SDK configuration
Set up a workspace so your scripts and commands record results in the right place.
Every run you record lands in a project on a Hub. A workspace saves the Hub
and the project for a directory, so you choose them once. Every command in that directory then records there.
A Python script connects to the same Hub, and records to the same project when
it calls use_context_project().
SDK setup takes the shortest path through these settings: one workspace, the default Hub, and one project. This page covers each setting in full, including other Hubs, sharing a workspace with your team, continuing a run, and automated jobs.
The workspace#
A workspace is a directory with an .ehub/ folder, the way a git repository is
a directory with .git/. embedl-hub init creates one in the current
directory. Commands run anywhere inside that directory use the workspace’s
settings, and embedl-hub use saves settings to it.
A workspace holds two kinds of settings: one your team shares, and some that
are yours alone. The Hub is shared. It is saved in .ehub/config.yaml, so
everyone who clones the repository connects to the same Hub. The settings for a Hub behind Google Cloud IAP can be saved there too.
The project, run, and batch you are working with are yours. They are saved in .ehub/state.yaml, which the .ehub/.gitignore written by init keeps out of
git. You can therefore commit the whole .ehub/ folder with your code.
Connect to a Hub#
The SDK connects to https://hub.embedl.com unless you choose another Hub,
such as a self-hosted installation:
embedl-hub use hub https://your-hub.example.com Use the address you open in the browser. embedl-hub use clear hub removes the
Hub from the workspace, which returns to a Hub saved with --global or, without
one, to the default. See Using a self-hosted Hub for the complete
steps.
Store an API key#
embedl-hub auth --api-key - Create a key on the API keys page of your Hub and paste it
at the prompt. Entering it there, rather than on the command line, keeps it out
of your shell history. The key is stored for the Hub in use, which embedl-hub status shows.
The key is saved as plain text in your user configuration directory, whose location depends on your operating system. It is never saved in a workspace, so it is not committed, and you store it once for each Hub you use. Where a key should not be on disk, such as in CI, provide it through the environment; see Run automated jobs.
To store a key for a Hub other than the one in use, name that Hub:
embedl-hub auth --hub https://your-hub.example.com --api-key - Select a project#
embedl-hub use project quantized-classifier New runs started from this workspace are created in that project. The project itself is created with its first run if it does not exist.
A Python script names its project in code:
from embedl_hub.tracking import Client
client = Client()
client.set_project("quantized-classifier") To let the workspace decide instead, so that the same script follows embedl-hub use project, call client.use_context_project() in place of set_project. A client has no project until you call set_project or use_context_project.
Names are unique per owner, so a project shared with you can have the same name as one of yours. To start a new run in the same project as an existing run, for example its parent, take the project from that run instead of naming it:
project = client.get_run_project("PARENT_RUN_ID")
client.set_project(project)
with client.start_run("eval", parent_run_id="PARENT_RUN_ID"):
... To log to the existing run itself, select the run instead. See Select a run or batch.
Select a run or batch#
Most commands and scripts start a new run. Select a run to keep logging to it from several commands or in a later session:
embedl-hub use run RUN_ID log commands in the workspace then log to that run without --run. The
selected run can be in a different project than the selected project. Selecting
the run does not change the selected project, which is still where new runs are
created.
embedl-hub run start --use selects the run it creates, and use batch BATCH_ID selects a batch for log commands to queue into. embedl-hub use clear deselects the project, run, and
batch together; use clear run deselects only the run.
In Python, client.use_context_run() logs to the selected run. See Direct tracking.
Check what is in use#
embedl-hub status To see where your commands will record before you run them, use status. It
shows the Hub, project, run, batch, and API key in effect and where each one
comes from, without printing the key. embedl-hub use --show-origin prints the
files the workspace and global settings are stored in.
Where a setting applies#
A setting can apply at four scopes, from widest to narrowest:
- Every directory. Add
--globaltouse huboruse project, for exampleembedl-hub use project quantized-classifier --global. The global setting applies in every directory where no workspace has one saved. Runs and batches have no global setting. - One workspace.
embedl-hub usewithout--globalsaves the setting in the workspace, where it applies to what you run inside the workspace’s directory. This is the scope the sections above use. - One shell or job. Set an environment variable, such as
EMBEDL_HUB_PROJECT. - One command. Pass an option, such as
--projector--run.
When a setting is given in more than one place, the narrowest applies: an option, then an environment variable, then the workspace, then the global setting. One command or one shell can therefore record somewhere else without changing what the workspace has saved.
| Setting | Option | Environment variable | Workspace | Global |
|---|---|---|---|---|
| Hub | none | EMBEDL_HUB_URL | use hub | use hub --global |
| API key | none | EMBEDL_HUB_API_KEY | never | auth, for each Hub |
| Project | --project | EMBEDL_HUB_PROJECT | use project | use project --global |
| Run | --run | EMBEDL_HUB_RUN | use run | none |
| Batch | --batch | EMBEDL_HUB_BATCH | use batch | none |
| IAP | none | EMBEDL_HUB_IAP_* | hubs entry | hubs entry |
Run automated jobs#
A job has no one to type a key and should not depend on what happens to be saved on the runner. Give it everything through the environment, with the key injected from your secret store:
export EMBEDL_HUB_URL=https://hub.embedl.com
export EMBEDL_HUB_API_KEY=YOUR_API_KEY
export EMBEDL_HUB_PROJECT=quantized-classifier Always set the Hub together with the key. A workspace can arrive with a cloned repository, so the SDK does not send a key from the environment to a Hub that only the workspace names. Avoid placing real keys in scripts or logs.
A self-hosted Hub behind Google Cloud IAP also needs its IAP settings: two more variables, unless the job runs in a workspace that stores them. See Connect to a Hub behind Google Cloud IAP.