-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ChainMap for UserCommands #375
Conversation
Make UserCommends a sub-subclass of ChainMap. Also some refactoring and changes related to the new superclass. Fix wonky reload in set_modes.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev_master #375 +/- ##
==============================================
- Coverage 74.29% 74.21% -0.08%
==============================================
Files 56 56
Lines 7818 7854 +36
==============================================
+ Hits 5808 5829 +21
- Misses 2010 2025 +15 ☔ View full report in Codecov by Sentry. |
Any ideas why the RTD build fails on this @hugobuddel ? I can't really make heads or tails of the error it produces... |
No. I just (tried to) rebuild RTD for the dev_master branch and that also fails. So I think it is caused by a change on their end. Maybe we still need to do something, but it is unrelated to this PR I think. |
|
Oh yeah, I just saw that the dev_master fails with the same cryptic error. So that's nothing to do with this here. Still annoying... |
I'll go ahead and merge this. We did discuss it, I addressed the previous review comments and tests are passing. |
Yeah fine. I didn't do a full review yet, as the PR was still marked draft, but we covered the important points. |
This makes
UserCommands
a subclass ofastar_utils.NestedChainMap
, which is a bang-string-key variant subclass of the standard library'scollections.ChainMap
. This enables a separation of configuration "layers" into global settings and default, optical train-wide settings and, in the future, effect-level properties and kwargs. Any changes applied through simple assignment (i.e.__setitem__
, e.g.cmd["foo"] = 42
) will only modify the top layer of this object, thus not influence any other instance building on the same base layer. The individual levels are "by ref", so any change that is applied to the global settings (e.g. logging level) will be seen by all instances. All of this is an advantage over just updating dicts, and potentially making deep copies to avoid cross-contamination.Additionally, I made some refactoring changes to the rather convoluted
.update()
method ofUserCommands
. It's still not quite where I want it to be, but one step at a time. I also added a whole bunch of debug-level logging to, well, debug the YAML loading process, mostly. This could be reduced again in the future, once it's more stable (or once [if] we change the way instrument packages are handled anyway...).This also bumps the required version of astar-utils to 0.2.2, to include the new bang-string classes from there.