package reference

Run

pyhectiqlab.Run

classRun(name: str, project: str, path: str = None, read_only: bool = False)
Initialize a run.

Parameters

PropertyTypeDefaultDescription
namestr-Run name in a readable format. Leave empty if using path. If a run with the same slugified name exists, the existing run will be fetched and a warning will be raised.
projectstr-The project name. The usual format is {owner}/{project-name}.
pathstrNoneThe slugified name of an existing run. Use this to attach to existing run.
read_onlyboolFalseIf True, the methods will have no effect on the shared state of the run. Use this when you want to execute the code without affecting the state in the cloud. Default is False.
@classmethodRun.existing(path: str, project: str, read_only: bool = False)
Connect to an existing run using the path. The path can be found in web application.

Parameters

PropertyTypeDefaultDescription
pathstr-The slugified name of an existing run. Use this to attach to existing run.
projectstr-The project name. The usual format is {owner}/{project-name}.
read_onlyboolFalseIf True, the methods will have no effect on the shared state of the run. Use this when you want to execute the code without affecting the state in the cloud. Default is False.
Run.add_log_stream(logger_name: str = None, format: str = '%(asctime)s - %(levelname)s - %(message)s', level: int = 30)
Start observing the log stream and pushing the logs in the lab. The method outputs a logger object.

Parameters

PropertyTypeDefaultDescription
logger_namestrNoneIf specified, the name of the log stream that will be observed. If not specified, the root logging is be observed.
formatstr'%(asctime)s - %(levelname)s - %(message)s'Optional log format.
levelint30Minimum logging level. See logging levels.
Run.remove_log_stream(logger_name: str = None)
Stop observing a specific log stream.

Parameters

PropertyTypeDefaultDescription
logger_namestrNoneIf specified, the name of the log stream that will be observed. If not specified, the root stream will be remove.
Run.clear_logs()
Clear the all the log streams saved in the cloud.

Parameters

PropertyTypeDefaultDescription
Run.add_tag(name: str, color: str = None)
Add a tag to the run. If the run has already this tag, do nothing.

Parameters

PropertyTypeDefaultDescription
namestr-Tag name.
colorstrNoneOptional HEX color of the tag. If specified, we recommend using dark or bright colors, instead of light colors, because an opacity is applied in the web application. If not specified, a color will be chosen from the default set.
Run.add_package_versions(packages: dict, with_sys: bool = True, with_python: bool = True, with_git: bool = True)
Log the current states of your python packages, your system specifications, and git repo.

Parameters

PropertyTypeDefaultDescription
packagesdict-A dict with keys are names of package and values are modules. We recommand using globals() that stores all the packages in memory.
with_sysboolTrueIf True, the system state is logged (Compiler, OS, Machine, Hostname, etc.).
with_pythonboolTrue If True, the python version is logged.
with_gitboolTrueIf True and the execution script is locatted in a git repo, then the git state will be stored (hash, origin, branch).
Run.add_package_repo_state(package: str)
Log the current git state of the package at its __path__.

Parameters

PropertyTypeDefaultDescription
packagestr-Name of the target package.
Run.add_config(config: Config)
Add the configuration file.

Parameters

PropertyTypeDefaultDescription
configConfig-The target config file.
Run.add_meta(key: str, value: Any)
Attach a key/value information to the run. If the key already exists in the lab, the value is overwritten.

Parameters

PropertyTypeDefaultDescription
keystr-The label of the attribute
valueAny-Any JSON encodable attribute.
Run.add_figure(fig: matplotlib.figure.Figure, name: str, step: int = None, tmp_path: str = None, dpi: int = 300, wait_response: bool = False, **kwargs)
Add a matplotlib figure in the lab. It will save the figure in a local directory and push the file to the lab. New in v2.0.26.

Parameters

PropertyTypeDefaultDescription
figmatplotlib.figure.Figure-The matplotlib figure.
namestr-The name of the artifact. If an extension is used, the figure format will be inferred from the extension.
stepintNoneOptional step-stamp to attach to the artifact. You can use this to group a set of artifacts under the same name with different steps. A common usage is an artifact produced during a training step.
tmp_pathstrNoneUse this to specify where the image will be saved. Otherwise, a temporary folder will be used.
dpiint300The resolution in dots per inch.
wait_responseboolFalseIf True, the upload with be sync with your python process.
**kwargs-Any extra arguments passed to fig.savefig(..., **kwargs)
Run.add_artifact(filepath: str, name: str = None, step: int = None, wait_response: bool = False)
Add an artifact file to a run. If the file with

Parameters

PropertyTypeDefaultDescription
filepathstr-Local path to the artifact.
namestrNoneOptional name you'd like to give the artifact. For step artifacts, the name is an helpful way to group artifacts. By default, the basename of filepath is used as name.
stepintNoneOptional step-stamp to attach to the artifact. You can use this to group a set of artifacts under the same name with different steps. A common usage is an artifact produced during a training step.
wait_responseboolFalseIf True, the upload with be sync with your python process.
Run.add_current_notebook(name: str = None, stamp: str = 'datetime')
If the run is executed from a jupyter notebook, the current notebook is saved as an artifact. This is an experimental feature.

Parameters

