Common Data Interface
Runs (ixmp4.data.run)
Data Transfer Object
- class ixmp4.data.run.dto.Run(*, updated_at: datetime | None, updated_by: str | None, created_at: datetime | None, created_by: str | None, id: int, model__id: int, model: Model, scenario__id: int, scenario: Scenario, version: int, is_default: bool, lock_transaction: int | None)
Bases:
BaseModel,HasCreationInfo,HasUpdateInfoModel run data model.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.run.service.RunService(transport: Transport)
Bases:
GetByIdService- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- versions: VersionRepository
- models: ItemRepository
- scenarios: ItemRepository
- transactions: TransactionRepository
- meta: PandasRepository
- meta_versions: VersionRepository
- create(model_name: str, scenario_name: str) Run
Creates a run with an incremented version number or version=1 if no versions exist. Will automatically create the models and scenarios if they don’t exist yet.
- Parameters:
- Returns:
The created run.
- Return type:
- create_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, model_name: str, scenario_name: str) None
- delete_by_id(id: int) None
Deletes a run and all associated iamc, optimization and meta data.
- Parameters:
id (int) – The unique integer id of the run.
- Raises:
RunNotFound – If the run with id does not exist.
- get(model_name: str, scenario_name: str, version: int) Run
Retrieves a run.
- Parameters:
- Raises:
RunNotFound – If the run with model_name, scenario_name and version does not exist.
- Returns:
The retrieved run.
- Return type:
- get_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, model_name: str, scenario_name: str, version: int) None
- get_or_create(model_name: str, scenario_name: str) Run
Tries to retrieve a run’s default version and creates it if it was not found.
- Parameters:
- Returns:
The retrieved or created run.
- Return type:
- get_default_version(model_name: str, scenario_name: str) Run
Retrieves a run’s default version.
- Parameters:
- Raises:
NoDefaultRunVersion – If no runs with model_name, scenario_name and is_default=True exist.
- Returns:
The retrieved run.
- Return type:
- get_default_version_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, model_name: str, scenario_name: str) None
- get_by_id(id: int) Run
Retrieves a Run by its id.
- Parameters:
id (int) – Unique integer id.
- Raises:
RunNotFound – If the Run with id does not exist.
- Returns:
The retrieved Run.
- Return type:
- list(**kwargs: Unpack[RunFilter]) List[Run]
Lists runs by specified criteria.
- Parameters:
**kwargs (any) – Any filter parameters as specified in RunFilter.
- Returns:
List of runs.
- Return type:
list[
ixmp4.data.run.dto.Run]
- paginated_list(pagination: Pagination, **kwargs: Unpack[RunFilter]) PaginatedResult[List[Run]]
- tabulate(include_audit_info: bool = False, include_internal_columns: bool = False, **kwargs: Unpack[RunFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulate runs by specified criteria.
- Parameters:
include_audit_info (bool) – Whether or not to include audit info columns in the data frame. Default:
Falseinclude_internal_columns (bool) – Whether or not to include internal database columns (
model__id,scenario__id,lock_transaction). Default:False**kwargs (any) – Any filter parameters as specified in RunFilter.
- Returns:
- A data frame with the columns:
id
model
scenario
version
is_default
- and if
include_internal_columnsisTrue: model__id
scenario__id
lock_transaction
- and if
include_audit_infoisTrue: created_by
created_at
updated_by
updated_at
- Return type:
- paginated_tabulate(pagination: Pagination, include_audit_info: bool = False, include_internal_columns: bool = False, **kwargs: Unpack[RunFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
- set_as_default_version(id: int) None
Sets a run as the default version for a (model, scenario) combination.
- Parameters:
id (int) – Unique integer id.
- Raises:
RunNotFound – If no run with the id exists.
- set_as_default_version_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, id: int) None
- unset_as_default_version(id: int) None
Unsets a run as the default version leaving no default version for a (model, scenario) combination.
- Parameters:
id (int) – Unique integer id.
- Raises:
RunNotFound – If no run with the id exists.
- unset_as_default_version_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, id: int) None
- revert(id: int, transaction__id: int, revert_platform: bool = False) None
Reverts run data to a specific transaction__id.
- Parameters:
- Raises:
RunNotFound – If no run with the id exists.
- revert_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, id: int, transaction__id: int, revert_platform: bool = False) None
- lock(id: int) Run
Locks a run at the current transaction (via transaction__id).
- Parameters:
id (int) – Unique integer id.
- Raises:
RunNotFound – If no run with the id exists.
RunIsLocked – If the run is already locked.
- unlock(id: int) Run
Locks a run at the current transaction (via transaction__id).
- Parameters:
id (int) – Unique integer id.
- Raises:
RunNotFound – If no run with the id exists.
Filters
- class ixmp4.data.run.filter.IamcRunFilter
Bases:
TypedDict- variable: InstrumentedAttribute object at 0x79d92787b380>)]
- unit: InstrumentedAttribute object at 0x79d927827d80>)]
- region: InstrumentedAttribute object at 0x79d927827ba0>)]
- ixmp4.data.run.filter.filter_by_iamc(exc: Select | Update | Delete, value: dict[str, Any] | bool | None, *, schema: type[Any], repo: BaseRepository[Any]) Select | Update | Delete
- class ixmp4.data.run.filter.RunFilter
Bases:
RunFilter- model: InstrumentedAttribute object at 0x79d927323420>]
- scenario: InstrumentedAttribute object at 0x79d9273234c0>]
- iamc: IamcRunFilter | bool | None, <function filter_by_iamc at 0x79d926f420c0>]
- default_only: Annotated[bool, <function filter_by_default_only at 0x79d926f42e80>]
Models (ixmp4.data.model)
Data Transfer Object
- class ixmp4.data.model.dto.Model(*, created_at: datetime | None, created_by: str | None, id: int, name: str)
Bases:
BaseModel,HasCreationInfoThe model.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.model.service.ModelService(transport: Transport)
Bases:
DocsService,GetByIdService- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- versions: VersionRepository
- create(name: str) Model
Creates a model.
- Parameters:
name (str) – The name of the model.
- Raises:
ModelNotUnique – If the model with name is not unique.
- Returns:
The created model.
- Return type:
- delete_by_id(id: int) None
Deletes a model.
- Parameters:
id (int) – The unique integer id of the model.
- Raises:
ModelNotFound – If the model with id does not exist.
ModelDeletionPrevented – If the model with id is used in the database, preventing it’s deletion.
Unauthorized – If the current user is not authorized to perform this action.
- get_by_name(name: str) Model
Retrieves a model by its name.
- Parameters:
name (str) – The unique name of the model.
- Raises:
ModelNotFound – If the model with name does not exist.
- Returns:
The retrieved model.
- Return type:
- get_by_id(id: int) Model
Retrieves a model by its id.
- Parameters:
id (int) – The integer id of the model.
- Raises:
ixmp4.data.abstract.Model.NotFound – If the model with id does not exist.
- Returns:
The retrieved model.
- Return type:
- list(**kwargs: Unpack[ModelFilter]) List[Model]
Lists models by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
ModelFilter.- Returns:
List of models.
- Return type:
- paginated_list(pagination: Pagination, **kwargs: Unpack[ModelFilter]) PaginatedResult[List[Model]]
- tabulate(**kwargs: Unpack[ModelFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulates models by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
ModelFilter.- Returns:
- A data frame with the columns:
id
name
- Return type:
- paginated_tabulate(pagination: Pagination, **kwargs: Unpack[ModelFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
Filters
- class ixmp4.data.model.filter.IamcModelFilter
Bases:
ModelFilter- variable: InstrumentedAttribute object at 0x79d927827ce0>)]
- unit: InstrumentedAttribute object at 0x79d927827d80>)]
- region: InstrumentedAttribute object at 0x79d927827ba0>)]
- run: InstrumentedAttribute object at 0x79d927827b00>)]
- ixmp4.data.model.filter.filter_by_iamc(exc: Select | Update | Delete, value: dict[str, Any] | bool | None, *, schema: type[Any], repo: BaseRepository[Any]) Select | Update | Delete
- class ixmp4.data.model.filter.ModelFilter
Bases:
ModelFilter- iamc: IamcModelFilter | bool | None, <function filter_by_iamc at 0x79d925afeca0>]
- class ixmp4.data.model.filter.FacadeIamcModelFilter
Bases:
ModelFilter- variable: VariableFilter
- unit: UnitFilter
- region: RegionFilter
- run: FacadeRunFilter
- ixmp4.data.model.filter.iamc_facade_to_data_filter(filter_values: Mapping[str, Any]) IamcModelFilter
- class ixmp4.data.model.filter.FacadeModelFilter
Bases:
ModelFilter- iamc: FacadeIamcModelFilter | bool | None
- ixmp4.data.model.filter.facade_to_data_filter(filter_values: Mapping[str, Any]) ModelFilter
Scenarios (ixmp4.data.scenario)
Data Transfer Object
- class ixmp4.data.scenario.dto.Scenario(*, created_at: datetime | None, created_by: str | None, id: int, name: str)
Bases:
BaseModel,HasCreationInfoModeling scenario data model.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.scenario.service.ScenarioService(transport: Transport)
Bases:
DocsService,GetByIdService- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- versions: VersionRepository
- create(name: str) Scenario
Creates a scenario.
- Parameters:
name (str) – The name of the scenario.
- Raises:
ScenarioNotUnique – If the scenario with name is not unique.
- Returns:
The created scenario.
- Return type:
- delete_by_id(id: int) None
Deletes a scenario.
- Parameters:
id (int) – The unique integer id of the scenario.
- Raises:
ScenarioNotFound – If the scenario with id does not exist.
ScenarioDeletionPrevented – If the scenario with id is used in the database, preventing it’s deletion.
Unauthorized – If the current user is not authorized to perform this action.
- get_by_name(name: str) Scenario
Retrieves a scenario by its name.
- Parameters:
name (str) – The unique name of the scenario.
- Raises:
ScenarioNotFound – If the scenario with name does not exist.
- Returns:
The retrieved scenario.
- Return type:
ixmp4.data.base.iamc.Scenario
- get_by_id(id: int) Scenario
Retrieves a scenario by its id.
- Parameters:
id (int) – The integer id of the scenario.
- Raises:
ixmp4.data.abstract.Scenario.NotFound – If the scenario with id does not exist.
- Returns:
The retrieved scenario.
- Return type:
ixmp4.data.base.iamc.Scenario
- list(**kwargs: Unpack[ScenarioFilter]) List[Scenario]
Lists scenarios by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
ScenarioFilter.- Returns:
List of scenarios.
- Return type:
- paginated_list(pagination: Pagination, **kwargs: Unpack[ScenarioFilter]) PaginatedResult[List[Scenario]]
- tabulate(**kwargs: Unpack[ScenarioFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulates scenarios by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
ScenarioFilter.- Returns:
- A data frame with the columns:
id
name
- Return type:
- paginated_tabulate(pagination: Pagination, **kwargs: Unpack[ScenarioFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
Filters
- class ixmp4.data.scenario.filter.IamcScenarioFilter
Bases:
ScenarioFilter- variable: InstrumentedAttribute object at 0x79d927827ce0>)]
- unit: InstrumentedAttribute object at 0x79d927827d80>)]
- region: InstrumentedAttribute object at 0x79d927827ba0>)]
- run: InstrumentedAttribute object at 0x79d927827b00>)]
- ixmp4.data.scenario.filter.filter_by_iamc(exc: Select | Update | Delete, value: dict[str, Any] | bool | None, *, schema: type[Any], repo: BaseRepository[Any]) Select | Update | Delete
- class ixmp4.data.scenario.filter.ScenarioFilter
Bases:
ScenarioFilter- iamc: IamcScenarioFilter | bool | None, <function filter_by_iamc at 0x79d9259ea8e0>]
- class ixmp4.data.scenario.filter.FacadeIamcScenarioFilter
Bases:
ScenarioFilter- variable: VariableFilter
- unit: UnitFilter
- region: RegionFilter
- run: FacadeRunFilter
- ixmp4.data.scenario.filter.iamc_facade_to_data_filter(filter_values: Mapping[str, Any]) IamcScenarioFilter
- class ixmp4.data.scenario.filter.FacadeScenarioFilter
Bases:
ScenarioFilter- iamc: FacadeIamcScenarioFilter | bool | None
- ixmp4.data.scenario.filter.facade_to_data_filter(filter_values: Mapping[str, Any]) ScenarioFilter
Run Meta Indicators (ixmp4.data.meta)
Data Transfer Object
- class ixmp4.data.meta.dto.RunMetaEntry(*, id: int, run__id: int, key: str, dtype: Type, value: bool | float | int | str, value_int: int | None, value_str: str | None, value_float: float | None, value_bool: bool | None)
Bases:
BaseModelRun meta entry model.
- dtype: Type
Datatype of the entry’s value.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.meta.service.RunMetaEntryService(transport: Transport)
Bases:
Service- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- runs: ItemRepository
- runs_pandas: PandasRepository
- default_filter: RunMetaEntryFilter = {'run': {'default_only': True}}
- create(run_id: int, key: str, value: bool | float | int | str) RunMetaEntry
Creates a metadata entry.
- Parameters:
run_id (int) – The id of the
ixmp4.data.run.dto.Runfor which this entry is defined.key (str) – The key (unique to this run) for which value is associated.
value (MetaValueType) – The value for this entry.
- Raises:
RunMetaEntryNotUnique – If the metadata entry with key and run__id is not unique.
- Returns:
The created metadata entry.
- Return type:
RunMetaEntry
- create_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, run_id: int, key: str, value: bool | float | int | str) None
- get(run_id: int, key: str) RunMetaEntry
Retrieves a metadata entry by the run id and key.
- Parameters:
run_id (int) – The id of the
ixmp4.data.run.dto.Runfor which this entry is defined.key (str) – The key (unique to this run) for which value is to be retrieved.
- Raises:
RunMetaEntryNotFound – If the metadata entry with id does not exist.
- Returns:
The retrieved metadata entry.
- Return type:
RunMetaEntry
- get_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, run_id: int, key: str) None
- delete_by_id(id: int) None
Deletes a metadata entry.
- Parameters:
id (int) – Unique integer id of the entry to delete
- Raises:
RunMetaEntryNotFound – If the metadata entry with id was not found.
- list(**kwargs: Unpack[RunMetaEntryFilter]) list[RunMetaEntry]
Lists metadata entries by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
RunMetaEntryFilter.- Returns:
List of metadata entries.
- Return type:
Iterable[
RunMetaEntry]
- paginated_list(pagination: Pagination, **kwargs: Unpack[RunMetaEntryFilter]) PaginatedResult[List[RunMetaEntry]]
- tabulate(include_run_index: bool = False, join_run_index: bool | None = None, **kwargs: Unpack[RunMetaEntryFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulates metadata entries by specified criteria.
- Parameters:
include_run_index (bool, optional) – Whether to include run columns in the data frame. Default:
False**kwargs (any) – Filter parameters as specified in
RunMetaEntryFilter.
- Returns:
- A data frame with the columns:
id
dtype
key
value
- if
include_run_indexisFalse(default): run__id
- if
include_run_indexisTrue: model
scenario
version
- Return type:
- paginated_tabulate(pagination: Pagination, include_run_index: bool = False, join_run_index: bool | None = None, **kwargs: Unpack[RunMetaEntryFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
- bulk_upsert(df: WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]) None
Upserts a dataframe of run meta indicator entries.
- Parameters:
df (
pandas.DataFrame) –- A data frame with the columns:
run__id
key
value
- bulk_upsert_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, df: WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]) None
- bulk_delete(df: WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]) None
Deletes run meta indicator entries as specified per dataframe. Warning: No recovery of deleted data shall be possible via ixmp after the execution of this function.
- Parameters:
df (
pandas.DataFrame) –- A data frame with the columns:
run__id
key
- bulk_delete_auth_check(auth_ctx: AuthorizationContext, platform: PlatformProtocol, df: WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]) None
Filters
- class ixmp4.data.meta.filter.RunFilter
Bases:
RunFilter- model: InstrumentedAttribute object at 0x79d927323420>]
- scenario: InstrumentedAttribute object at 0x79d9273234c0>]
- default_only: Annotated[bool, <function filter_by_default_only at 0x79d926f42e80>]
- class ixmp4.data.meta.filter.RunMetaEntryFilter
Bases:
RunMetaEntryFilter- run: InstrumentedAttribute object at 0x79d927446660>]
- class ixmp4.data.meta.filter.FacadeRunMetaEntryFilter
Bases:
RunMetaEntryFilter- run: FacadeRunFilter
- ixmp4.data.meta.filter.facade_to_data_filter(filter_values: Mapping[str, Any]) RunMetaEntryFilter
Regions (ixmp4.data.region)
Data Transfer Object
- class ixmp4.data.region.dto.Region(*, created_at: datetime | None, created_by: str | None, id: int, name: str, hierarchy: str)
Bases:
BaseModel,HasCreationInfoRegion data model.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.region.service.RegionService(transport: Transport)
Bases:
DocsService,GetByIdService- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- versions: VersionRepository
- create(name: str, hierarchy: str) Region
Creates a region.
- Parameters:
- Raises:
RegionNotUnique – If the region with name is not unique.
Unauthorized – If the current user is not authorized to perform this action.
- Returns:
The created region.
- Return type:
- delete_by_id(id: int) None
Deletes a region.
- Parameters:
id (int) – The unique integer id of the region.
- Raises:
RegionNotFound – If the region with id does not exist.
RegionDeletionPrevented – If the region with id is used in the database, preventing it’s deletion.
Unauthorized – If the current user is not authorized to perform this action.
- get_by_name(name: str) Region
Retrieves a region by its name.
- Parameters:
name (str) – The unique name of the region.
- Raises:
RegionNotFound – If the region with name does not exist.
Unauthorized – If the current user is not authorized to perform this action.
- Returns:
The retrieved region.
- Return type:
Region
- get_by_id(id: int) Region
Retrieves a region by its id.
- Parameters:
id (int) – The integer id of the region.
- Raises:
RegionNotFound – If the region with id does not exist.
Unauthorized – If the current user is not authorized to perform this action.
- Returns:
The retrieved region.
- Return type:
Region
- list(**kwargs: Unpack[RegionFilter]) List[Region]
Lists regions by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
RegionFilter.- Raises:
Unauthorized – If the current user is not authorized to perform this action.
- Returns:
List of regions.
- Return type:
- paginated_list(pagination: Pagination, **kwargs: Unpack[RegionFilter]) PaginatedResult[List[Region]]
- tabulate(**kwargs: Unpack[RegionFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulates regions by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
RegionFilter.- Returns:
- A data frame with the columns:
id
name
hierarchy
- Return type:
- paginated_tabulate(pagination: Pagination, **kwargs: Unpack[RegionFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
Filters
- class ixmp4.data.region.filter.IamcRegionFilter
Bases:
RegionFilter- variable: InstrumentedAttribute object at 0x79d927827ce0>)]
- unit: InstrumentedAttribute object at 0x79d927827d80>)]
- run: InstrumentedAttribute object at 0x79d927827b00>)]
- ixmp4.data.region.filter.filter_by_iamc(exc: Select | Update | Delete, value: dict[str, Any] | bool | None, *, schema: type[Any], repo: BaseRepository[Any]) Select | Update | Delete
- class ixmp4.data.region.filter.RegionFilter
Bases:
RegionFilter- iamc: IamcRegionFilter | bool | None, <function filter_by_iamc at 0x79d92597ed40>]
- class ixmp4.data.region.filter.FacadeIamcRegionFilter
Bases:
RegionFilter- variable: VariableFilter
- unit: UnitFilter
- run: FacadeRunFilter
- ixmp4.data.region.filter.iamc_facade_to_data_filter(filter_values: Mapping[str, Any]) IamcRegionFilter
- class ixmp4.data.region.filter.FacadeRegionFilter
Bases:
RegionFilter- iamc: FacadeIamcRegionFilter | bool | None
- ixmp4.data.region.filter.facade_to_data_filter(filter_values: Mapping[str, Any]) RegionFilter
Units (ixmp4.data.unit)
Data Transfer Object
- class ixmp4.data.unit.dto.Unit(*, created_at: datetime | None, created_by: str | None, id: int, name: str)
Bases:
BaseModel,HasCreationInfoUnit data model.
- model_config = {'from_attributes': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Service
- class ixmp4.data.unit.service.UnitService(transport: Transport)
Bases:
DocsService,GetByIdService- http_controller
alias of
EnumerationCompatibilityController
- executor: SessionExecutor
- items: ItemRepository
- pandas: PandasRepository
- versions: VersionRepository
- create(name: str) Unit
Creates a unit.
- Parameters:
name (str) – The name of the model.
- Raises:
UnitNotUnique – If the unit with name is not unique.
- Returns:
The created unit.
- Return type:
- delete_by_id(id: int) None
Deletes a unit.
- Parameters:
id (int) – The unique integer id of the unit.
- Raises:
UnitNotFound – If the unit with id does not exist.
UnitDeletionPrevented – If the unit with id is used in the database, preventing it’s deletion.
- get_by_name(name: str) Unit
Retrieves a unit by its name.
- Parameters:
name (str) – The unique name of the unit.
- Raises:
UnitNotFound – If the unit with name does not exist.
- Returns:
The retrieved unit.
- Return type:
ixmp4.data.base.iamc.Unit
- get_by_id(id: int) Unit
Retrieves a unit by its id.
- Parameters:
id (int) – The integer id of the unit.
- Raises:
ixmp4.data.abstract.Unit.NotFound – If the unit with id does not exist.
- Returns:
The retrieved unit.
- Return type:
ixmp4.data.base.iamc.Unit
- list(**kwargs: Unpack[UnitFilter]) List[Unit]
Lists units by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
UnitFilter.- Returns:
List of units.
- Return type:
list[
ixmp4.data.unit.dto.Unit]
- paginated_list(pagination: Pagination, **kwargs: Unpack[UnitFilter]) PaginatedResult[List[Unit]]
- tabulate(**kwargs: Unpack[UnitFilter]) WithJsonSchema(json_schema={'properties': {'index': {'anyOf': [{'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Index'}, 'columns': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Columns'}, 'dtypes': {'anyOf': [{'items': {'type': 'string'}, 'type': 'array'}, {'type': 'null'}], 'default': None, 'title': 'Dtypes'}, 'data': {'anyOf': [{'items': {'items': {'anyOf': [{'type': 'boolean'}, {'type': 'integer'}, {'type': 'number'}, {'type': 'string'}, {'additionalProperties': True, 'type': 'object'}, {'items': {'type': 'number'}, 'type': 'array'}, {'items': {'type': 'integer'}, 'type': 'array'}, {'items': {'type': 'string'}, 'type': 'array'}, {'format': 'date-time', 'type': 'string'}, {'type': 'null'}]}, 'type': 'array'}, 'type': 'array'}, {'type': 'null'}], 'title': 'Data'}}, 'required': ['data'], 'title': 'DataFrameTypeAdapter', 'type': 'object'}, mode=serialization)]
Tabulates units by specified criteria.
- Parameters:
**kwargs (any) – Filter parameters as specified in
UnitFilter.- Returns:
- A data frame with the columns:
id
name
- Return type:
- paginated_tabulate(pagination: Pagination, **kwargs: Unpack[UnitFilter]) PaginatedResult[Annotated[DataFrame, PlainValidator, PlainSerializer, WithJsonSchema]]
Filters
- class ixmp4.data.unit.filter.IamcUnitFilter
Bases:
UnitFilter- variable: InstrumentedAttribute object at 0x79d927827ce0>)]
- region: InstrumentedAttribute object at 0x79d927827ba0>)]
- run: InstrumentedAttribute object at 0x79d927827b00>)]
- ixmp4.data.unit.filter.filter_by_iamc(exc: Select | Update | Delete, value: dict[str, Any] | bool | None, *, schema: type[Any], repo: BaseRepository[Any]) Select | Update | Delete
- class ixmp4.data.unit.filter.UnitFilter
Bases:
UnitFilter- iamc: IamcUnitFilter | bool | None, <function filter_by_iamc at 0x79d925726980>]
- class ixmp4.data.unit.filter.FacadeIamcUnitFilter
Bases:
UnitFilter- variable: VariableFilter
- region: RegionFilter
- run: FacadeRunFilter
- ixmp4.data.unit.filter.iamc_facade_to_data_filter(filter_values: Mapping[str, Any]) IamcUnitFilter
- class ixmp4.data.unit.filter.FacadeUnitFilter
Bases:
UnitFilter- iamc: FacadeIamcUnitFilter | bool | None
- ixmp4.data.unit.filter.facade_to_data_filter(filter_values: Mapping[str, Any]) UnitFilter
Base Filters
- class ixmp4.data.filters.base.NameFilter
Bases:
TypedDict
- class ixmp4.data.filters.base.HierarchyFilter
Bases:
TypedDict
- class ixmp4.data.filters.base.ValueFilter
Bases:
TypedDict