Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
e34512d0
Commit
e34512d0
authored
2 months ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Add some logging around constant injection
parent
c8fc4255
No related branches found
No related tags found
1 merge request
!1026
Feat[Jungfrau]: Inject CCVs using RESTful API
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cal_tools/constants.py
+9
-3
9 additions, 3 deletions
src/cal_tools/constants.py
with
9 additions
and
3 deletions
src/cal_tools/constants.py
+
9
−
3
View file @
e34512d0
import
binascii
import
logging
import
time
from
dataclasses
import
asdict
,
dataclass
from
datetime
import
datetime
,
timezone
from
hashlib
import
md5
from
pathlib
import
Path
...
...
@@ -21,6 +21,8 @@ from cal_tools.calcat_interface2 import (
CONDITION_NAME_MAX_LENGTH
=
60
log
=
logging
.
getLogger
(
__name__
)
class
InjectionError
(
Exception
):
...
...
...
@@ -80,7 +82,7 @@ def create_unique_cc_name(det_type, calibration, condition_name):
def
create_unique_ccv_name
(
start_idx
):
# Generate unique name if it doesn't exist
datetime_str
=
datetime_str
=
datetime
.
now
(
datetime_str
=
datetime
.
now
(
timezone
.
utc
).
strftime
(
'
%Y%m%d_%H%M%S
'
)
return
f
'
{
datetime_str
}
_sIdx=
{
start_idx
}
'
...
...
@@ -243,11 +245,13 @@ def get_or_create_calibration_constant(
cc_id
=
client
.
get
(
f
"
calibrations/
{
cal_id
}
/get_calibration_constant
"
,
calibration_constant
)
)[
'
id
'
]
log
.
debug
(
"
Retrieved existing calibration constant ID %s
"
,
cc_id
)
except
CalCatAPIError
as
e
:
if
e
.
status_code
!=
404
:
raise
cc_id
=
client
.
post
(
"
calibration_constants
"
,
calibration_constant
)[
'
id
'
]
log
.
debug
(
"
Created calibration constant ID %s
"
,
cc_id
)
return
cc_id
...
...
@@ -344,6 +348,7 @@ def inject_ccv(const_src, ccv_root, report_to=None, client=None):
try
:
condition_id
,
condition_name
=
create_condition
(
client
,
detector_type
,
pdu_name
,
pdu_uuid
,
cond_params
)
log
.
debug
(
"
Condition ID: %s & name: %r
"
,
condition_id
,
condition_name
)
# Create Calibration Constant in database, if not available.
cc_id
=
get_or_create_calibration_constant
(
...
...
@@ -360,6 +365,7 @@ def inject_ccv(const_src, ccv_root, report_to=None, client=None):
description
=
""
,
))
report_id
=
resp
[
'
id
'
]
log
.
debug
(
"
CalCat report ID: %s
"
,
report_id
)
# Get PDU ID before creating new CCV.
pdu_id
=
client
.
pdu_by_name
(
pdu_name
)[
'
id
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment