qanat.core package

Submodules

qanat.core.database module

class qanat.core.database.Action(**kwargs)[source]

Bases: Base

Dataclass for actions performed on experiments.

created
description
executable
executable_command
experiment_id
id
name
updated
class qanat.core.database.Dataset(**kwargs)[source]

Bases: Base

Dataclass for eventual datasets used in the project.

created
description
id
name
path
updated
class qanat.core.database.DatasetExperiment(**kwargs)[source]

Bases: Base

Dataclass for the link between experiments and datasets.

dataset_id
experiment_id
id
class qanat.core.database.DatasetsTags(**kwargs)[source]

Bases: Base

Dataclass for the link between datasets and tags.

dataset_id
id
tag_id
class qanat.core.database.Document(**kwargs)[source]

Bases: Base

Dataclass for the documents of the project.

compile_script
compile_script_command
compiled
created
description
id
name
path
status
updated
view_script
view_script_command
class qanat.core.database.DocumentExperimentDependencies(**kwargs)[source]

Bases: Base

action_args
action_name
commit_sha
container
document_id
experiment_id
id
run_args_file
runner
runner_params
class qanat.core.database.DocumentExperimentFilesDependencies(**kwargs)[source]

Bases: Base

document_id
experiment_id
file_id
id
class qanat.core.database.DocumentsTags(**kwargs)[source]

Bases: Base

Dataclass for the link between documents and tags.

document_id
id
tag_id
class qanat.core.database.Experiment(**kwargs)[source]

Bases: Base

Dataclass for type of experiments.

created
description
executable
executable_command
id
name
path
updated
class qanat.core.database.ExperimentResultFiles(**kwargs)[source]

Bases: Base

Dataclass to track Files that are results of experiments.

experiment_id
id
path
class qanat.core.database.ExperimentsTags(**kwargs)[source]

Bases: Base

Dataclass for the link between experiments and tags.

experiment_id
id
tag_id
class qanat.core.database.GroupOfParametersOfARun(**kwargs)[source]

Bases: Base

Dataclass for groups of parameters used in the run of an experiment.

id
run_id
values
class qanat.core.database.JSONEncodedDict(*args: Any, **kwargs: Any)[source]

Bases: TypeDecorator

Represents an mutable structure as a json-encoded string.

impl

alias of String

process_bind_param(value, dialect)[source]

Serialise the value to a JSON-encoded string.

process_result_value(value, dialect)[source]

Deserialise the value from a JSON-encoded string.

class qanat.core.database.RunOfAnExperiment(**kwargs)[source]

Bases: Base

Dataclass for runs of experiments.

comment_file
commit_sha
container_path
description
experiment_id
finished
id
launched
metric
param_file
progress
runner
runner_params
status
storage_path
class qanat.core.database.RunsTags(**kwargs)[source]

Bases: Base

Dataclass for the link between runs and tags.

id
run_id
tag_id
class qanat.core.database.Tags(**kwargs)[source]

Bases: Base

Dataclass for tags for both experiments, runs and datasets.

description
id
name
qanat.core.database.add_action(session: Session, name: str, description: str, executable: str, executable_command: str, experiment_name: str) Action[source]

Add an action to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • name (str) – The name of the action.

  • description (str) – The description of the action.

  • executable (str) – The path to the executable of the action.

  • executable_command (str) – The command to run the executable.

  • experiment_name – The name of the experiment of the action.

Returns:

The action object.

Return type:

qanat.core.dataset.Action

qanat.core.database.add_dataset(session: Session, path: str, name: str, description: str, tags: list = []) Dataset[source]

Add a dataset to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • path (str) – The path to the dataset.

  • name (str) – The name of the dataset.

  • description (str) – The description of the dataset.

  • tags (list) – The tags (names) of the dataset. Default is [].

Returns:

The dataset object.

Return type:

qanat.core.dataset.Dataset

qanat.core.database.add_dependency_to_document(session: Session, document_name: str, dependency: dict) None[source]

Add a dependency to a document in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

  • dependency (dict) – The dependency to add. dict with keys ‘exepriment_name’, ‘run_args_file’, ‘files’, “runner”, “runner_params”, “container”, “commit_sha”, “action_name”, ‘action_args’

