Upgrade guide to version 3.0.0 ​
The release of version 3.0.0
of pyhectiqlab
package comes with many new features. In addition, we have conserved much of the old API, making the upgrade as smooth as possible. In this section, we show how to migrate your code.
Upgrading ​
To upgrade the pyhectiqlab
package, use pip
and specify the latest versions >=3.0.0
:
pip install --upgrade pyhectiqlab==3.0.0
Run ​
To create runs, you can simply replace the name
argument by title
:
from pyhectiqlab import Run
run = Run(
title="My first run",
name="My first run",
project="lab/demo",
)
from pyhectiqlab import Run
run = Run(
name="My first run",
project="lab/demo",
)
from pyhectiqlab import Run
run = Run(
title="My first run",
project="lab/demo",
)
Also, note that you can now remove the project
argument from the run creation, as it can be fixed externally using the Project
namespace or specifying using the environment variable HECTIQ_LAB_PROJECT
:
from pyhectiqlab import Project, Run
Project.set("lab/demo")
# or
os.environ["HECTIQ_LAB_PROJECT"] = "lab/demo"
run = Run(
title="My first run",
name="My first run",
project="lab/demo",
)
from pyhectiqlab import Project, Run
run = Run(
name="My first run",
project="lab/demo",
)
import os
from pyhectiqlab import Project, Run
Project.set("lab/demo")
# or
os.environ["HECTIQ_LAB_PROJECT"] = "lab/demo"
run = Run(title="My first run")
Previously, the runs were identified using a universally unique identifier (UUID) system, where the UUIDs were given by the name of the runs. We changed this system to give less importance to the name of the run, hence we now work with a simple integer rank ID system. Now, to retrieve a run, you now have to specify the rank
of the run:
from pyhectiqlab import Run
from pyhectiqlab import Project
Project.set("lab/demo")
retrieved_run = Run(
rank=14,
name="An old run",
project="lab/demo",
)
from pyhectiqlab import Run
retrieved_run = Run(
name="An old run",
project="lab/demo",
)
from pyhectiqlab import Run, Project
Project.set("lab/demo")
retrieved_run = Run(rank=14)
You can find the rank ID of a specific run on the web application.
WARNING
The Run
class is now a singleton object, hence all instances of the class share the same information at all times. As a result, you cannot initialize multiple independent runs.
Config ​
The configs have had a facelift in the last upgrade. We change the run API for retrieving configs, which now must be performed through the Run
class:
from pyhectiqlab import Run, Config
config = Config.download(run="My run", project="lab/demo")
config = Run.retrieve_config(run=14, project="lab/demo")
from pyhectiqlab import Config
config = Config.download(run="My run", project="lab/demo")
from pyhectiqlab import Run
config = Run.retrieve_config(run=14, project="lab/demo")
Managing versions ​
The version management system has been simplified to the bare minimum for you to track the git repos that are attached to your experiments. To push all the system and python related information and attach it to a given run, simply run the track_versions
.
from pyhectiqlab import Run
run = Run(
title="My run",
name="My run",
project="lab/demo"
)
run.track_version(["my_repos"])
run.add_package_repo_state("my_repos")
run.add_package_versions(globals())
from pyhectiqlab import Run
run = Run(
name="My run",
project="lab/demo"
)
run.add_package_repo_state("my_repos")
run.add_package_versions(globals())
from pyhectiqlab import Run
run = Run(
title="My run",
project="lab/demo"
)
run.track_versions(["my_repos"])
Logs and messages ​
As of yet, the logs and messages system have been removed from version 3.0.0. We recommend using standard logging
loggers. We will reimplement those features in future versions.
To track the logs of a run, use the steps system. For example:
import logging
logger = logging.getLogger()
from pyhectiqlab import Step, Run
run = Run(title="My run", project="lab/demo")
run.add_logger()
with Step(name="Step 1") as step:
logger.info("This message is logged.")
import logging
logger = logging.getLogger()
from pyhectiqlab import Step, Run
run = Run(title="My run", project="lab/demo")
run.add_logger()
import logging
logger = logging.getLogger()
from pyhectiqlab import Step, Run
run = Run(title="My run", project="lab/demo")
with Step(name="Step 1") as step:
logger.info("This message is logged.")
Models and datasets ​
We have revamped the way datasets and models are uploaded and pushed to the lab. First, you no longer have to download or upload them using runs; it can be done using the functional or object-oriented API, as shown in the tutorial, or using the command-line interface.
from pyhectiqlab import Dataset
from pyhectiqlab import Run
Dataset.create(
name="my_dataset",
version="1.0.0",
source="path/to/the/data",
upload=True
)
run = Run(name="upload of dataset", project="lab/demo")
run.add_dataset(
source_path="path/to/the/data",
name="my_dataset",
version="1.0.0",
push_dir=True
)
from pyhectiqlab import Run
run = Run(name="upload of dataset", project="lab/demo")
run.add_dataset(
source_path="path/to/the/data",
name="my_dataset",
version="1.0.0",
push_dir=True
)
from pyhectiqlab import Run
from pyhectiqlab import Dataset
Dataset.create(
name="my_dataset",
version="1.0.0",
source="path/to/the/data",
upload=True
)
hectiq-lab Dataset.create --source path/to/the/data --name my_dataset --version 1.0.0
A similar API is used for uploading models:
from pyhectiqlab import Model
from pyhectiqlab import Run
Model.create(
path="path/to/the/model/data",
name="my_model",
version="1.0.0",
)
run = Run(name="upload of model", project="lab/demo")
run.add_mlmodel(
source_path="path/to/the/model/data",
name="my_model",
version="1.0.0",
push_dir=True
)
from pyhectiqlab import Run
run = Run(name="upload of model", project="lab/demo")
run.add_mlmodel(
source_path="path/to/the/model/data",
name="my_model",
version="1.0.0",
)
from pyhectiqlab import Run
from pyhectiqlab import Model
Model.create(
path="path/to/the/model/data",
name="my_model",
version="1.0.0"
)
hectiq-lab Model.create --path path/to/the/model/data --name my_model --version 1.0.0
For downloading datasets and models, you can also use the Dataset
and Model
classes:
from pyhectiqlab import Model
from pyhectiqlab import Run
Model.download(
name="my_model",
version="1.0.0",
path="path/to/the/model/data",
)
run = Run(name="upload of model", project="lab/demo")
run.download_dataset(
name="my_model",
version="1.0.0",
save_path="path/to/the/model/data",
)
from pyhectiqlab import Run
from pyhectiqlab.mlmodels import download_mlmodel
run = Run(name="upload of model", project="lab/demo")
path = run.download_mlmodel(
name="my_model",
version="1.0.0",
save_path="path/to/the/model/data",
)
# or
download_mlmodel(
mlmodel_name="my_model",
version="1.0.0",
project_path="lab/demo",
save_path="path/to/the/model/data",
)
from pyhectiqlab import Run
from pyhectiqlab import Model
Model.download(
name="my_model",
version="1.0.0",
path="path/to/the/model/data",
)
hectiq-lab Model.download --name my_model --version 1.0.0 --path path/to/the/model/data
Artifacts ​
The artifact has not changed.
Metrics ​
The metrics have not changed.