Skip to content

Run

Since each scenario corresponds to a probability distribution, performing a sensitivity analysis helps to explore uncertainty for a given scenario.

Sensitivity analysis involves tweaking different variables e.g. technology costs for a scenario and performing a new run. It will become possible to use the TransitionZero platform to conduct sensitivity analysis using runs and but for now runs data for existing scenarios can be accessed via the

To access data for runs, you can use this Jupyter Notebook on Github.

Bases: RunBase

Source code in tz/client/run.py
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
class Run(schemas.RunBase):
    _run_results: Optional[RunResults] = None

    @classmethod
    def from_id(cls, id: str) -> "Run":
        """
        Initialize the Run object from an ID.

        Args:
            id (str): A run ID, e.g. `model-slug:scenario-slug:run-slug`.

        Returns:
            Run: A Run object.
        """
        run_reponse = api.runs.get(fullslug=id)
        return cls(**run_reponse.model_dump())

    @classmethod
    def search(
        cls,
        slug: Optional[str] = None,
        model_slug: Optional[str] = None,
        scenario_slug: Optional[str] = None,
        owner_id: Optional[str] = None,
        featured: Optional[bool] = None,
        includes: Optional[str] = None,
        public: Optional[bool] = None,
        limit: int = 5,
        page: int = 0,
    ) -> List["Run"]:
        """
        Search for runs using various filters.

        Args:
            slug (str, optional): The slug of the run.
            model_slug (str, optional): The slug of the model to filter by.
            scenario_slug (str, optional): The slug of the scenario to filter by.
            owner_id (str, optional): The ID of the owner.
            featured (bool, optional): Filter by whether the run is featured.
            includes (str, optional): Additional fields to include in the search results.
            public (bool, optional): Filter by whether the run is public.
            limit (int): The maximum number of search results to return per page.
            page (int): The page number of search results to return.

        Returns:
            List[Run]: A list of Run objects.
        """

        search_results = api.runs.search(
            slug=slug,
            model_slug=model_slug,
            scenario_slug=scenario_slug,
            owner_id=owner_id,
            featured=featured,
            includes=includes,
            public=public,
            limit=limit,
            page=page,
        )

        return [cls(**r.model_dump()) for r in search_results]

    @property
    def id(self) -> str:
        """The ID of the run. A combination of the model, scenario, and run slugs."""
        return f"{self.model_slug}:{self.scenario_slug}:{self.slug}"

    @property
    def model(self) -> Optional["Model"]:
        """The model associated with this run."""
        run_data = api.runs.get(fullslug=self.id, includes="model")
        if run_data.model is None:
            return None
        return factory.model(**run_data.model.model_dump())

    @property
    def scenario(self) -> Optional["Scenario"]:
        """The scenario associated with this run."""
        run_data = api.runs.get(fullslug=self.id, includes="scenario")
        if run_data.scenario is None:
            return None
        return factory.scenario(**run_data.scenario.model_dump())

    @property
    def results(self) -> RunResults:
        if self._run_results is None:
            self._run_results = RunResults(id=self.id)
            return self._run_results
        return self._run_results

    def __str__(self) -> str:
        return f"Run: {self.name} (id={self.id})"

id: str property

The ID of the run. A combination of the model, scenario, and run slugs.

model: Optional[Model] property

The model associated with this run.

scenario: Optional[Scenario] property

The scenario associated with this run.

from_id(id) classmethod

Initialize the Run object from an ID.

Parameters:

Name Type Description Default
id str

A run ID, e.g. model-slug:scenario-slug:run-slug.

required

Returns:

Name Type Description
Run Run

A Run object.

Source code in tz/client/run.py
154
155
156
157
158
159
160
161
162
163
164
165
166
@classmethod
def from_id(cls, id: str) -> "Run":
    """
    Initialize the Run object from an ID.

    Args:
        id (str): A run ID, e.g. `model-slug:scenario-slug:run-slug`.

    Returns:
        Run: A Run object.
    """
    run_reponse = api.runs.get(fullslug=id)
    return cls(**run_reponse.model_dump())

search(slug=None, model_slug=None, scenario_slug=None, owner_id=None, featured=None, includes=None, public=None, limit=5, page=0) classmethod

Search for runs using various filters.

Parameters:

Name Type Description Default
slug str

The slug of the run.

None
model_slug str

The slug of the model to filter by.

None
scenario_slug str

The slug of the scenario to filter by.

None
owner_id str

The ID of the owner.

None
featured bool

Filter by whether the run is featured.

None
includes str

Additional fields to include in the search results.

None
public bool

Filter by whether the run is public.

None
limit int

The maximum number of search results to return per page.

5
page int

The page number of search results to return.

0

Returns:

Type Description
List[Run]

List[Run]: A list of Run objects.

Source code in tz/client/run.py
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
@classmethod
def search(
    cls,
    slug: Optional[str] = None,
    model_slug: Optional[str] = None,
    scenario_slug: Optional[str] = None,
    owner_id: Optional[str] = None,
    featured: Optional[bool] = None,
    includes: Optional[str] = None,
    public: Optional[bool] = None,
    limit: int = 5,
    page: int = 0,
) -> List["Run"]:
    """
    Search for runs using various filters.

    Args:
        slug (str, optional): The slug of the run.
        model_slug (str, optional): The slug of the model to filter by.
        scenario_slug (str, optional): The slug of the scenario to filter by.
        owner_id (str, optional): The ID of the owner.
        featured (bool, optional): Filter by whether the run is featured.
        includes (str, optional): Additional fields to include in the search results.
        public (bool, optional): Filter by whether the run is public.
        limit (int): The maximum number of search results to return per page.
        page (int): The page number of search results to return.

    Returns:
        List[Run]: A list of Run objects.
    """

    search_results = api.runs.search(
        slug=slug,
        model_slug=model_slug,
        scenario_slug=scenario_slug,
        owner_id=owner_id,
        featured=featured,
        includes=includes,
        public=public,
        limit=limit,
        page=page,
    )

    return [cls(**r.model_dump()) for r in search_results]