question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Making workspaces immutable?

See original GitHub issue

Question

Currently workspaces are mutable:

import pyhf
spec = {
    "channels": [
        {
            "name": "Signal Region",
            "samples": [
                {
                    "data": [10],
                    "modifiers": [
                        {"data": [1], "name": "staterror_Signal-Region", "type": "staterror"},
                        {"data": None, "name": "Signal strength",  "type": "normfactor"},
                    ],
                    "name": "Signal",
                }
            ],
        }
    ],
    "measurements": [
        {
            "config": {
                "parameters": [{"name": "staterror_Signal-Region", "fixed": True, "inits": [1.1]}],
                "poi": "Signal strength",
            },
            "name": "fit",
        }
    ],
    "observations": [{"data": [475], "name": "Signal Region"}],
    "version": "1.0.0",
}
ws = pyhf.Workspace(spec)
model = ws.model()
print(model.config.suggested_init())  # -> [1.1, 1.0]
spec["measurements"][0]["config"]["parameters"][0]["inits"] = [1.2]
print(model.config.suggested_init())  # -> [1.1, 1.0]
model = ws.model()
print(model.config.suggested_init())  # -> [1.2, 1.0]

Models on the other hand are immutable. What do you think about making workspaces immutable as well? While I do not have a concrete example in mind, I imagine it could prevent some difficult-to-debug scenarios where the workspace changes without the user noticing.

Relevant Issues and Pull Requests

none

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lukasheinrichcommented, Oct 19, 2020

I thiink a simple change like

spec_copy = copy.deepcopy(spec)
super(Workspace, self).__init__(spec_copy, channels=spec_copy['channels'])

should suffice

0reactions
matthewfeickertcommented, Oct 19, 2020

@lukasheinrich Sorry hadn’t taken the time to read all the other replies when I copy pasted that in. That would be great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature] "yarn workspaces focus" option --immutable #1803
I'd be willing to implement this feature This feature can already be implemented through a plugin - the workspace-tools plugin in this repo....
Read more >
Are Travis Workspaces immutable? - Travis CI Community
Hi, I'm not sure whether the following “problem” is by design or rather a bug, but either way it is undocumented or at...
Read more >
Immutable offers workspace flexibility at WeWork to drive ...
Immutable offers workspace flexibility at WeWork to drive global expansion ... Immutable is creating a destination for people to achieve ...
Read more >
How to build immutable servers fast - TechBeacon
The time it takes to make a change through immutable servers can be a challenge. I'm going to share some techniques for keeping...
Read more >
Efficient workspace: type or immutable? - Julia Discourse
Question: Should WorkSpace be an immutable composite ( immutable ) or ... in which case immutable makes it much cheaper to store in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found