morb_fetch package

Copyright (c) 2025 MORB Developers and Contributors. All rights reserved.

morb-fetch: Data Fetcher for MORB

class morb_fetch.Settings(*args, **kwargs)

Bases: BaseSettings

Configuration settings for MORB-fetch.

serverurl

The base URL for the MORB-data server.

Type:

AnyHttpUrl

indexfile

The filename of the index file.

Type:

CSVFilename

indexfilehash

The SHA256 hash of the index file.

Type:

SHA256Hash

max_filesize

The maximum file size allowed.

Type:

Optional[HumanFileSize]

cache

The path to the cache directory.

Type:

Path

Parameters:
Return type:

Any

cache: Path
indexfile: Annotated[str]
indexfilehash: Annotated[str]
max_filesize: Optional[Annotated[str]]
mmess_path: Path
morlab_path: Path
pymor_path: Path
serverurl: AnyHttpUrl
classmethod settings_customise_sources(settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings)

Customise the settings sources and priorities to include a YAML file and environment variable.

Priority: Source file defaults < YAML File < Environment Variables

Parameters:
  • settings_cls (type[BaseSettings])

  • init_settings (PydanticBaseSettingsSource)

  • env_settings (PydanticBaseSettingsSource)

  • dotenv_settings (PydanticBaseSettingsSource)

  • file_secret_settings (PydanticBaseSettingsSource)

Return type:

tuple[PydanticBaseSettingsSource, ...]

tectonic_path: Path
morb_fetch.get_config()

Get the global configuration for package

Returns:

The global configuration settings.

Return type:

Settings

morb_fetch.clear_config()

Unset the global configuration for package

morb_fetch.print_config()

Print the current configuration.

Return type:

None

class morb_fetch.Database(config=None)

Bases: object

A class to represent the examples database. It loads the examples from a CSV file and provides a method to fetch a specific example by name and identifier.

Parameters:

config (Settings | None)

list_ids()

List all example identifiers.

Returns:

The list of example identifiers.

Return type:

list[str]

lookup(id)

Lookup an example by its identifier.

Parameters:

id (str) – The identifier of the example.

Returns:

The example data.

Return type:

dict

class morb_fetch.Example(meta, database=None)

Bases: object

A class to represent an example. It contains the metadata and the data associated with the example.

Parameters:
retrieve()

Retrieve the data associated with the example either from the local cache or from the server.

Returns:

None

class morb_fetch.ToolkitDownloader(*args, **kwargs)

Bases: BaseModel

Base Downloader class for Toolkits

Parameters:
Return type:

Any

abstractmethod classmethod list_available_versions()
Return type:

list[str]

abstractmethod classmethod retrieve_version(version)
Parameters:

version (str)

Return type:

str

name: ClassVar[str]
registry: ClassVar[dict[str, Annotated[str]]]
download_path: ClassVar[Path]
class morb_fetch.MORLABDownloader(*args, **kwargs)

Bases: ZenodoToolkitDownloader

Parameters:
Return type:

Any

download_path: ClassVar[Path]
name: ClassVar[str]
registry: ClassVar[dict[str, DOIstr]]
class morb_fetch.MMESSDownloader(*args, **kwargs)

Bases: ZenodoToolkitDownloader

Parameters:
Return type:

Any

download_path: ClassVar[Path]
name: ClassVar[str]
registry: ClassVar[dict[str, DOIstr]]
class morb_fetch.PyMORDownloader(*args, **kwargs)

Bases: ZenodoToolkitDownloader

Parameters:
Return type:

Any

download_path: ClassVar[Path]
name: ClassVar[str]
registry: ClassVar[dict[str, DOIstr]]
classmethod retrieve_version(version)

Retrieve a specific version of Toolkit

Parameters:

version (str)

Return type:

str

zenodo_filename: ClassVar[str]
class morb_fetch.ZenodoToolkitDownloader(*args, **kwargs)

Bases: ToolkitDownloader

Base Downloader class for Toolkits from Zenodo

Parameters:
Return type:

Any

classmethod list_available_versions()

List all available versions of MORLAB