qanat.core.database.add_document(session: Session, name: str, path: str, compile_script: str, compile_script_command: str, description: str = '', view_script: str = '', view_script_command: str = '', experiment_dependencies: list = None, tags: list = None) None[source]

Add a document to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • name (str) – The name of the document.

  • path (str) – The path of the document.

  • compile_script (str) – The path of the compile script.

  • compile_script_command (str) – The command of the compile script.

  • description (str) – The description of the document.

  • view_script (str) – The path of the view script.

  • view_script_command (str) – The command of the view script.

  • experiment_dependencies (list) – The dependencies of the document. list of dict with keys ‘exepriment_name’, ‘run_args_file’, ‘files’

  • tags (list) – The tags of the document.

qanat.core.database.add_experiment(session: Session, path: str, name: str, description: str, executable: str, executable_command: str = '/usr/bin/bash', tags: list = [], datasets: list = []) Experiment[source]

Add an experiment to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • path (str) – The path to the experiment.

  • name (str) – The name of the experiment.

  • description (str) – The description of the experiment.

  • executable (str) – The path to the executable of the experiment.

  • executable_command (str.) – The progrma to use to execute executable. Default is “/usr/bin/bash”.

  • tags (list) – The tags (names) of the experiment. Default is [].

  • datasets (list) – The datasets (paths) of the experiment. Default is [].

Returns:

The experiment object.

Return type:

qanat.core.dataset.Experiment

qanat.core.database.add_run(session: Session, experiment_name: str, storage_path: str, commit_sha: str, parameters_groups: list = [], description: str = '', tags: list = [], runner: str = 'local', container_path: str = None, runner_params: dict = {}, param_file: str = None) RunOfAnExperiment[source]

Add a run to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The naf of the experiment.

  • storage_path (str) – The path to the storage of the run.

  • commit_sha (str) – The commit sha of the repo when running.

  • parameters_groups (list) – The parameters groups (as dict) of the run. Default is [].

  • description (str) – The description of the run. Default is “”.

  • tags (list) – The tags (names) of the run. Default is [].

  • runner (str) – The name of the runner. Default is ‘local’.

  • container_path (str) – The path to the container of the runner.

  • runner_params (dict) – The parameters of the runner. Default is {}.

  • param_file (str) – The path to the parameter file. Default is None.

Returns:

The run object.

Return type:

qanat.core.dataset.RunOfAnExperiment

qanat.core.database.add_tag(session: Session, name: str, description: str) Tags[source]

Add a tag to the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • name (str) – The name of the tag.

  • description (str) – The description of the tag.

Returns:

The tag object.

Return type:

qanat.core.dataset.Tags

qanat.core.database.check_document_dependency_exists(Session: Session, document_name: int, experiment_name: int, run_args_file: str) bool[source]

Check whether a document dependency exists in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

  • experiment_name (str) – The name of the experiment.

  • run_args_file (str) – The run args file.

Returns:

Whether the dependency exists or not.

Return type:

bool

qanat.core.database.check_document_exists(Session: Session, document_name: str) bool[source]

Check whether a document exists in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

Returns:

Whether the document exists or not.

Return type:

bool

qanat.core.database.count_number_runs_experiment(session: Session, experiment_name: str) int[source]

Count the number of runs of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The name of the experiment.

Returns:

The number of runs of the experiment.

Return type:

int

qanat.core.database.delete_action(session: Session, action_name: str, experiment_name) bool[source]

Delete an action from the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • action_name (str) – The name of the action.

  • experiment_name (str) – The name of the experiment.

Returns:

True if the action has been deleted, False otherwise.

Return type:

bool

qanat.core.database.delete_dataset(session: Session, dataset_name: str)[source]

Remove a dataset from the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • dataset_name (str) – The name of the dataset.

qanat.core.database.delete_document(session: Session, document_name: str)[source]

Delete a document from the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

qanat.core.database.delete_experiment(session: Session, experiment_name: str)[source]

Remove an experiment from the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name (str) – The name of the experiment.

