Abstract Interface
Subpackages
Submodules
ixmp4.data.abstract.base module
- class ixmp4.data.abstract.base.BaseMeta(name, bases, namespace, /, **kwargs)
Bases:
_ProtocolMeta
- class ixmp4.data.abstract.base.BaseModel(*args, **kwargs)
Bases:
Protocol
- DeletionPrevented
alias of
BaseModelDeletionPrevented
- NotFound
alias of
BaseModelNotFound
- NotUnique
alias of
BaseModelNotUnique
- class ixmp4.data.abstract.base.BulkDeleter(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
- class ixmp4.data.abstract.base.BulkUpserter(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
- class ixmp4.data.abstract.base.Creator(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
- class ixmp4.data.abstract.base.Deleter(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
- class ixmp4.data.abstract.base.Lister(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
- class ixmp4.data.abstract.base.Retriever(*args: Any, **kwargs: Any)
Bases:
BaseRepository
,Protocol
ixmp4.data.abstract.meta module
- class ixmp4.data.abstract.meta.EnumerateKwargs
Bases:
HasIdFilter
,HasRunIdFilter
- run: HasRunFilter
- class ixmp4.data.abstract.meta.RunMetaEntry(*args, **kwargs)
-
Run meta entry model.
- DeletionPrevented
alias of
RunMetaEntryDeletionPrevented
- NotFound
alias of
RunMetaEntryNotFound
- NotUnique
alias of
RunMetaEntryNotUnique
- class ixmp4.data.abstract.meta.RunMetaEntryRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Retriever
,Deleter
,Enumerator
,BulkUpserter
,BulkDeleter
,Protocol
- bulk_delete(df: DataFrame) 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
- df
- bulk_upsert(df: DataFrame) None
Upserts a dataframe of run meta indicator entries.
Parameters
- df
pandas.DataFrame
- A data frame with the columns:
run__id
key
value
type
- df
- create(run__id: int, key: str, value: bool | int | float | str) RunMetaEntry
Creates a meta indicator entry for a run.
Parameters
- run__idstr
The unique integer id of a run.
- keystr
The key of the entry.
- valuestr, int, bool or float
The value of the entry.
Raises
ixmp4.core.exceptions.RunMetaEntryNotUnique
:If the entry with run__id and key is not unique.
Returns
ixmp4.data.base.RunMetaEntry
:The created entry.
- delete(id: int) None
Deletes a run’s meta indicator entry. Warning: No recovery of deleted data shall be possible via ixmp after the execution of this function.
Parameters
- idint
The unique integer ids of entries to delete.
Raises
ixmp4.data.abstract.RunMetaEntry.NotFound
:If the entry with id does not exist.
- get(run__id: int, key: str) RunMetaEntry
Retrieves a run’s meta indicator entry.
Parameters
- run__idstr
The unique integer id of a run.
- keystr
The key of the entry.
Raises
ixmp4.data.abstract.RunMetaEntry.NotFound
:If the entry with run__id and key does not exist.
Returns
ixmp4.data.base.Run
:The retrieved entry.
- list(join_run_index: bool = False, **kwargs: Unpack[EnumerateKwargs]) list[RunMetaEntry]
Lists run’s meta indicator entries by specified criteria.
Parameters
- join_run_index: bool, optional
Default False.
- **kwargs: any
Filter parameters as specified in ixmp4.data.db.meta.filter.RunMetaEntryFilter.
Returns
- Iterable[
ixmp4.data.abstract.RunMetaEntry
]: List of run meta indicator entries.
- tabulate(join_run_index: bool = False, **kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulates run’s meta indicator entries by specified criteria.
Parameters
- join_run_index: bool, optional
Default False.
- **kwargs: any
Filter parameters as specified in ixmp4.data.db.meta.filter.RunMetaEntryFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:
id
run__id
key
type
value
ixmp4.data.abstract.model module
- class ixmp4.data.abstract.model.EnumerateKwargs
Bases:
HasIdFilter
,HasNameFilter
- class ixmp4.data.abstract.model.Model(*args, **kwargs)
-
Data model of an assement modeling “model”. Unfortunately two naming conventions clash here.
- DeletionPrevented
alias of
ModelDeletionPrevented
- NotFound
alias of
ModelNotFound
- NotUnique
alias of
ModelNotUnique
- class ixmp4.data.abstract.model.ModelRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Retriever
,Enumerator
,Protocol
- create(name: str) Model
Creates a model.
Parameters
- namestr
The name of the model.
Raises
ixmp4.core.exceptions.ModelNotUnique
:If the model with name is not unique.
Returns
ixmp4.data.abstract.Model
:The created model.
- docs: DocsRepository
- get(name: str) Model
Retrieves a model.
Parameters
- namestr
The unique name of the model.
Raises
ixmp4.data.abstract.Model.NotFound
:If the model with name does not exist.
Returns
ixmp4.data.abstract.Model
:The retrieved model.
- list(**kwargs: Unpack[EnumerateKwargs]) list[Model]
Lists models by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.model.filter.ModelFilter.
Returns
- Iterable[
ixmp4.data.abstract.Model
]: List of Model.
- map(**kwargs: Unpack[EnumerateKwargs]) dict[int, str]
Return a mapping of model-id to model-name.
Returns
dict
:A dictionary id -> name
- tabulate(**kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulate models by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.model.filter.ModelFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:
id
name
ixmp4.data.abstract.region module
- class ixmp4.data.abstract.region.EnumerateKwargs
Bases:
HasHierarchyFilter
,HasIdFilter
,HasNameFilter
- class ixmp4.data.abstract.region.Region(*args, **kwargs)
-
Region data model.
- DeletionPrevented
alias of
RegionDeletionPrevented
- NotFound
alias of
RegionNotFound
- NotUnique
alias of
RegionNotUnique
- class ixmp4.data.abstract.region.RegionRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Deleter
,Retriever
,Enumerator
,Protocol
- create(name: str, hierarchy: str) Region
Creates a region.
Parameters
- namestr
The name of the region.
- hierarchystr
The hierarchy this region is assigned to.
Raises
ixmp4.data.abstract.Region.NotUnique
:If the region with name is not unique.
Returns
ixmp4.ata.base.iamc.Region
:The created region.
- delete(id: int) None
Deletes a region.
Parameters
- idint
The unique integer id of the region.
Raises
ixmp4.data.abstract.Region.NotFound
:If the region with id does not exist.
ixmp4.data.abstract.Region.DeletionPrevented
:If the region with id is used in the database, preventing it’s deletion.
- docs: DocsRepository
- get(name: str) Region
Retrieves a region.
Parameters
- namestr
The unique name of the region.
Raises
ixmp4.data.abstract.Region.NotFound
:If the region with name does not exist.
Returns
ixmp4.data.base.iamc.Region
:The retrieved region.
- list(**kwargs: Unpack[EnumerateKwargs]) list[Region]
Lists regions by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.region.filter.RegionFilter.
Returns
- Iterable[
ixmp4.data.abstract.Region
]: List of regions.
- tabulate(**kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulate regions by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.region.filter.RegionFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:
id
name
ixmp4.data.abstract.run module
- class ixmp4.data.abstract.run.EnumerateKwargs
Bases:
HasRunFilter
- class ixmp4.data.abstract.run.Run(*args, **kwargs)
-
Model run data model.
- DeletionPrevented
alias of
RunDeletionPrevented
- NoDefaultVersion
alias of
NoDefaultRunVersion
- NotFound
alias of
RunNotFound
- NotUnique
alias of
RunNotUnique
- class ixmp4.data.abstract.run.RunRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Retriever
,Enumerator
,Protocol
- 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
- model_namestr
The name of a model.
- scenario_namestr
The name of a scenario.
Returns
ixmp4.data.abstract.Run
:The created run.
- get(model_name: str, scenario_name: str, version: int) Run
Retrieves a run.
Parameters
- model_namestr
The name of a model.
- scenario_namestr
The name of a scenario.
- versionint
The version number of this run.
Raises
ixmp4.data.abstract.Run.NotFound
:If the run with model_name, scenario_name and version does not exist.
Returns
ixmp4.data.abstract.Run
:The retrieved run.
- get_default_version(model_name: str, scenario_name: str) Run
Retrieves a run’s default version.
Parameters
- model_namestr
The name of a model.
- scenario_namestr
The name of a scenario.
Raises
ixmp4.core.exceptions.NoDefaultRunVersion
:If no runs with model_name, scenario_name and is_default=True exist.
Returns
ixmp4.data.abstract.Run
:The retrieved run.
- 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
- model_namestr
The name of a model.
- scenario_namestr
The name of a scenario.
Returns
ixmp4.data.abstract.Run
:The retrieved or created run.
- list(**kwargs: Unpack[EnumerateKwargs]) list[Run]
Lists runs by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.run.filter.RunFilter.
Returns
- Iterable[
ixmp4.data.abstract.Run
]: List of runs.
- set_as_default_version(id: int) None
Sets a run as the default version for a (model, scenario) combination.
Parameters
- idint
Unique integer id.
Raises
ixmp4.data.abstract.Run.NotFound
:If no run with the id exists.
- tabulate(**kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulate runs by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.run.filter.RunFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:
id
model__id
scenario__id
- unset_as_default_version(id: int) None
Unsets a run as the default version leaving no default version for a (model, scenario) combination.
Parameters
- idint
Unique integer id.
Raises
ixmp4.data.abstract.Run.NotFound
:If no run with the id exists.
ixmp4.core.exceptions.IxmpError
:If the run is not set as a default version.
ixmp4.data.abstract.scenario module
- class ixmp4.data.abstract.scenario.EnumerateKwargs
Bases:
HasIdFilter
,HasNameFilter
- class ixmp4.data.abstract.scenario.Scenario(*args, **kwargs)
-
Modeling scenario data model.
- DeletionPrevented
alias of
ScenarioDeletionPrevented
- NotFound
alias of
ScenarioNotFound
- NotUnique
alias of
ScenarioNotUnique
- class ixmp4.data.abstract.scenario.ScenarioRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Retriever
,Enumerator
,Protocol
- create(name: str) Scenario
Creates a scenario.
Parameters
- namestr
The name of the scenario.
Raises
ixmp4.core.exceptions.ScenarioNotUnique
:If the scenario with name is not unique.
Returns
ixmp4.data.abstract.Scenario
:The created scenario.
- docs: DocsRepository
- get(name: str) Scenario
Retrieves a scenario.
Parameters
- namestr
The unique name of the scenario.
Raises
ixmp4.data.abstract.Scenario.NotFound
:If the scenario with name does not exist.
Returns
ixmp4.data.abstract.Scenario
:The retrieved scenario.
- list(**kwargs: Unpack[EnumerateKwargs]) list[Scenario]
Lists scenarios by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.scenario.filter.ScenarioFilter.
Returns
- Iterable[
ixmp4.data.abstract.Scenario
]: List of scenarios.
- map(**kwargs: Unpack[EnumerateKwargs]) dict[int, str]
Return a mapping of scenario-id to scenario-name.
Returns
dict
A dictionary id -> name
- tabulate(**kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulate scenarios by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.scenario.filter.ScenarioFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:
id
name
ixmp4.data.abstract.unit module
- class ixmp4.data.abstract.unit.EnumerateKwargs
Bases:
HasIdFilter
,HasNameFilter
- class ixmp4.data.abstract.unit.Unit(*args, **kwargs)
-
Unit data model.
- DeletionPrevented
alias of
UnitDeletionPrevented
- NotFound
alias of
UnitNotFound
- NotUnique
alias of
UnitNotUnique
- class ixmp4.data.abstract.unit.UnitRepository(*args: Any, **kwargs: Any)
Bases:
Creator
,Deleter
,Retriever
,Enumerator
,Protocol
- create(name: str) Unit
Creates a unit.
Parameters
- namestr
The name of the model.
Raises
ixmp4.core.exceptions.UnitNotUnique
:If the unit with name is not unique.
Returns
ixmp4.data.abstract.Unit
:The created unit.
- delete(id: int) None
Deletes a unit.
Parameters
- idint
The unique integer id of the unit.
Raises
ixmp4.data.abstract.Unit.NotFound
:If the unit with id does not exist.
ixmp4.data.abstract.Unit.DeletionPrevented
:If the unit with id is used in the database, preventing it’s deletion.
- docs: DocsRepository
- get(name: str) Unit
Retrieves a unit.
Parameters
- namestr
The unique name of the unit.
Raises
ixmp4.data.abstract.Unit.NotFound
:If the unit with name does not exist.
Returns
ixmp4.data.abstract.Unit
:The retrieved unit.
- get_by_id(id: int) Unit
Retrieves a Unit by it’s id.
Parameters
- idint
Unique integer id.
Raises
ixmp4.data.abstract.Unit.NotFound
.If the Unit with id does not exist.
Returns
ixmp4.data.abstract.Unit
:The retrieved Unit.
- list(**kwargs: Unpack[EnumerateKwargs]) list[Unit]
Lists units by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.unit.filter.UnitFilter.
Returns
- Iterable[
ixmp4.data.base.iamc.Unit
]: List of units.
- tabulate(**kwargs: Unpack[EnumerateKwargs]) DataFrame
Tabulate units by specified criteria.
Parameters
- **kwargs: any
Any filter parameters as specified in ixmp4.data.db.unit.filter.UnitFilter.
Returns
pandas.DataFrame
:- A data frame with the columns:pass
id
name
Module contents
This module holds a shared datastructure and interface for normalization between the database and api data models and repositories.