Hectiq Lab

Models

Models are the main output of a machine learning experiment. In Hectiq Lab, models are stored in a specific directory and can be accessed using the Model object.

Create a model

You can create a model using the create method. This method is available from the functional and model object-oriented approach.

import pyhectiqlab.functional as hl
hl.create_model(name="model_name", path="path/to/model")
NameTypeDefaultDescription
namestr-Name of the model
pathOptional[str]NonePath to the model. If None, it creates a model without files.
run_idOptional[str]NoneID of the run
versionOptional[str]NoneVersion of the model
descriptionOptional[str]NoneDescription of the model
projectOptional[str]NoneProject of the model
uploadOptional[bool]TrueUpload the model to the server

If the name parameter is not provided, the project or the model is not found, it logs an error and returns None.

Upload files to a model

You can upload files to a model using the upload method. This method is available from the functional and model object-oriented approach. You'll need the model id to upload the files. The model id can be retrieved using the retrieve method or is provided in the web application. The id is unique for a specific model name and version.

import pyhectiqlab.functional as hl
model = hl.retrieve_model(name="model_name", version="0.1.0")
hl.upload_model(id=model["id"], path="path/to/model")

Retrieve a model

You can retrieve a model by its name and version using the retrieve method.

import pyhectiqlab.functional as hl
hl.retrieve_model(name="model_name", version="0.1.0")
NameTypeDefaultDescription
namestr-Name of the model
projectOptional[str]NoneProject of the model
versionstr-Version of the model
fieldsOptional[list[str]]NoneFields to retrieve

If the project is not found, it logs an error and returns None.

Download a model locally

You can download a model by its name and version using the download method.

import pyhectiqlab.functional as hl
hl.download_model(name="model_name", version="0.1.0")
NameTypeDefaultDescription
namestr-Name of the model
projectOptional[str]NoneProject of the model
versionstr-Version of the model
pathOptional[str]NonePath to download the model
overwriteboolFalseWhether to overwrite the existing files.

If the project or the model is not found, it logs an error and returns None.

Delete a model

You can delete a model by its name, version and project using the delete method, or by its id. Depending on the argument you provide, the method will delete the model by its id or by its name and version.

import pyhectiqlab.functional as hl
hl.delete_model(name="model_name", version="0.1.0")

If the id parameter, or the name, version and project are not provided, it logs an error and returns None.

NameTypeDefaultDescription
idstrNoneID of the model
nameOptional[str]NoneName of the model
versionOptional[str]NoneVersion of the model
projectOptional[str]NoneProject of the model
wait_responseboolFalseWait for the response from the server

Update a model

You can update the metadata of a model using the update method. For updating the files of a model, you can use the upload method.

The name and version of a model can be updated. The update uses the id to find the model to update.

import pyhectiqlab.functional as hl
hl.update_model(id="12kd9x", version="0.1.0", description="New description")

If the id parameter is not provided, it logs an error and returns None.

NameTypeDefaultDescription
idstr-ID of the model
nameOptional[str]NoneName of the model
descriptionOptional[str]NoneDescription of the model
versionOptional[str]NoneVersion of the model
wait_responseboolFalseWait for the response from the server

List models

You can list models using the list method.

import pyhectiqlab.functional as hl  
hl.list_models(project="hectiq-ai/demo")
NameTypeDefaultDescription
projectOptional[str]NoneProject of the model
searchOptional[str]NoneSearch string
authorOptional[str]NoneAuthor of the model
keep_latest_versionboolFalseIf True, group by the latest version of model name and return only the latest version of each model name
fieldsOptional[list[str]][]Fields to retrieve
pageOptional[int]1Page number
limitOptional[int]100Limit of the models
order_byOptional[str]"created_at"Order by
order_directionOptional[str]"desc"Order direction
wait_responseboolFalseWait for the response from the server

Attach / Detach models to a run

A model can be attached or detached from a run. To do so, use the attach and detach method.

import pyhectiqlab.functional as hl
hl.attach_model(name="model-name", version="1.0.0", run_id="9c29ckw0")
hl.detach_model(name="model-name", version="1.0.0", run_id="9c29ckw0")
NameTypeDefaultDescription
namestr-Name of the model.
versionstr-Version of the model.
run_idstr-ID of the run.
projectstrNoneProject of the model.
wait_responseboolFalseWait for the response from the server.

If the run_id parameter is not provided or the model is not found, it logs an error and returns None.

Attach / detach tags to the models

Like for runs, tags can be attached / detached to models by using the add_tags and detach_tag method.

import pyhectiqlab.functional as hl
hl.add_tags_to_model(name="model-name", version="1.0.0", tags=["some", "tag"])
hl.detach_tag_from_model(tag="some", model_id="model-id", project="hectiq-ai/demo")

If the model is not found, it logs an error and returns None.

On this page