Skip to content

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.

python
import pyhectiqlab.functional as hl
hl.create_model(name="model_name", path="path/to/model")
python
from pyhectiqlab import Model
model = Model.create(name="model_name", path="path/to/model")
bash
hectiq-lab Model.create --name "model_name" --path "path/to/model" --project hectiq-ai/demo
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

WARNING

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.

python
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")
python
from pyhectiqlab import Model
model = Model.retrieve(name="model_name", version="0.1.0")
Model.upload(id=model["id"], path="path/to/model")
bash
hectiq-lab Model.upload --id "asda2a68197ad" --path "path/to/model/files" --project hectiq-ai/demo

Retrieve a model ​

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

python
import pyhectiqlab.functional as hl
hl.retrieve_model(name="model_name", version="0.1.0")
python
from pyhectiqlab import Model
model = Model.retrieve(name="model_name", version="0.1.0")
bash
hectiq-lab Model.retrieve --name "model_name" --version "0.1.0" --project hectiq-ai/demo
NameTypeDefaultDescription
namestr-Name of the model
projectstr-Project of the model
versionstr-Version of the model
fieldsOptional[list[str]]NoneFields to retrieve

WARNING

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.

python
import pyhectiqlab.functional as hl
hl.download_model(name="model_name", version="0.1.0")
python
from pyhectiqlab import Model
model = Model.download(name="model_name", version="0.1.0")
bash
hectiq-lab Model.download --name "model_name" --version "0.1.0" --project hectiq-ai/demo
NameTypeDefaultDescription
namestr-Name of the model
projectstr-Project of the model
versionstr-Version of the model
pathOptional[str]NonePath to download the model

WARNING

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.

python
import pyhectiqlab.functional as hl
hl.delete_model(name="model_name", version="0.1.0")
python
from pyhectiqlab import Model
model = Model.delete(name="model_name", version="0.1.0")
bash
hectiq-lab Model.delete --name "model_name" --version "0.1.0" --project hectiq-ai/demo

WARNING

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.

DANGER

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

python
import pyhectiqlab.functional as hl
hl.update_model(id="12kd9x", version="0.1.0", description="New description")
python
from pyhectiqlab import Model
model = Model.update(id="12kd9x", version="0.1.0", description="New description")
bash
hectiq-lab Model.update --id "12kd9x" --version "0.1.0" --description "New description"

WARNING

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
blockOptional[str]NoneBlock of the model
wait_responseboolFalseWait for the response from the server

List models ​

You can list models using the list method.

python
import pyhectiqlab.functional as hl  
hl.list_models(project="hectiq-ai/demo")
python
from pyhectiqlab import Model
model = Model.list(project="hectiq-ai/demo")
bash
hectiq-lab Model.list --project hectiq-ai/demo
NameTypeDefaultDescription
projectstr-Project 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]]NoneFields to retrieve
pageOptional[int]NonePage number
limitOptional[int]NoneLimit of the models
order_byOptional[str]NoneOrder by
order_directionOptional[str]NoneOrder direction
wait_responsebool-Wait 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.

python
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")
python
from pyhectiqlab import Model
Model.attach(name="model-name", version="1.0.0", run_id="9c29ckw0")
Model.deattach(name="model-name", version="1.0.0", run_id="9c29ckw0")
bash
hectiq-lab Model.attach --name "model-name" --version "1.0.0" --run_id 9c29ckw0
hectiq-lab Model.deattach --name "model-name" --version "1.0.0" --run_id 9c29ckw0
NameTypeDefaultDescription
namestr-Name of the model.
versionstr-Version of the model.
run_idstrNoneID of the run. If not provided, the run will be the current run.
projectstrNoneProject of the model.
wait_responseboolFalseWait for the response from the server.

WARNING

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.

python
import pyhectiqlab.functional as hl
hl.add_tags_to_dataset(name="model-name", version="1.0.0", tags=["some", "tag"])
hl.detach_tag_from_dataset(name="model-name", version="1.0.0", tag="some")
python
from pyhectiqlab import Model
Model.add_tags(name="model-name", version="1.0.0", tags=["some", "tag"])
Model.detach_tag(name="model-name", version="1.0.0", tag="some")
bash
hectiq-lab Model.attach --name "model-name" --version "1.0.0" --tags "some" --tags "tag"
hectiq-lab Model.detach_tag --name "model-name" --version "1.0.0" --tag "some"

WARNING

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