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