modos.remote#

Functions related to server storage handling

Classes#

BearerAuth

Base class that all auth implementations derive from

EndpointManager

Handle modos server endpoints.

JWT

Handles storage of JWT tokens for authentication.

Permissions

!!! abstract "Usage Documentation"

S3KeySpec

!!! abstract "Usage Documentation"

S3Key

!!! abstract "Usage Documentation"

Functions#

get_session()

list_remote_items(url)

get_metadata_from_remote(url[, modo_id])

Function to access metadata from one specific or all modos on a remote server

is_s3_path(path)

Check if a path is an S3 path

get_s3_path(url, query[, exact_match])

Request public S3 path of a specific modo or all modos matching the query string

get_cache_dir()

Module Contents#

class modos.remote.BearerAuth[source]#

Bases: requests.auth.AuthBase

Base class that all auth implementations derive from

jwt = None[source]#
__call__(r)[source]#
Parameters:

r (requests.PreparedRequest)

Return type:

requests.PreparedRequest

modos.remote.get_session()[source]#
Return type:

requests.Session

class modos.remote.EndpointManager[source]#

Handle modos server endpoints. If a modos server url is provided, it is used to detect available service urls. Alternatively, service urls can be provided explicitely if no modos server is available.

Parameters:
  • modos – URL to the modos server.

  • services – Mapping of services to their urls.

Examples

>>> ex = EndpointManager(modos="http://modos.example.org") 
>>> ex.list() 
{
  's3: 'http://s3.example.org/',
  'htsget': 'http://htsget.example.org/'
}
>>> ex.htsget 
'http://htsget.example.org'
>>> ex = EndpointManager(services={"s3": "http://s3.example.org"})
>>> ex.s3
'http://s3.example.org'
modos: pydantic.HttpUrl | None = None[source]#
services: dict[str, Any][source]#
property session[source]#
list()[source]#

List available endpoints.

Return type:

dict[str, Any]

property auth: dict[str, str | pydantic.HttpUrl] | None[source]#
Return type:

dict[str, str | pydantic.HttpUrl] | None

property kms: pydantic.HttpUrl | None[source]#
Return type:

pydantic.HttpUrl | None

property s3: pydantic.HttpUrl | None[source]#
Return type:

pydantic.HttpUrl | None

property fuzon: pydantic.HttpUrl | None[source]#
Return type:

pydantic.HttpUrl | None

property htsget: pydantic.HttpUrl | None[source]#
Return type:

pydantic.HttpUrl | None

property refget: pydantic.HttpUrl | None[source]#
Return type:

pydantic.HttpUrl | None

modos.remote.list_remote_items(url)[source]#
Parameters:

url (pydantic.HttpUrl)

Return type:

list[pydantic.HttpUrl]

modos.remote.get_metadata_from_remote(url, modo_id=None)[source]#

Function to access metadata from one specific or all modos on a remote server

Parameters:
  • server_url – Url to the remote modo server

  • id – id of the modo to retrieve metadata from. Will return all if not specified (default).

  • url (pydantic.HttpUrl)

  • modo_id (str | None)

Return type:

dict[str, Any]

modos.remote.is_s3_path(path)[source]#

Check if a path is an S3 path

Parameters:

path (str)

modos.remote.get_s3_path(url, query, exact_match=False)[source]#

Request public S3 path of a specific modo or all modos matching the query string :param remote_url: Url to the remote modo server :param query: query string to specify the modo of interest :param exact_match: if True only modos with exactly that id will be returned, otherwise (default) all matching modos

Parameters:
  • url (pydantic.HttpUrl)

  • query (str)

  • exact_match (bool)

Return type:

dict[str, Any]

modos.remote.get_cache_dir()[source]#
Return type:

pathlib.Path

class modos.remote.JWT[source]#

Handles storage of JWT tokens for authentication.

Examples

