package reference
Run
pyhectiqlab.Run
classRun(name: str, project: str, path: str = None, read_only: bool = False)
Initialize a run.
Parameters
Property | Type | Default | Description |
---|---|---|---|
name | str | - | 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. |
project | str | - | The project name. The usual format is {owner}/{project-name} . |
path | str | None | The slugified name of an existing run. Use this to attach to existing run. |
read_only | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
path | str | - | The slugified name of an existing run. Use this to attach to existing run. |
project | str | - | The project name. The usual format is {owner}/{project-name} . |
read_only | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
logger_name | str | None | If specified, the name of the log stream that will be observed. If not specified, the root logging is be observed. |
format | str | '%(asctime)s - %(levelname)s - %(message)s' | Optional log format. |
level | int | 30 | Minimum logging level. See logging levels. |
Run.remove_log_stream(logger_name: str = None)
Stop observing a specific log stream.
Parameters
Property | Type | Default | Description |
---|---|---|---|
logger_name | str | None | If 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
Property | Type | Default | Description |
---|
Run.add_tag(name: str, color: str = None)
Add a tag to the run. If the run has already this tag, do nothing.
Parameters
Property | Type | Default | Description |
---|---|---|---|
name | str | - | Tag name. |
color | str | None | Optional 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
Property | Type | Default | Description |
---|---|---|---|
packages | dict | - | A dict with keys are names of package and values are modules. We recommand using globals() that stores all the packages in memory. |
with_sys | bool | True | If True , the system state is logged (Compiler, OS, Machine, Hostname, etc.). |
with_python | bool | True | If True , the python version is logged. |
with_git | bool | True | If 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
Property | Type | Default | Description |
---|---|---|---|
package | str | - | Name of the target package. |
Run.add_config(config: Config)
Add the configuration file.
Parameters
Property | Type | Default | Description |
---|---|---|---|
config | Config | - | 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
Property | Type | Default | Description |
---|---|---|---|
key | str | - | The label of the attribute |
value | Any | - | 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
Property | Type | Default | Description |
---|---|---|---|
fig | matplotlib.figure.Figure | - | The matplotlib figure. |
name | str | - | The name of the artifact. If an extension is used, the figure format will be inferred from the extension. |
step | int | None | Optional 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_path | str | None | Use this to specify where the image will be saved. Otherwise, a temporary folder will be used. |
dpi | int | 300 | The resolution in dots per inch. |
wait_response | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
filepath | str | - | Local path to the artifact. |
name | str | None | Optional 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. |
step | int | None | Optional 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_response | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
name | str | None | Optional name you'd like to give the artifact. By default, the name of notebook is used. |
stamp | str | '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
Property | Type | Default | Description |
---|---|---|---|
key | str | - | Metric name. It can contain special characters and spaces. |
value | float | - | The metric value. |
step | float | - | The step stamp. |
Run.set_metrics_group(group: str)
Add a group to all future pushed metrics.
Parameters
Property | Type | Default | Description |
---|---|---|---|
group | str | - | 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
Property | Type | Default | Description |
---|---|---|---|
aggr | str | '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
Property | Type | Default | Description |
---|---|---|---|
name | str | - | 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
Property | Type | Default | Description |
---|---|---|---|
source_path | str | - | Path to the dataset file or directory. |
name | str | - | The dataset name. The lab will use a slugified version of the name. |
version | str | None | Version 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) |
description | str | None | An optional short description of the dataset. For larger description, push a README.md file in the root path. |
push_dir | bool | False | If the source_path is a directory, use push_dir=True to confirm that you understand that a directory will be uploaded. |
resume_upload | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
dataset_name | str | - | Name of the dataset. |
version | str | None | Specific version of the dataset. If None , the latest version is fetched. |
save_path | str | ./ | Path to where the dataset will be saved. |
overwrite | bool | False | 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
Property | Type | Default | Description |
---|---|---|---|
dirpath | str | - | Path to where the dataset is saved. |
Run.add_dataset_usage(name: str, version: str)
Attach the run to an existing dataset.
Parameters
Property | Type | Default | Description |
---|---|---|---|
name | str | - | Dataset name |
version | str | - | 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
Property | Type | Default | Description |
---|---|---|---|
source_path | str | - | Path to the mlmodel file or directory. |
name | str | - | The mlmodel name. The lab will use a slugified version of the name. |
version | str | None | Version 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) |
description | str | None | An optional short description of the mlmodel. For larger description, push a README.md file in the root path. |
push_dir | bool | False | If the source_path is a directory, use push_dir=True to confirm that you understand that a directory will be uploaded. |
resume_upload | bool | False | If 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
Property | Type | Default | Description |
---|---|---|---|
mlmodel_name | str | - | Name of the mlmodel. |
version | str | None | Specific version of the mlmodel. If None , the latest version is fetched. |
save_path | str | ./ | Path to where the mlmodel will be saved. |
overwrite | bool | False | 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
Property | Type | Default | Description |
---|---|---|---|
dirpath | str | - | Path to where the mlmodel is saved. |
Run.add_mlmodel_usage(name: str, version: str)
Attach the run to an existing mlmodel.
Parameters
Property | Type | Default | Description |
---|---|---|---|
name | str | - | MLModel name |
version | str | - | 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.