-
Notifications
You must be signed in to change notification settings - Fork 60
Description
I have some code that sets runmanager globals via runmanager.remote, and am running into issues with the current behavior of runmanager.remote.set_globals, which will preserve any existing string-final comments in the old globals and append them to the incoming new values. I argue that this behavior should be weakened or removed.
In my code, I try to get a copy of currently active globals, change some up, engage an expansion, and then restore the original globals. Since our globals have comments in them (often representing some commonly used values, and not necessarily string-final) that we'd like to preserve, I query the current globals with the raw option enabled:
import runmanager.remote as rr
previous_globals = rr.get_globals(raw=True)
rr.set_globals(...)
rr.engage()
rr.set_globals(previous_globals, raw=True)However, set_globals does something clever, taking the incoming revisions and appending any final comments. I think this is counterintuitive behavior, especially if using the raw option (which suggests that the string I put in is the string I should get). For example, a global that looks like 3 # 5 for configuration B would get the string-final comment doubled on each cycle of get_globals...set_globals
I suggest:
- that this comment-preservation behavior be disabled when
raw == True, - that furthermore the behavior should be disable-able even when
raw == False, and - that the comment-preservation should be deprecated, a suitable deprecation warning emitted when it is used, and removed in a future major release.
(If someone wishes to preserve comments like this, that can be handled in client code with the info provided byget_globals(raw=True).)
Happy to supply a PR.