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.
import pyhectiqlab.functional as hl
hl.add_artifact(path="path/to/file")from pyhectiqlab import Artifact
Artifact.create(path="path/to/file")run.add_artifact(path="path/to/file")hectiq-lab Run.add_artifact --run_id 9c29ckw0 --path "path/to/file" 
hectiq-lab Artifact.create --run_id 9c29ckw0 --path "path/to/file"| Name | Type | Default | Description | 
|---|---|---|---|
| path | str | - | Path to the file to upload. | 
| name | str, optional | None | Name of the artifact or the group of artifacts. If None, the name is the basename of the file. | 
| step | int, optional | None | The optional step stamp of the artifacts. If None, the artifacts is not considered as a step artifact. | 
| run_id | str, optional | None | ID of the run. If None, the current run ID is used. | 
| project | str, optional | None | The project of the artifact. If None, the current project is used. | 
| wait_response | bool | False | Set 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.
import pyhectiqlab.functional as hl
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
hl.add_figure(fig=fig)import matplotlib.pyplot as plt
fig, ax = plt.subplots()
run.add_figure(fig=fig)| Name | Type | Default | Description | 
|---|---|---|---|
| figure | matplotlib.pyplot.Figure | - | The figure to save. | 
| name | str | - | The name of the artifact. | 
| step | Optional[int] | None | The optional step stamp of the artifacts. If None, the artifacts is not considered as a step artifact. | 
| dpi | int | 200 | The dpi of the figure. | 
| extension | str | "png" | The extension of the figure. | 
| wait_response | bool | False | Set to true to upload sync. If False, the upload is made in background. | 
| run_id | Optional[str] | None | The run of the artifact. If None, the current run is used. | 
| project | Optional[str] | None | The 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.
import pyhectiqlab.functional as hl
hl.download_artifact(id="9c29ckw0")from pyhectiqlab import Artifact
artifact = Artifact.download(id="9c29ckw0")hectiq-lab Artifact.download --id 9c29ckw0| Name | Type | Default | Description | 
|---|---|---|---|
| name | str | - | Name of the artifact. | 
| savepath | str | './' | Path to save the file. | 
| block | - | None | Name 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.
import pyhectiqlab.functional as hl
hl.retrieve_artifact(id="9c29ckw0")from pyhectiqlab import Artifact
artifact = Artifact.retrieve(id="9c29ckw0")hectiq-lab Artifact.retrieve --id 9c29ckw0| Name | Type | Default | Description | 
|---|---|---|---|
| id | str | - | 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.
import pyhectiqlab.functional as hl
hl.delete_artifact(id="9c29ckw0")from pyhectiqlab import Artifact
artifact = Artifact.delete(id="9c29ckw0")hectiq-lab Artifact.delete --id 9c29ckw0| Name | Type | Default | Description | 
|---|---|---|---|
| id | str | - | ID of the artifact. | 
| wait_response | bool | False | Set 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.
import pyhectiqlab.functional as hl
hl.list_artifacts(run="9c29ckw0")from pyhectiqlab import Artifact
artifact = Artifact.list()hectiq-lab Artifact.list --run_id 9c29ckw0 --project hectiq-ai/demo| Name | Type | Default | Description | 
|---|---|---|---|
| run_id | str | - | ID of the run. | 
| project | str | - | ID of the project. | 
| fields | List[str], optional | None | List of fields to retrieve. | 
| group_by_step | bool, optional | True | Set to True to group the artifacts by step. | 
| page | int, optional | 1 | Page number. | 
| limit | int, optional | 50 | Number of artifacts to retrieve per page. | 
| order_by | str, optional | "name" | Field to order by. | 
| order_direction | str, optional | "asc" | Order direction. |