Skip to content

Artifacts ​

Artifacts are any files than should be kept during a machine learning experiment. Usually, this includes figures, images and dataframe. Models and dataset have a specific repertoire in Hectiq Lab, but you can add any file you want to the artifacts.

In the object-oriented approach, artifacts are accessible using run methods (Run.add_artifact) and artifacts methods (Artifact.create). These approaches are equivalent and you can use the one you prefer.

Add an artifact ​

Any file ​

You can add an artifact to the run using the add_artifact method. Artifact is a file that you want to store in the run.

python
import pyhectiqlab.functional as hl
hl.add_artifact(path="path/to/file")
python
from pyhectiqlab import Artifact
Artifact.create(path="path/to/file")
python
run.add_artifact(path="path/to/file")
bash
hectiq-lab Run.add_artifact --run_id 9c29ckw0 --path "path/to/file" 
hectiq-lab Artifact.create --run_id 9c29ckw0 --path "path/to/file"
NameTypeDefaultDescription
pathstr-Path to the file to upload.
namestr, optionalNoneName of the artifact or the group of artifacts. If None, the name is the basename of the file.
stepint, optionalNoneThe optional step stamp of the artifacts. If None, the artifacts is not considered as a step artifact.
run_idstr, optionalNoneID of the run. If None, the current run ID is used.
projectstr, optionalNoneThe project of the artifact. If None, the current project is used.
wait_responseboolFalseSet to true to upload sync. If False, the upload is made in background.

Matplotlib figure ​

For matplotlib, you can use the add_figure method to add a figure to the run. The figure will be saved to png and stored as an artifact. This method is only availabe from the functional and run object-oriented approach.

python
import pyhectiqlab.functional as hl
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
hl.add_figure(fig=fig)
python
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
run.add_figure(fig=fig)
NameTypeDefaultDescription
figurematplotlib.pyplot.Figure-The figure to save.
namestr-The name of the artifact.
stepOptional[int]NoneThe optional step stamp of the artifacts. If None, the artifacts is not considered as a step artifact.
dpiint200The dpi of the figure.
extensionstr"png"The extension of the figure.
wait_responseboolFalseSet to true to upload sync. If False, the upload is made in background.
run_idOptional[str]NoneThe run of the artifact. If None, the current run is used.
projectOptional[str]NoneThe project of the artifact. If None, the current project is used.

Download an artifact ​

You can download an artifact using the download method. This method is only available from the functional and artifact object-oriented approach.

The download uses tqdm to display the progress of the download.

python
import pyhectiqlab.functional as hl
hl.download_artifact(id="9c29ckw0")
python
from pyhectiqlab import Artifact
artifact = Artifact.download(id="9c29ckw0")
bash
hectiq-lab Artifact.download --id 9c29ckw0
NameTypeDefaultDescription
namestr-Name of the artifact.
savepathstr'./'Path to save the file.
block-NoneName of the block. If None, the block is determined from the context.

Retrieve informations on artifact ​

You can retrieve informations on an artifact using the retrieve method. This method is only available from the functional and artifact object-oriented approach.

python
import pyhectiqlab.functional as hl
hl.retrieve_artifact(id="9c29ckw0")
python
from pyhectiqlab import Artifact
artifact = Artifact.retrieve(id="9c29ckw0")
bash
hectiq-lab Artifact.retrieve --id 9c29ckw0
NameTypeDefaultDescription
idstr-ID of the artifact.

Delete an artifact ​

You can delete an artifact using the delete method. This method is only available from the functional and artifact object-oriented approach.

python
import pyhectiqlab.functional as hl
hl.delete_artifact(id="9c29ckw0")
python
from pyhectiqlab import Artifact
artifact = Artifact.delete(id="9c29ckw0")
bash
hectiq-lab Artifact.delete --id 9c29ckw0
NameTypeDefaultDescription
idstr-ID of the artifact.
wait_responseboolFalseSet to true to delete sync. If False, the deletion is made in background.

List artifacts ​

You can list artifacts using the list method. This method is only available from the functional and artifact object-oriented approach.

python
import pyhectiqlab.functional as hl
hl.list_artifacts(run="9c29ckw0")
python
from pyhectiqlab import Artifact
artifact = Artifact.list()
bash
hectiq-lab Artifact.list --run_id 9c29ckw0 --project hectiq-ai/demo
NameTypeDefaultDescription
run_idstr-ID of the run.
projectstr-ID of the project.
fieldsList[str], optionalNoneList of fields to retrieve.
group_by_stepbool, optionalTrueSet to True to group the artifacts by step.
pageint, optional1Page number.
limitint, optional50Number of artifacts to retrieve per page.
order_bystr, optional"name"Field to order by.
order_directionstr, optional"asc"Order direction.