runs

Artifacts

Artifacts are any files that you attach to runs. It is common to use artifacts to store images, plots, and notebooks.

If you want to log models or datasets, it is suggested to use their designated methods to make them more freely available.

Upload

You can push artifacts using run.add_artifact like so:

filepath = "./path/to/file/cat.png"
run.add_artifact(filepath)

The file will be uploaded on a separate thread to the lab. This method lets you add a custom name and a step-stamp. The argument step lets you group artifacts with the same name and organize them by steps. This feature is specially useful when creating some artifacts during a training session. For instance, generating examples for GAN models or plotting a certain distribution. It lets you follow the progression of your artifacts. Below is an example usage,

filepath = model.generate_image()
run.add_artifact(filepath, name="cat-example", step=1)

model.training_step()
filepath = model.generate_image()
run.add_artifact(filepath, name="cat-example", step=2)

Figures

Since v2.0.26, you can push an existing figure in the lab with:

fig = plt.figure()
run.add_figure(fig, name="My figure")

The figure will be saved in a temporary directory and the file is pushed to the lab.

Notebooks

Experimental feature. If you are executing your run from a jupyter notebook, you can save the active notebook as an artifact of the run with:

# untitle.ipynb
run.add_current_notebook()

Download

Once an artifact is uploaded, an unique id is given. You can download the artifact if you have this id. The id is available in the Artifact page of the run.

from pyhectiqlab.utils import download_existing_run_artifact
download_existing_run_artifact(artifact_uuid="XXXXX-XXXXXX-XXXX-XXX")

Troubleshooting

Name collision

When two or more artifacts without step-stamps in the same run are uploaded with the same name, the lab will keep the latest upload and discard previous uploads. In the future, we plan to version artifacts. If artifacts are uploaded with the step parameters, the lab will keep and display all uploads.

Methods

pyhectiqlab.Run

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_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_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.