Return type:

list[str]

classmethod retrieve_version(version)

Retrieve a specific version of Toolkit

Parameters:

version (str)

Return type:

str

class morb_fetch.TectonicDownloader

Bases: object

Download Tectonic binary from GitHub releases. Tectonic is a XELateX-implementation engine that can flexibly fetch related resources to compile LaTeX documents.

NOTE: Tectonic does not implement the biber engine. Check TectonicBiberDownloader to retrieve the biber engine.

REPO_URL
download_path
classmethod list_available_versions()

List all available versions of Tectonic

Return type:

list[str]

name
registry
classmethod retrieve_version(version)

Retrieve a specific version of Tectonic

Parameters:

version (str)

Return type:

str

class morb_fetch.TectonicBiberDownloader

Bases: object

Download Biber binary from SourceForge releases. Add to OS’s PATH for Tectonic to find the biber binary.

REPO_URL
download_path
classmethod list_available_versions()

List all available versions of Tectonic

Return type:

list[str]

name
registry
classmethod retrieve_version(version)
Parameters:

version (str)

Return type:

str

morb_fetch.get_database()

Get the global database instance.

Returns:

The global database instance.

Return type:

Database

morb_fetch.loadmat(filepath)

Load a MATLAB file using pymatreader.read_mat.

Parameters:

filepath (str) – The path to the MATLAB file.

Returns:

The loaded MATLAB data.

Return type:

dict

Subpackages

Submodules

morb_fetch.config module

class morb_fetch.config.Settings(*args, **kwargs)

Bases: BaseSettings

Configuration settings for MORB-fetch.

serverurl

The base URL for the MORB-data server.

Type:

AnyHttpUrl

indexfile

The filename of the index file.

Type:

CSVFilename

indexfilehash

The SHA256 hash of the index file.

Type:

SHA256Hash

max_filesize

The maximum file size allowed.

Type:

Optional[HumanFileSize]

cache

The path to the cache directory.

Type:

Path

Parameters:
Return type:

Any

serverurl: AnyHttpUrl
indexfile: Annotated[str]
indexfilehash: Annotated[str]
max_filesize: Optional[Annotated[str]]
cache: Path
pymor_path: Path
mmess_path: Path
morlab_path: Path
tectonic_path: Path
classmethod settings_customise_sources(settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings)

Customise the settings sources and priorities to include a YAML file and environment variable.

Priority: Source file defaults < YAML File < Environment Variables

Parameters:
  • settings_cls (type[BaseSettings])

  • init_settings (PydanticBaseSettingsSource)

  • env_settings (PydanticBaseSettingsSource)

  • dotenv_settings (PydanticBaseSettingsSource)

  • file_secret_settings (PydanticBaseSettingsSource)

Return type:

tuple[PydanticBaseSettingsSource, ...]

morb_fetch.config.get_config()

Get the global configuration for package

Returns:

The global configuration settings.

Return type:

Settings

morb_fetch.config.clear_config()

Unset the global configuration for package

morb_fetch.config.print_config()

Print the current configuration.

Return type:

None

morb_fetch.config.create_config(yaml_path)

Create a new configuration file at the specified path.

Parameters:

yaml_path (Path) – The path to the YAML configuration file.

morb_fetch.config.list_config()

List available configuration files in the current working directory, user configuration directory and any context included due to environment variables.

morb_fetch.config.delete_config(yaml_path)

Delete a YAML configuration file.

Parameters:

yaml_path (Path) – Path to the YAML configuration file.

morb_fetch.utils module

morb_fetch.utils.loadmat(filepath)

Load a MATLAB file using pymatreader.read_mat.

Parameters:

filepath (str) – The path to the MATLAB file.

Returns:

The loaded MATLAB data.

Return type:

dict

morb_fetch.utils.parse_human_size(s)

Parse a human-readable size string into an integer.

Parameters:

s (HumanFileSize) – The human-readable size string.

Returns:

The parsed size in bytes.

Return type:

int

Raises:

ValueError – If the size string is invalid.

morb_fetch.utils.setup_logging()
Return type:

None