qanat.core.database.delete_run_from_id(session: Session, run_id: int)[source]

Delete a run from the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

qanat.core.database.fetch_actions_of_experiment(Session: Session, experiment_name: str) list[source]

Fetch the actions of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The name of the experiment.

Returns:

The actions of the experiment.

Return type:

list

qanat.core.database.fetch_datasets_of_experiment(Session: Session, experiment_name: str) list[source]

Fetch the datasets of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The name of the experiment.

Returns:

The datasets of the experiment.

Return type:

list

qanat.core.database.fetch_groupofparameters_of_run(Session: Session, run_id: int) list[source]

Fetch the group of parameters of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

Returns:

The group of parameters of the run.

Return type:

list

qanat.core.database.fetch_runs_of_experiment(Session: Session, experiment_name: str) list[source]

Fetch the runs of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The name of the experiment.

Returns:

The runs of the experiment.

Return type:

list

qanat.core.database.fetch_tags_of_dataset(Session: Session, dataset_name: str) list[source]

Fetch the tags of a dataset in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • dataset_name – The name of the dataset.

Returns:

The tags of the dataset.

Return type:

list

qanat.core.database.fetch_tags_of_document(Session: Session, document_name: str) list[source]

Fetch the tags of a document in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

Returns:

The tags of the document.

Return type:

list

qanat.core.database.fetch_tags_of_experiment(Session: Session, experiment_name: str) list[source]

Fetch the tags of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name – The name of the experiment.

Returns:

The tags of the experiment.

Return type:

list

qanat.core.database.fetch_tags_of_run(Session: Session, run_id: int) list[source]

Fetch the tags of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

Returns:

The tags of the run.

Return type:

list

qanat.core.database.find_action_id(session: Session, action_name: str, experiment_name: str) int[source]

Find the id of an action in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • action_name (str) – The name of the action.

  • experiment_name (str) – The name of the experiment.

qanat.core.database.find_dataset_id(session: Session, dataset_name: str) int[source]

Find the id of a dataset in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • dataset_name – The name of the dataset.

Returns:

The id of the dataset.

Return type:

int

qanat.core.database.find_document_id(session: Session, document_name: str) int[source]

Find the id of a document in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

Returns:

The id of the document.

Return type:

int

qanat.core.database.find_experiment_id(session: Session, experiment_name: str) int[source]

Find the id of an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name (str) – The name of the experiment.

Returns:

The id of the experiment.

Return type:

int

qanat.core.database.find_tag_id(session: Session, tag_name: str) int[source]

Find the id of a tag in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • tag_name (str) – The name of the tag.

Returns:

The id of the tag.

Return type:

int

qanat.core.database.get_dependencies_info_of_document(Session: Session, document_id: int) tuple[source]

Get the infos on the dependencies to a document in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_id (int) – The id of the document.

Returns:

The info on the dependencies as lists.

Return type:

tuple

qanat.core.database.get_document_info_from_name(Session: Session, document_name: str) Tuple[Document, List[DocumentExperimentDependencies], List[DocumentExperimentFilesDependencies]][source]

Get the info of a document from its name.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

Returns:

The info of the document.

Return type:

Document

Returns:

The info of the document experiment dependencies.

Return type:

list of DocumentExperimentDependencies

Returns:

The info of the document experiment files dependencies.

Return type:

list of DocumentExperimentFilesDependencies

qanat.core.database.get_experiment_of_run(Session: Session, run_id: int) Experiment[source]

Get the experiment of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

Returns:

The experiment of the run.

Return type:

Experiment

qanat.core.database.get_files_document_experiment(Session: Session, document_id: int, experiment_id: int) list[source]

Get the files relative to a document and an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_id (int) – The id of the document.

  • experiment_id (int) – The id of the experiment.

Returns:

The files of the document and the experiment.

Return type:

list

qanat.core.database.get_last_run_id(session: Session) int[source]

Get the id of the last run in the database

Parameters:

session (sqlalchemy.orm.session.Session) – The session of the database.

Returns:

The id of the last run.

Return type:

int

qanat.core.database.init_database(path: str)[source]

Initialize a new database for qanat.

