Skip to content

Comment-preservation behavior undesirable in runmanager.remote.set_globalsย #123

@neutrinonerd3333

Description

@neutrinonerd3333

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:

  1. that this comment-preservation behavior be disabled when raw == True,
  2. that furthermore the behavior should be disable-able even when raw == False, and
  3. 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 by get_globals(raw=True).)

Happy to supply a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions