bartender.config#

Parses config file as list of applications, schedulers and filesystems.

Attributes#

Classes#

ApplicatonConfiguration

Configuration for an application.

InteractiveApplicationConfiguration

Configuration for an interactive application.

Config

Bartender configuration.

Functions#

build_config(→ Config)

Build a config instance from a yaml formatted file.

_load(→ Any)

get_config(→ Config)

Get config based on current request.

Module Contents#

class bartender.config.ApplicatonConfiguration#

Bases: pydantic.BaseModel

Configuration for an application.

command_template#

Shell command template to run in job directory. Use Jinja2 template syntax to substitute variables from request body.

input_schema#

JSON schema of request body. Dialect of JSON Schema should be draft 2020-12. Root should be an object.

summary#

The summary of the application, if any.

description#

The description of the application, if any.

upload_needs#

A list of file names that should exist in the uploaded archive file during submission. If empty then no files are required to be present in the archive.

allowed_roles#

A list of roles that are allowed to submit jobs. If empty then anyone can submit jobs.

check_input_schema(v) dict#

Validate the input schema.

Parameters:

v (Union[dict[Any, Any], None]) –

Return type:

Union[dict[Any, Any], None]

check_command_template(v) str#

Validate the command template.

Parameters:

v (str) –

Return type:

str

command_template: str#
input_schema: dict[Any, Any] | None = None#
summary: str | None = None#
description: str | None = None#
upload_needs: list[str] = []#
allowed_roles: list[str] = []#
check_input_schema(v: dict[Any, Any] | None) dict[Any, Any] | None#

Validate input schema.

Parameters:

v (Union[dict[Any, Any], None]) – The unvalidated input schema.

Raises:

ValueError – When input schema is invalid.

Returns:

The validated input schema.

Return type:

Union[dict[Any, Any], None]

check_command_template(v: str) str#

Validate command template.

Raises TemplateSyntaxError when command template is invalid.

Parameters:

v (str) – The unvalidated command template.

Returns:

The validated command template.

Return type:

str

bartender.config.ApplicatonConfigurations#
class bartender.config.InteractiveApplicationConfiguration#

Bases: pydantic.BaseModel

Configuration for an interactive application.

Example

Given completed job 1 run interactive app rescore with:

response = client.post('/api/job/1/interactiveapp/rescore', json={
    'capri_dir': 'output/06_caprieval',
    'w_elec': 0.2,
    'w_vdw': 0.2,
    'w_desolv': 0.2,
    'w_bsa': 0.1,
    'w_air': 0.3,
})
if response.json()['returncode'] == 0:
    # Find the results in the job directory somewhere
    path = '/api/job/1/files/output/06_caprieval_interactive/capri_clt.tsv'
    files = client.get(path)
command_template#

Shell command template to run in job directory. Use Jinja2 template syntax to substitute variables from request body.

input_schema#

JSON schema of request body. Dialect of JSON Schema should be draft 2020-12. Root should be an object.

summary#

Summary of the interactive app.

description#

Description of the interactive app.

timeout#

Maximum time in seconds to wait for command to finish.

job_application#

Name of the application that generated the job. If not set, the interactive app can be run on any job. If set, the interactive app can only be run on jobs that were submitted for that given application.

command_template: str#
input_schema: dict[Any, Any]#
summary: str | None = None#
description: str | None = None#
timeout: confloat(gt=0, le=60) = 30.0#
job_application: str | None = None#
check_input_schema(v: dict[Any, Any]) dict[Any, Any]#

Validate input schema.

Parameters:

v (dict[Any, Any]) – The unvalidated input schema.

Raises:

ValueError – When input schema is invalid.

Returns:

The validated input schema.

Return type:

dict[Any, Any]

check_command_template(v: str) str#

Validate command template.

Raises TemplateSyntaxError when command template is invalid.

Parameters:

v (str) – The unvalidated command template.

Returns:

The validated command template.

Return type:

str

bartender.config.InteractiveApplicationConfigurations#
class bartender.config.Config#

Bases: pydantic.BaseModel

Bartender configuration.

The bartender.settings.Settings class is for FastAPI settings. The bartender.config.Config class is for non-FastAPI configuration.

If config is empty will create a single slot in memory scheduler with a local file system.

applications: ApplicatonConfigurations#
destinations: dict[str, bartender.destinations.DestinationConfig]#
job_root_dir: pydantic.types.DirectoryPath#
destination_picker: str = 'bartender.picker:pick_first'#
interactive_applications: InteractiveApplicationConfigurations#
class Config#
validate_all = True#
validate_job_root_dir(v: pydantic.types.DirectoryPath) pydantic.types.DirectoryPath#

Resolves the job root directory path to an absolute path.

Parameters:

v (pydantic.types.DirectoryPath) – The directory path to validate.

Returns:

The resolved directory path.

Return type:

pydantic.types.DirectoryPath

applications_non_empty(v: ApplicatonConfigurations) ApplicatonConfigurations#

Validates that applications dict is filled.

Parameters:

v (ApplicatonConfigurations) – The given dict.

Raises:

ValueError – When dict is empty.

Returns:

The given dict.

Return type:

ApplicatonConfigurations

check_job_application(values: dict[str, Any]) dict[str, Any]#

Check that all interactive applications have a valid job_application.

Parameters:

values (dict[str, Any]) – The configuration values to check.

Returns:

The original configuration values.

Raises:

AssertionError – If an interactive application has an invalid job_application.

Return type:

dict[str, Any]

bartender.config.build_config(config_filename: pathlib.Path) Config#

Build a config instance from a yaml formatted file.

Parameters:

config_filename (pathlib.Path) – File name of configuration file.

Returns:

A config instance.

Return type:

Config

bartender.config._load(config_filename: pathlib.Path) Any#
Parameters:

config_filename (pathlib.Path) –

Return type:

Any

bartender.config.get_config(request: fastapi.Request) Config#

Get config based on current request.

Parameters:

request (fastapi.Request) – The current FastAPI request.

Returns:

The config.

Return type:

Config

bartender.config.CurrentConfig#