sessions
sessions
Session management utilities.
Classes
Sessions
Bases: Base
A collection of Scenario objects
Source code in src/pyetm/models/base.py
Functions
load_all
classmethod
Load scenarios belonging to the authenticated user.
Fetches ETEngine sessions for the authenticated user. By default, automatically fetches all pages. If page parameter is provided, fetches only that specific page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
Optional[int]
|
Optional page number (1-indexed). If provided, fetches only that page. If None, fetches all pages automatically. |
None
|
per_page
|
Optional[int]
|
Optional number of results per page |
None
|
client
|
Optional[BaseClient]
|
Optional BaseClient instance for API communication |
None
|
Returns:
| Type | Description |
|---|---|
'Sessions'
|
Sessions collection containing user's sessions |
Raises:
| Type | Description |
|---|---|
ValueError
|
If authentication fails or API request fails |
Source code in src/pyetm/models/sessions.py
load_many
classmethod
Load multiple Session objects by their ETEngine session IDs.
This is a bulk operation - individual failures are collected as warnings to allow partial success. Use PYETM_ERROR_MODE=safe to raise on first error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_ids
|
Iterable[int]
|
Iterable of ETEngine session IDs to load |
required |
client
|
Optional[BaseClient]
|
Optional BaseClient instance for API communication |
None
|
Returns:
| Type | Description |
|---|---|
'Sessions'
|
Sessions collection containing the loaded Session objects. |
'Sessions'
|
Warnings from failures are displayed automatically. |
Source code in src/pyetm/models/sessions.py
create_many
classmethod
Create multiple Session objects from parameter dicts.
This is a bulk operation - individual failures are collected as warnings to allow partial success. Use PYETM_ERROR_MODE=safe to raise on first error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_params
|
Iterable[dict[str, Any]]
|
Iterable of parameter dicts containing area_code, end_year, etc. |
required |
area_code
|
str | None
|
Default area_code for all sessions (if not in params) |
None
|
end_year
|
int | None
|
Default end_year for all sessions (if not in params) |
None
|
Returns:
| Type | Description |
|---|---|
'Sessions'
|
Sessions collection containing created Session objects. |
'Sessions'
|
Warnings from failures are displayed automatically. |
Source code in src/pyetm/models/sessions.py
to_excel
Export all scenarios to Excel.
Source code in src/pyetm/models/sessions.py
from_excel
classmethod
Import scenarios (Sessions) from Excel file.
Only loads scenarios where the 'session' column is True. SavedScenarios (session=False or missing) are ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xlsx_path
|
PathLike[str] | str
|
Path to Excel file |
required |
Returns:
| Type | Description |
|---|---|
'Sessions'
|
Scenarios collection containing only Session instances |