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")
from pyhectiqlab import Model
model = Model.create(name="model_name", path="path/to/model")
hectiq-lab Model.create --name "model_name" --path "path/to/model" --project hectiq-ai/demo
Name | Type | Default | Description |
---|---|---|---|
name | str | - | Name of the model |
path | Optional[str] | None | Path to the model. If None , it creates a model without files. |
run_id | Optional[str] | None | ID of the run |
version | Optional[str] | None | Version of the model |
description | Optional[str] | None | Description of the model |
project | Optional[str] | None | Project of the model |
upload | Optional[bool] | True | Upload 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.
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")
from pyhectiqlab import Model
model = Model.retrieve(name="model_name", version="0.1.0")
Model.upload(id=model["id"], path="path/to/model")
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.
import pyhectiqlab.functional as hl
hl.retrieve_model(name="model_name", version="0.1.0")
from pyhectiqlab import Model
model = Model.retrieve(name="model_name", version="0.1.0")
hectiq-lab Model.retrieve --name "model_name" --version "0.1.0" --project hectiq-ai/demo
Name | Type | Default | Description |
---|---|---|---|
name | str | - | Name of the model |
project | str | - | Project of the model |
version | str | - | Version of the model |
fields | Optional[list[str]] | None | Fields 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.
import pyhectiqlab.functional as hl
hl.download_model(name="model_name", version="0.1.0")
from pyhectiqlab import Model
model = Model.download(name="model_name", version="0.1.0")
hectiq-lab Model.download --name "model_name" --version "0.1.0" --project hectiq-ai/demo
Name | Type | Default | Description |
---|---|---|---|
name | str | - | Name of the model |
project | str | - | Project of the model |
version | str | - | Version of the model |
path | Optional[str] | None | Path 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.
import pyhectiqlab.functional as hl
hl.delete_model(name="model_name", version="0.1.0")
from pyhectiqlab import Model
model = Model.delete(name="model_name", version="0.1.0")
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
.
Name | Type | Default | Description |
---|---|---|---|
id | str | None | ID of the model |
name | Optional[str] | None | Name of the model |
version | Optional[str] | None | Version of the model |
project | Optional[str] | None | Project of the model |
wait_response | bool | False | Wait 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.
import pyhectiqlab.functional as hl
hl.update_model(id="12kd9x", version="0.1.0", description="New description")
from pyhectiqlab import Model
model = Model.update(id="12kd9x", version="0.1.0", description="New description")
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
.
Name | Type | Default | Description |
---|---|---|---|
id | str | - | ID of the model |
name | Optional[str] | None | Name of the model |
description | Optional[str] | None | Description of the model |
version | Optional[str] | None | Version of the model |
block | Optional[str] | None | Block of the model |
wait_response | bool | False | Wait 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")
from pyhectiqlab import Model
model = Model.list(project="hectiq-ai/demo")
hectiq-lab Model.list --project hectiq-ai/demo
Name | Type | Default | Description |
---|---|---|---|
project | str | - | Project of the model |
search | Optional[str] | None | Search string |
author | Optional[str] | None | Author of the model |
keep_latest_version | bool | False | If True, group by the latest version of model name and return only the latest version of each model name |
fields | Optional[list[str]] | None | Fields to retrieve |
page | Optional[int] | None | Page number |
limit | Optional[int] | None | Limit of the models |
order_by | Optional[str] | None | Order by |
order_direction | Optional[str] | None | Order direction |
wait_response | bool | - | 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.
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")
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")
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
Name | Type | Default | Description |
---|---|---|---|
name | str | - | Name of the model. |
version | str | - | Version of the model. |
run_id | str | None | ID of the run. If not provided, the run will be the current run. |
project | str | None | Project of the model. |
wait_response | bool | False | Wait 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.
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")
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")
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
.