Experiment#
- class mergernet.core.experiment.Experiment[source]#
Bases:
object
This class stores all relevant information for an experiment, which can be accessed from anywhere in the application as it’s an implementation of the Singleton pattern.
The experiments are tracked using two values: exp_id and run_id. The first value is a human-readable integer set by user and is related with a task specified in entrypoint file. And the second value is a auto-generated hex token used to track different re-runs of same experiment.
Attributes
Identifier of the experiment set by user.
'exp_``exp_id``'
The path in Google Drive where the artifacts of a experiment run will be uploaded to.
The path in Google Drive where the shared artifacts for all experiments are stored, e.g.
The path in local environment where artifacts (outputs of an experiment, e.g.
The path in local environment where shared files (e.g.
Notes for current run of this experiment
- class Tracker[source]#
Bases:
object
Context manager that creates an wandb project
- Parameters:
See also
mergernet.core.experiment.init_wandb
- _post_run()[source]#
Post-run tasks automatically performed when run is called, that includes:
upload registered artifacts
See also
mergernet.core.experiment.upload_registered_artifacts()
- _pre_run()[source]#
Pre-run tasks automatically performed when run is called, that includes:
clear log file
setup experiment global attributes
See also
mergernet.core.experiment._setup_experiment_attributes()
- _setup_experiment_attributes()[source]#
Configure the experiment identifiers and file system to store the files needed (e.g. dataset) and the files generated by the experiment (e.g. models, dataset, logs, predictions)
- classmethod download_file_gd(fname: str, exp_id: int | None = None, shared: bool = False)[source]#
Downloads a file from google drive inside gd_artifact_path
- classmethod init_wandb(config: dict = {}, job_type: str | None = None, name: str | None = None, tags: list = [])[source]#
Creates a wandb project
- Parameters:
See also
mergernet.core.experiment.finish_wandb()
,mergernet.core.experiment.Tracker()
- classmethod register_artifact(fname: str, service: str)[source]#
Register an artifact that will be automatically uploaded to corresponding service at the end of the experiment
- run()[source]#
Run the experiement defined in the abstract call method executing pre-run and post-run tasks
See also
mergernet.core.experiment._pre_run()
,mergernet.core.experiment._post_run()
- classmethod upload_file_gd(fname: str, data: Any | None = None)[source]#
Uploads a file to google drive inside gd_artifact_path
- Parameters:
fname (str) – The file name
data (Any, optional) – The content of the file. If not specified, this method will consider the data of the file with same name as fname inside the local_artifact_path folder. If specified, it can be a json serializable python object or the bytes of the file.
- gd_exp_path: Path = None#
The path in Google Drive where the artifacts of a experiment run will be uploaded to.
The path in Google Drive where the shared artifacts for all experiments are stored, e.g. external datasets.
- local_exp_path: Path = None#
The path in local environment where artifacts (outputs of an experiment, e.g. model predictions) are stored.
The path in local environment where shared files (e.g. dataset) are stored. This path is shared to any run of any experiemnt.