PropertyTypeDefaultDescription
namestrNoneOptional name you'd like to give the artifact. By default, the name of notebook is used.
stampstr'datetime'Add a stamp on the notebook filename. For example, untitled.ipynb will become untitled_v2022-02-27T18:35:43.ipynb if datetime. One of 'datetime', 'date', None.
Run.add_metrics(key: str, value: float, step: float)
Add a metric quantity to the run.

Parameters

PropertyTypeDefaultDescription
keystr-Metric name. It can contain special characters and spaces.
valuefloat-The metric value.
stepfloat-The step stamp.
Run.set_metrics_group(group: str)
Add a group to all future pushed metrics.

Parameters

PropertyTypeDefaultDescription
groupstr-The group to append. For instance, if group='w=0.5', then metrics key will have ::w=0.5 appended to their keys. Set group to None to disable.
Run.set_metrics_aggr(aggr: str = 'none')
Set the metrics aggregation method on batched metrics.

Parameters

PropertyTypeDefaultDescription
aggrstr'none'The aggregate method. One of ['none', 'sum', 'max', 'mean'] (default is none). If 'none', all metrics are pushed to the lab. Otherwise, only the aggregated value is pushed. If you plan to exceed the maximum rate (1000 metrics/5 seconds), it is best to use an aggregation method.
Run.rename(name: str)
Change the run name.

Parameters

PropertyTypeDefaultDescription
namestr-The new name.
Run.add_dataset(source_path: str, name: str, version: str = None, description: str = None, push_dir: bool = False, resume_upload: bool = False)
Upload a dataset to the lab.

Parameters

PropertyTypeDefaultDescription
source_pathstr-Path to the dataset file or directory.
namestr-The dataset name. The lab will use a slugified version of the name.
versionstrNoneVersion in format '{major}.{minor}.{micro}' (e.g., 1.2.0). If `None`, the version 1.0.0 is assigned or an increment of minor of the latest version of the dataset with this name (e.g. 1.3.3 -> 1.4.0)
descriptionstrNoneAn optional short description of the dataset. For larger description, push a README.md file in the root path.
push_dirboolFalseIf the source_path is a directory, use push_dir=True to confirm that you understand that a directory will be uploaded.
resume_uploadboolFalseIf True, you'll be able to push files on an existing dataset version.
Run.download_dataset(dataset_name: str, version: str = None, save_path: str = ./, overwrite: bool = False)
Download an existing dataset from a run. Returns the path to the saved dataset.

Parameters

PropertyTypeDefaultDescription
dataset_namestr-Name of the dataset.
versionstrNoneSpecific version of the dataset. If None, the latest version is fetched.
save_pathstr./Path to where the dataset will be saved.
overwriteboolFalse Set to True if you want to download the dataset again even if it is already saved on your machine.
Run.add_dataset_usage_from_dirpath(dirpath: str)
Attach a run to an existing dataset saved on your machine. The name and version of the dataset is inferred from the directory.

Parameters

PropertyTypeDefaultDescription
dirpathstr-Path to where the dataset is saved.
Run.add_dataset_usage(name: str, version: str)
Attach the run to an existing dataset.

Parameters

PropertyTypeDefaultDescription
namestr-Dataset name
versionstr-Dataset version
Run.add_mlmodel(source_path: str, name: str, version: str = None, description: str = None, push_dir: bool = False, resume_upload: bool = False)
Upload a mlmodel to the lab.

Parameters

PropertyTypeDefaultDescription
source_pathstr-Path to the mlmodel file or directory.
namestr-The mlmodel name. The lab will use a slugified version of the name.
versionstrNoneVersion in format '{major}.{minor}.{micro}' (e.g., 1.2.0). If `None`, the version 1.0.0 is assigned or an increment of minor of the latest version of the mlmodel with this name (e.g. 1.3.3 -> 1.4.0)
descriptionstrNoneAn optional short description of the mlmodel. For larger description, push a README.md file in the root path.
push_dirboolFalseIf the source_path is a directory, use push_dir=True to confirm that you understand that a directory will be uploaded.
resume_uploadboolFalseIf True, you'll be able to push files on an existing mlmodel.
Run.download_mlmodel(mlmodel_name: str, version: str = None, save_path: str = ./, overwrite: bool = False)
Download an existing mlmodel from a run. Returns the path to the saved mlmodel.

Parameters

PropertyTypeDefaultDescription
mlmodel_namestr-Name of the mlmodel.
versionstrNoneSpecific version of the mlmodel. If None, the latest version is fetched.
save_pathstr./Path to where the mlmodel will be saved.
overwriteboolFalse Set to True if you want to download the mlmodel again even if it is already saved on your machine.
Run.add_mlmodel_usage_from_dirpath(dirpath: str)
Attach a run to an existing mlmodel saved on your machine. The name and version of the mlmodel is inferred from the directory.

Parameters

PropertyTypeDefaultDescription
dirpathstr-Path to where the mlmodel is saved.
Run.add_mlmodel_usage(name: str, version: str)
Attach the run to an existing mlmodel.

Parameters

PropertyTypeDefaultDescription
namestr-MLModel name
versionstr-MLModel version
Run.failed()
Set the run status to failed.
Run.completed()
Set the run status to completed.
Run.pending()
Set the run status to pending.
Run.stopped()
Set the run status to stopped.
Run.running()
Set the run status to running.
Run.training()
Set the run status to training.