Skip to content

Conversation

@louispt1
Copy link

@louispt1 louispt1 commented Dec 12, 2025

Description

Create saved scenario runner, update saved scenario runner and minimal example in Jupyter notebook.
Create a minimal saved scenario model with create, from_scenario and update methods.
Add a save method 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

@louispt1 louispt1 requested a review from noracato December 12, 2025 12:13
@louispt1 louispt1 changed the title Create Saved Scenario Runner Create & Update Saved Scenario + model Dec 15, 2025
**kwargs: Additional arguments passed to the request
"""

ALLOWED_KEYS = ["title", "description", "private", "discarded"]
Copy link
Member

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).

Suggested change
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}")
Copy link
Member

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)

Copy link
Member

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)

params = {"scenario_id": scenario.id, "title": title, **kwargs}
return cls.create(params, client=client)

def get_scenario(self, client: Optional[BaseClient] = None) -> "Scenario":
Copy link
Member

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)

@louispt1 louispt1 force-pushed the create-saved-scenario branch from 8820ff5 to b127e34 Compare December 17, 2025 10:53
@louispt1 louispt1 merged commit aa72d35 into version-2 Dec 17, 2025
1 check passed
@louispt1 louispt1 deleted the create-saved-scenario branch December 17, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants