Feat/parameter value change callback#6934
Conversation
… to global class-level with tests
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6934 +/- ##
=======================================
Coverage 59.92% 59.92%
=======================================
Files 342 342
Lines 31411 31420 +9
=======================================
+ Hits 18823 18829 +6
- Misses 12588 12591 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@microsoft-github-policy-service agree |
|
@microsoft/qcodes-maintainers Does anyone else want add an opinion on this feature before merge. I think it looks like a generally useful feature that we should be fine with adding. |
|
@mahmut-oqs Just waiting to see if there is any other input. Other than that I think this is good but it would be nice with some kind of example + a changelog entry (see the template that shows up when you create the pr) to let others know about this feature |
I have done both. Please let me know if any changes are needed. |
astafan8
left a comment
There was a problem hiding this comment.
Thank you for a thorough contribution! Great description, tests, newsfragment -- thank you!
|
@mahmut-oqs We realized that an instance level callback is also required for some of our use cases. Could you have a look at #6934 which extends your pr with this feature while keeping the feature as you wanted it too. |
|
@jenshnielsen Okay, I am going to have a look at it. |
|
@mahmut-oqs I merged #6934 ok to close this one? |
@jenshnielsen Yes, I am closing the PR right now. Thank you for the feature and the cooperation. |
Pull request was closed
Description
This PR introduces the basic infrastructure needed to use QCoDeS in our systems to transition from memory-intensive full snapshots to an efficient parameter-level tracking system. It adds a global callback mechanism to
ParameterBasethat allows individual parameter changes to be logged directly to a time series database (or any other custom logging system).Motivation
Our current systems store full snapshots of experiment states, which has led to several issues:
This PR is the first step towards a more efficient, database-backed parameter tracking system that will:
Implementation details
global_value_changed_callback: Callable[[ParameterBase, Any], None] | None = NoneinParameterBaseto support parameter-level tracking.set_global_value_changed_callback(callback: Callable[[ParameterBase, Any], None] | None)to configure (or clear) the global callback._wrap_setmethod to invoke the global callback after each parameter change.Breaking changes
None. This is a backwards-compatible addition that is only activated when the callback is explicitly set.
Example usage
Note: You can easily swap out
monitor_callbackwith a function likewrite_to_databasethat inserts the parameter change record into a database. Just replace the print statement with your database logic.