Parameters:

path (str) – The path to the database.

Returns:

The engine of the database.

Return type:

sqlalchemy.engine.base.Engine

Returns:

The base of the database.

Return type:

sqlalchemy.ext.declarative.api.DeclarativeMeta

qanat.core.database.open_database(path: str)[source]

Open an existing database for qanat.

Parameters:

path (str) – The path to the database.

Returns:

The engine of the database.

Return type:

sqlalchemy.engine.base.Engine

Returns:

The base of the database.

Return type:

sqlalchemy.ext.declarative.api.DeclarativeMeta

Returns:

The session maker of the database.

Return type:

sqlalchemy.orm.session.sessionmaker

qanat.core.database.update_document(session: Session, document_name: str, new_name: str = None, new_description: str = None, new_path: str = None, new_compile_script: str = None, new_compile_script_command: str = None, new_view_script: str = None, new_view_script_command: str = None, new_tags: list = None) None[source]

Update a document in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • document_name (str) – The name of the document.

  • new_name (str) – The new name of the document.

  • new_description (str) – The new description of the document.

  • new_path (str) – The new path of the document.

  • new_compile_script (str) – The new compile script of the

  • new_compile_script_command (str) – The new compile script command

  • new_view_script (str) – The new view script of the document.

  • new_view_script_command (str) – The new view script command of

  • new_tags (list) – The new tags of the document.

qanat.core.database.update_experiment(session: Session, experiment_name: str, new_experiment_name: str = None, new_experiment_description: str = None, new_experiment_path: str = None, new_experiment_executable: str = None, new_experiment_executable_command: str = None, new_experiment_tags: list = None, new_experiment_datasets: list = None, new_experiment_actions: list = None)[source]

Update an experiment in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • experiment_name (str) – The name of the experiment.

  • new_experiment_name (str) – The new name of the experiment.

  • new_experiment_description (str) – The new description of the experiment.

  • new_experiment_path (str) – The new path of the experiment.

  • new_experiment_executable (str) – The new executable of the experiment.

  • new_experiment_executable_command (str) – The new executable command of the experiment.

  • new_experiment_tags (list) – The new tags of the experiment.

  • new_experiment_datasets (list) – The new datasets of the experiment.

  • new_experiment_actions (list) – The new actions of the experiment.

qanat.core.database.update_run_finish_time(session: Session, run_id: int, new_finish_time: datetime = None) None[source]

Update the finish time of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

  • new_finish_time (datetime.datetime) – The new finish time of the run.

qanat.core.database.update_run_progress(session: Session, run_id: int, new_progress: float) None[source]

Update the progress of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

  • new_progress (float) – The new progress of the run.

qanat.core.database.update_run_start_time(session: Session, run_id: int, new_start_time: datetime = None) None[source]

Update the start time of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

  • new_start_time (datetime.datetime) – The new start time of the run.

qanat.core.database.update_run_status(session: Session, run_id: int, new_status: str) None[source]

Update the status of a run in the database.

Parameters:
  • session (sqlalchemy.orm.session.Session) – The session of the database.

  • run_id (int) – The id of the run.

  • new_status (str) – The new status of the run.

qanat.core.qanat module

Main module.

qanat.core.repo module

class qanat.core.repo.QanatRepertory(path)[source]

Bases: object

Class for managing the Qanat repertory.

check_exists_qanat()[source]

Check if the Qanat repertory exists.

Returns:

True if the Qanat repertory exists, False otherwise.

Return type:

bool

check_git()[source]

Check if the repertory is a git repository.

Returns:

True if the Qanat repertory is a git repository, False otherwise.

Return type:

bool

create_qanat()[source]

Create the Qanat repertory.

handle_default_editor(yes)[source]

Handle the default editor used for modifying comments/documents.

iniate_creation(yes)[source]

Initiate the creation of the Qanat repertory.

qanat.core.repo.check_directory_is_qanat(path='./')[source]

Check if directory is a Qanat repertory.

Parameters:

path (str) – The path to the directory to check.

Returns:

True if the directory is a Qanat repertory, False otherwise.

Return type:

bool

Module contents