Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
calng
Commits
adf0f3c5
Commit
adf0f3c5
authored
2 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Move expensive buffer changes to background to avoid timeouts
parent
1a655dcc
No related branches found
No related tags found
1 merge request
!12
Snapshot: field test deployed version as of end of run 202201
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/calng/base_correction.py
+9
-4
9 additions, 4 deletions
src/calng/base_correction.py
src/calng/utils.py
+19
-0
19 additions, 0 deletions
src/calng/utils.py
with
28 additions
and
4 deletions
src/calng/base_correction.py
+
9
−
4
View file @
adf0f3c5
...
...
@@ -709,8 +709,7 @@ class BaseCorrection(PythonDevice):
update
=
self
.
_prereconfigure_update_hash
if
update
.
has
(
"
frameFilter
"
):
with
self
.
_buffer_lock
:
self
.
_update_frame_filter
()
self
.
_lock_and_update_in_background
(
self
.
_update_frame_filter
)
elif
any
(
update
.
has
(
shape_param
)
for
shape_param
in
(
...
...
@@ -721,11 +720,17 @@ class BaseCorrection(PythonDevice):
"
frameFilter
"
,
)
):
with
self
.
_buffer_lock
:
self
.
_update_buffers
()
self
.
_lock_and_update_in_background
(
self
.
_update_buffers
)
# TODO: only call this if they are changed (is cheap, though)
self
.
_update_correction_flags
()
def
_lock_and_update_in_background
(
self
,
method
):
# TODO: securely handle errors (postReconfigure may succeed and device state not)
def
runner
():
with
self
.
_buffer_lock
,
utils
.
StateContext
(
self
,
State
.
CHANGING
):
method
()
threading
.
Thread
(
target
=
runner
,
daemon
=
True
).
start
()
def
loadMostRecentConstants
(
self
):
self
.
flush_constants
()
self
.
calcat_friend
.
flush_constants
()
...
...
This diff is collapsed.
Click to expand it.
src/calng/utils.py
+
19
−
0
View file @
adf0f3c5
...
...
@@ -279,6 +279,25 @@ class Stopwatch:
return
f
"
{
self
.
name
}
:
{
self
.
elapsed
()
:
.
3
f
}
s
"
class
StateContext
:
"""
What if device state was a stack?
"""
def
__init__
(
self
,
device
,
new_state
,
revert_to
=
None
):
self
.
device
=
device
if
revert_to
is
None
:
revert_to
=
device
.
get
(
"
state
"
)
self
.
revert_to
=
revert_to
self
.
new_state
=
new_state
def
__enter__
(
self
):
if
self
.
new_state
is
not
self
.
revert_to
:
self
.
device
.
updateState
(
self
.
new_state
)
def
__exit__
(
self
,
t
,
v
,
tb
):
if
self
.
new_state
is
not
self
.
revert_to
:
self
.
device
.
updateState
(
self
.
revert_to
)
class
TrainRatioTracker
:
"""
Measure how many percent of recent train IDs (from contiguous set) were seen
...
...
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
3566342d
·
2 years ago
mentioned in commit
3566342d
mentioned in commit 3566342d031db1bb435b6430f100afdbaaa6c4bf
Toggle commit list
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