mantik.runs.local

Attributes

logger

Classes

LocalRunManager

The purpose of this class is so that the two functions inside it

LocalRunOutput

Tee

Like the tee linux command that prints to stdout

Functions

capture_and_print_output(→ Tuple[Any, str])

fetch_code_and_experiment(...)

get_env_vars_for_run(→ dict)

path_directory_of_mlproject_file(→ str)

run(data, project_id, mantik_token[, data_target_dir, ...])

save_run_data(→ uuid.UUID)

start_local_run(project_id, name, ...)

Module Contents

class mantik.runs.local.LocalRunManager[source]

The purpose of this class is so that the two functions inside it can be more easily monkey-patched together, feel free to improve this by monkeypatching the functions without the need of an extra class to clean up the code

classmethod clone_git_repo(uri: str, branch: str, target_directory: str) None[source]
static start_local_run(mlflow_experiment_id: str, data: mantik.runs.schemas.RunConfiguration, project_id: uuid.UUID, mantik_token: str, uri: str, env_manager: str = 'local') LocalRunOutput[source]
class mantik.runs.local.LocalRunOutput[source]
exception: BaseException | None = None[source]
run_id: uuid.UUID[source]
class mantik.runs.local.Tee(*streams)[source]

Bases: io.StringIO

Like the tee linux command that prints to stdout and save to a/multiple file the output of a command. This class takes n streams and populates them with the same data. A stream could be sys.stdout or sys.stderr, to keep printing to them.

Initialize self. See help(type(self)) for accurate signature.

flush()[source]

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

streams = ()[source]
write(data)[source]

Write string to file.

Returns the number of characters written, which is always equal to the length of the string.

mantik.runs.local.capture_and_print_output(func, *args, **kwargs) Tuple[Any, str][source]
mantik.runs.local.fetch_code_and_experiment(project_id: uuid.UUID, code_repository_id: uuid.UUID, experiment_repository_id: uuid.UUID, mantik_token: str) Tuple[mantik.utils.mantik_api.code_repository.CodeRepository, mantik.utils.mantik_api.experiment_repository.ExperimentRepository][source]
mantik.runs.local.get_env_vars_for_run(run_config: mantik.runs.schemas.RunConfiguration, mantik_token: str, project_id: str, data_target_dir: str | None = None) dict[source]
mantik.runs.local.logger[source]
mantik.runs.local.path_directory_of_mlproject_file(mlproject_file_path: str) str[source]
mantik.runs.local.run(data: mantik.runs.schemas.RunConfiguration, project_id: uuid.UUID, mantik_token: str, data_target_dir: str | None = None, run_manager: LocalRunManager = LocalRunManager(), env_manager: str | None = 'local')[source]
mantik.runs.local.save_run_data(data: mantik.runs.schemas.RunConfiguration, project_id: uuid.UUID, mantik_token: str) uuid.UUID[source]
mantik.runs.local.start_local_run(project_id: uuid.UUID, name: str, experiment_repository_id: uuid.UUID, code_repository_id: uuid.UUID, branch: str | None, commit: str | None, data_repository_id: uuid.UUID | None, mlflow_mlproject_file_path: str, entry_point: str, data_branch: str | None, data_commit: str | None, data_target_dir: str | None, env_manager: str | None, mlflow_parameters: dict)[source]
Parameters:
  • project_id (ID of the project to which the run should be linked)

  • name (Name of the Run)

  • experiment_repository_id (ID of the experiment repository) – to which the run should be linked

  • code_repository_id (ID of the code repository) – where the mlproject is located

  • branch (Name of the code repository's branch)

  • commit (Name of the code repository's commit (has precedence over branch))

  • data_repository_id (ID of the data repository) – where the data is located, this is optional

  • mlflow_mlproject_file_path (Path in your code directory) – to the MLproject file

  • entry_point (entry point name)

  • mlflow_parameters (Mlflow parameters present in your entry point)

  • data_branch (Data branch to checkout. Defaults to newest.)

  • data_commit (Data commit to checkout. Takes precedence over data_branch.)

  • env_manager (Which environment manager to use to handle installing run)

  • Local (dependencies. Could be)

  • Virtualenv (Conda or)

  • data_target_dir (Relative path to directory) – where the data will be stored (from code root)

Return type:

Response from the mantik API that contains the run id