>>> token = JWT(access_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MzI5MjU2MDB9.DummySignature")
>>> token.is_expired
True
>>> token.to_cache()
>>> loaded_jwt = JWT.from_cache()
>>> loaded_jwt.access_token == token.access_token
True
access_token: str[source]#
_expires_at: datetime.datetime | None = None[source]#
property expires_at[source]#
static get_cache_path()[source]#
Return type:

pathlib.Path

to_cache()[source]#

Store JWT in cache directory.

classmethod from_cache()[source]#

Load JWT from cache directory if it exists.

Return type:

JWT | None

property is_expired: bool[source]#
Parameters:

skew (int)

Return type:

bool

refresh()[source]#
Return type:

JWT | None

class modos.remote.Permissions(/, **data)[source]#

Bases: pydantic.BaseModel

!!! abstract “Usage Documentation”

[Models](../concepts/models.md)

A base class for creating Pydantic models.

Parameters:

data (Any)

__class_vars__[source]#

The names of the class variables defined on the model.

__private_attributes__[source]#

Metadata about the private attributes of the model.

__signature__[source]#

The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__[source]#

Whether model building is completed, or if there are still undefined fields.

__pydantic_core_schema__[source]#

The core schema of the model.

__pydantic_custom_init__[source]#

Whether the model has a custom __init__ function.

__pydantic_decorators__[source]#

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_generic_metadata__[source]#

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__[source]#

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__[source]#

The name of the post-init method for the model, if defined.

__pydantic_root_model__[source]#

Whether the model is a [RootModel][pydantic.root_model.RootModel].

__pydantic_serializer__[source]#

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_validator__[source]#

The pydantic-core SchemaValidator used to validate instances of the model.

__pydantic_fields__[source]#

A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.

__pydantic_computed_fields__[source]#

A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_extra__[source]#

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_fields_set__[source]#

The names of fields explicitly set during instantiation.

__pydantic_private__[source]#

Values of private attributes set on the model instance.

read: bool[source]#
write: bool[source]#
owner: bool[source]#
classmethod default()[source]#
Return type:

Self

__str__()[source]#
class modos.remote.S3KeySpec(/, **data)[source]#

Bases: pydantic.BaseModel

!!! abstract “Usage Documentation”

[Models](../concepts/models.md)

A base class for creating Pydantic models.

Parameters:

data (Any)

__class_vars__[source]#

The names of the class variables defined on the model.

__private_attributes__[source]#

Metadata about the private attributes of the model.

__signature__[source]#

The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__[source]#

Whether model building is completed, or if there are still undefined fields.

__pydantic_core_schema__[source]#

The core schema of the model.

__pydantic_custom_init__[source]#

Whether the model has a custom __init__ function.

__pydantic_decorators__[source]#

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_generic_metadata__[source]#

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__[source]#

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__[source]#

The name of the post-init method for the model, if defined.

__pydantic_root_model__[source]#

Whether the model is a [RootModel][pydantic.root_model.RootModel].

__pydantic_serializer__[source]#

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_validator__[source]#

The pydantic-core SchemaValidator used to validate instances of the model.

__pydantic_fields__[source]#

A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.

__pydantic_computed_fields__[source]#

A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_extra__[source]#

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_fields_set__[source]#

The names of fields explicitly set during instantiation.

__pydantic_private__[source]#

Values of private attributes set on the model instance.

bucket: str[source]#
expiration: datetime.datetime[source]#
prefixes: list[str] | None[source]#
permissions: Permissions[source]#
name: str | None = None[source]#
class modos.remote.S3Key(/, **data)[source]#

Bases: pydantic.BaseModel

!!! abstract “Usage Documentation”

[Models](../concepts/models.md)

A base class for creating Pydantic models.

Parameters:

data (Any)

__class_vars__[source]#

The names of the class variables defined on the model.

__private_attributes__[source]#

Metadata about the private attributes of the model.

__signature__[source]#

The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__[source]#

Whether model building is completed, or if there are still undefined fields.

__pydantic_core_schema__[source]#

The core schema of the model.

__pydantic_custom_init__[source]#

Whether the model has a custom __init__ function.

__pydantic_decorators__[source]#

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_generic_metadata__[source]#

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__[source]#

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__[source]#

The name of the post-init method for the model, if defined.

__pydantic_root_model__[source]#

Whether the model is a [RootModel][pydantic.root_model.RootModel].

__pydantic_serializer__[source]#

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_validator__[source]#

The pydantic-core SchemaValidator used to validate instances of the model.

__pydantic_fields__[source]#

A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.

__pydantic_computed_fields__[source]#

A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_extra__[source]#

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_fields_set__[source]#

The names of fields explicitly set during instantiation.

__pydantic_private__[source]#

Values of private attributes set on the model instance.

spec: S3KeySpec[source]#
access_key_id: str[source]#
secret_access_key: str | None[source]#
valid_paths()[source]#

Prints the valid S3 paths for this key.

Return type:

str