Configuration
Configure the Embedl Hub CLI and Python API.
In this guide, you will learn different ways to configure the Embedl Hub CLI and Python API. Read this if you’d like have a better understanding of the ins and outs of configuring the library or if the recommended configuration methods in the getting started guides aren’t ideal for your workflow.
Configuring an API key
The Embedl Hub Python library requires an API key for authentication. To start, create one under Personal API keys on your profile page.
Keep the key secret. Anyone with access to it will be able to read and write to your Embedl Hub projects.
You can configure the API key using the embedl-hub CLI or by storing the key
as an environment variable. A key provided as an environment variable takes
precedence over a key provided using the CLI.
Using the CLI
Run the following command to configure your key using the CLI:
embedl-hub auth --api-key <your-key>Your key will be stored in the plaintext configuration file at ~/.config/embedl-hub/config.yaml, and any existing key in the file will be
overwritten.
If you prefer, you can set your API key by manually editing the configuration file:
api_key: 'eh_...'Be sure to specify your full API key, including the eh_ prefix.
You can review the context of the configuration file with the following command:
embedl-hub showUsing an environment variable
Run the following command to configure your key using an environment variable:
export EMBEDL_HUB_API_KEY=<your-key>The API key stored in EMBEDL_HUB_API_KEY takes precedence over the key
configured using the CLI. If you originally set up your API key using an
environment variable and would now like to set up a key using the CLI, be sure
to unassign the environment variable first:
unset EMBEDL_HUB_API_KEYConfiguring project context
Using the CLI
You can configure a project using the embedl-hub CLI or by manually editing a
configuration file. This sets the default project for subsequent CLI commands.
Run the following command to configure a project using the CLI:
embedl-hub init \ --project "My Flower Detector App"You can also configure a custom artifact directory where all compile, profile, and invoke runs store their outputs:
embedl-hub init \ --artifact-dir ~/my-artifactsAlternatively, manually edit the configuration file at ~/.config/embedl-hub/config.yaml as follows:
project: 'My Flower Detector App'artifact_dir: '/home/user/my-artifacts'You can review the context of the configuration file with the following command:
embedl-hub showUsing the Python API
When using the Python API, project context is configured through HubContext:
from embedl_hub.core.context import HubContextwith HubContext( project_name="My Flower Detector App", artifact_base_dir="/path/to/artifacts",) as ctx: # All component runs within this context are tracked # under the specified project. ...The HubContext manages:
- Project name: All runs are tracked under this project on the Embedl Hub website.
- Artifact directory: Where compiled models, profiling results, and other outputs are stored locally.
- Devices: Registered devices for component dispatch.
- Tracking: Automatic logging of parameters, metrics, and artifacts.