Configuration

Module contents

Submodules

ixmp4.conf.auth module

class ixmp4.conf.auth.AnonymousAuth

Bases: BaseAuth, Auth

get_user() User
class ixmp4.conf.auth.BaseAuth

Bases: object

auth_flow(request)
get_user() User
class ixmp4.conf.auth.ManagerAuth(username: str, password: str, url: str)

Bases: BaseAuth, Auth

Uses the SceSe AAC/Management Service to obtain and refresh a token.

decode_token(token: str)
get_user() User
obtain_jwt()
refresh_jwt()
refresh_or_reobtain_jwt()
set_user(token: str)
class ixmp4.conf.auth.SelfSignedAuth(secret: str, username: str = 'ixmp4')

Bases: BaseAuth, Auth

Generates its own JWT with the supplied secret.

get_expiration_timestamp()
get_local_jwt()
get_user() User

ixmp4.conf.base module

class ixmp4.conf.base.Config(*args, **kwargs)

Bases: Protocol

get_platform(key: str) PlatformInfo
list_platforms() list[PlatformInfo]
class ixmp4.conf.base.PlatformInfo(*, name: str, dsn: str)

Bases: BaseModel

dsn: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dsn': FieldInfo(annotation=str, required=True), 'name': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

name: str

ixmp4.conf.credentials module

class ixmp4.conf.credentials.Credentials(toml_file: Path)

Bases: object

clear(key: str)
credentials: dict
dump()
get(key: str) tuple[str, str]
load()
set(key: str, username: str, password: str)

ixmp4.conf.manager module

class ixmp4.conf.manager.ManagerConfig(url: str, auth: BaseAuth, remote: bool = False)

Bases: Config

expand_dsn(dsn: str) str
fetch_group_permissions(group_id: int, platform: ManagerPlatformInfo, **kwargs) DataFrame
fetch_platforms(**kwargs) list[ManagerPlatformInfo]
fetch_user_permissions(user: User, platform: ManagerPlatformInfo, **kwargs) DataFrame
get_platform(key: str, **kwargs) ManagerPlatformInfo
list_platforms(**kwargs) list[ManagerPlatformInfo]
template_pattern = re.compile('(\\{env\\:(\\w+)\\})')
class ixmp4.conf.manager.ManagerPlatformInfo(*, slug: str, dsn: str, id: int, management_group: int, access_group: int, url: str, notice: str | None = None, accessibility: Accessibilty)

Bases: PlatformInfo

class Accessibilty(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: str, Enum

GATED = 'GATED'
PRIVATE = 'PRIVATE'
PUBLIC = 'PUBLIC'
access_group: int
accessibility: Accessibilty
id: int
management_group: int
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'access_group': FieldInfo(annotation=int, required=True), 'accessibility': FieldInfo(annotation=ManagerPlatformInfo.Accessibilty, required=True), 'dsn': FieldInfo(annotation=str, required=True), 'id': FieldInfo(annotation=int, required=True), 'management_group': FieldInfo(annotation=int, required=True), 'name': FieldInfo(annotation=str, required=True, alias='slug', alias_priority=2), 'notice': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'url': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

name: str
notice: str | None
url: str
class ixmp4.conf.manager.MockManagerConfig(platforms: list[ManagerPlatformInfo], permissions: DataFrame)

Bases: ManagerConfig

fetch_group_permissions(group_id: int, platform: ManagerPlatformInfo, **kwargs) DataFrame
fetch_platforms() list[ManagerPlatformInfo]
fetch_user_permissions(user: User, platform: ManagerPlatformInfo, **kwargs) DataFrame
class ixmp4.conf.manager.hashabledict

Bases: dict

Hashable dict type used for caching.

ixmp4.conf.toml module

class ixmp4.conf.toml.TomlConfig(toml_file: Path, user: User)

Bases: Config

add_platform(name: str, dsn: str)
dump()
get_platform(key: str) TomlPlatformInfo
list_platforms() list[TomlPlatformInfo]
load() None
platforms: dict[str, TomlPlatformInfo]
remove_platform(key: str)
class ixmp4.conf.toml.TomlPlatformInfo(*, name: str, dsn: str)

Bases: PlatformInfo

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'dsn': FieldInfo(annotation=str, required=True), 'name': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

ixmp4.conf.user module

class ixmp4.conf.user.User(*, id: int | None = None, username: str, email: str | None = None, is_staff: bool = False, is_superuser: bool = False, is_verified: bool = False, is_authenticated: bool = True, groups: list[int] = [], jti: str | None = None)

Bases: BaseModel

email: str | None
groups: list[int]
id: int | None
is_authenticated: bool
is_staff: bool
is_superuser: bool
is_verified: bool
jti: str | None
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'email': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'groups': FieldInfo(annotation=list[int], required=False, default=[]), 'id': FieldInfo(annotation=Union[int, NoneType], required=False, default=None), 'is_authenticated': FieldInfo(annotation=bool, required=False, default=True), 'is_staff': FieldInfo(annotation=bool, required=False, default=False), 'is_superuser': FieldInfo(annotation=bool, required=False, default=False), 'is_verified': FieldInfo(annotation=bool, required=False, default=False), 'jti': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'username': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

username: str