bartender.web.api.job.interactive_apps#
Module for running interactive applications.
Attributes#
Classes#
Represents the result of running a InteractiveApp. |
Functions#
|
Executes a shell command in the specified job directory. |
|
Builds a command string for an interactive application. |
|
Determines the encoding of a property. |
|
Extracts properties from JSON schema that store media. |
|
Stages a file to disk. |
|
Get the value at the specified path in the given dictionary. |
|
Sets the value of a path in a dictionary. |
|
Stage embedded file. |
|
Stages embedded files in the payload to disk. |
|
Runs an interactive application with the given payload and configuration. |
Module Contents#
- class bartender.web.api.job.interactive_apps.InteractiveAppResult#
Bases:
pydantic.BaseModelRepresents the result of running a InteractiveApp.
- returncode#
The return code of the InteractiveApp process.
- stderr#
The standard error output of the InteractiveApp process.
- stdout#
The standard output of the InteractiveApp process.
- async bartender.web.api.job.interactive_apps._shell(job_dir: pathlib.Path, command: str, timeout: float) InteractiveAppResult#
Executes a shell command in the specified job directory.
- Parameters:
job_dir (pathlib.Path) – The path to the job directory.
command (str) – The shell command to execute.
timeout (float) – The maximum time to wait for the command to finish. In seconds.
- Returns:
The result of running the shell command.
- Return type:
- bartender.web.api.job.interactive_apps.build_command(payload: dict[Any, Any], app: bartender.config.InteractiveApplicationConfiguration) str#
Builds a command string for an interactive application.
- Parameters:
payload (dict[Any, Any]) – A dictionary containing the input data for the application.
app (bartender.config.InteractiveApplicationConfiguration) – An object containing the configuration for the interactive application.
- Returns:
A string representing the command to be executed.
- Return type:
- bartender.web.api.job.interactive_apps.MediaEncoding#
- bartender.web.api.job.interactive_apps.encoding_of_prop(prop: dict[Any, Any]) MediaEncoding | None#
Determines the encoding of a property.
- Parameters:
prop (dict) – The property to determine the encoding of.
- Returns:
The encoding of the property, or None if it is encoded with UTF-8, or False if it has no encoding.
- Raises:
ValueError – If the encoding is not supported.
- Return type:
Union[MediaEncoding, None]
- bartender.web.api.job.interactive_apps.media_in_schema(schema: Any) dict[str, MediaEncoding]#
Extracts properties from JSON schema that store media.
See https://json-schema.org/understanding-json-schema/reference/non_json_data
- Parameters:
schema (Any) – The JSON schema to extract from.
- Returns:
A dictionary containing the property path and their encoding.
- Return type:
- async bartender.web.api.job.interactive_apps.write_file(encoded_data: str, encoding: MediaEncoding, fn: str) None#
Stages a file to disk.
- bartender.web.api.job.interactive_apps.get_path_in_payload(data: dict[Any, Any], path: str) Any | None#
Get the value at the specified path in the given dictionary.
- Parameters:
- Returns:
The value at the specified path, or None if the path does not exist.
- Return type:
Union[Any, None]
- bartender.web.api.job.interactive_apps.set_path_in_payload(data: dict[Any, Any], path: str, value: Any) None#
Sets the value of a path in a dictionary.
- async bartender.web.api.job.interactive_apps.stage_embedded_file(payload: dict[Any, Any], path: str, encoding: MediaEncoding, media_dir: str) None#
Stage embedded file.
Extracts an embedded file from the given payload, writes it to disk in the specified media directory, and updates the payload to reference the newly written file.
- async bartender.web.api.job.interactive_apps.stage_embedded_files(payload: dict[Any, Any], schema: dict[Any, Any]) AsyncGenerator[None, None]#
Stages embedded files in the payload to disk.
- async bartender.web.api.job.interactive_apps.run(job_dir: pathlib.Path, payload: dict[Any, Any], app: bartender.config.InteractiveApplicationConfiguration) InteractiveAppResult#
Runs an interactive application with the given payload and configuration.
- Parameters:
job_dir (pathlib.Path) – The directory where the input files for the application are located.
payload (dict[Any, Any]) – The payload to be used for the interactive application.
app (bartender.config.InteractiveApplicationConfiguration) – The configuration for the interactive application.
- Returns:
The result of running the interactive application.
- Return type: