-
Notifications
You must be signed in to change notification settings - Fork 0
Create & Update Saved Scenario + model #107
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
Conversation
| **kwargs: Additional arguments passed to the request | ||
| """ | ||
|
|
||
| ALLOWED_KEYS = ["title", "description", "private", "discarded"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating is not in scope at this moment, but for History we will need to be able to update the scenario ID (save a new version).
| ALLOWED_KEYS = ["title", "description", "private", "discarded"] | |
| ALLOWED_KEYS = ["title", "scenario_id", "private", "discarded"] |
I'd suggest not to include the description. There is not really a use case for it, and with Action Text you can do a lot more then through the API.
|
|
||
| if 400 <= value < 500: | ||
| text = info.data.get("text", "") | ||
| raise ValueError(f"HTTP {value}: {text}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have time to fix this, but if I do a bad create saved scenario request, I might get something like this in my notebook:
SavedScenarioError: Could not create saved scenario: ['1 validation error for ETMResponse\nstatus_code\n Value error, HTTP 404: [type=value_error, input_value=404, input_type=int]\n For further information visit https://errors.pydantic.dev/2.11/v/value_error']We should make that in to something more understandable for our users. Or at least make sure it doesn't happen during the demo ;)
| scenario: Optional[Dict[str, Any]] = None | ||
|
|
||
| _scenario_model: Optional[Scenario] = PrivateAttr(None) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add friendly methods that allows users to skip the Scenario object.
SavedScenario.load(ss_id)
SavedScenario.new(scenario_id=12345)
src/pyetm/models/saved_scenario.py
Outdated
| params = {"scenario_id": scenario.id, "title": title, **kwargs} | ||
| return cls.create(params, client=client) | ||
|
|
||
| def get_scenario(self, client: Optional[BaseClient] = None) -> "Scenario": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you feel about making this method implicit? Like we do with eg the inputs properties on the Scenario
So if you call:
SavedScenario.session It will call what you currently have in here (setting the model)
…add spec and add 'save' method to Scenario model
7151532 to
8820ff5
Compare
8820ff5 to
b127e34
Compare
Description
Create saved scenario runner, update saved scenario runner and minimal example in Jupyter notebook.
Create a minimal saved scenario model with
create,from_scenarioandupdatemethods.Add a
savemethod to the Scenario model.Add tests for the new runners.
Goes with this Engine PR and this MyETM PR.
Related Issues
Closes #105
Closes #101
Closes #97
Closes #100