CLI commands for training
akka is the command-line interface for Akka Optimize. Use akka commands to operate the trainer. The trainer pages use these commands to explain each operation.
akka is a command group of the akka CLI. To install the akka CLI, see Install the Akka CLI.
Connect to a trainer
The AKKA_OPTIMIZE_URL environment variable specifies the address of your Akka project’s route. akka uses this address to reach the trainer, the artifact registry, and the other services. Set it once for a deployed project. akka route get <route> shows the route’s hostname.
Set the address and confirm that the trainer responds:
export AKKA_OPTIMIZE_URL=https://optimize.example.akka.services
akka status
To reach one service at another address, set that service’s own variable, such as TRAINER_URL or REGISTRY_URL. A service’s own variable takes precedence over AKKA_OPTIMIZE_URL for that service only. The --trainer-url flag on any command takes precedence over both for the trainer. To use the route for every service, unset them:
unset TRAINER_URL REGISTRY_URL
status lists each service that the CLI contacts, whether the service responds, and the address that the CLI used. This section requires only the trainer and the registry. A service your project’s route does not map appears with an error at the route’s address. training info reports the trainer’s backend. It exits with a non-zero status when the service does not respond or has not finished starting, so a script can use it to wait for the trainer.
A 503 response from the trainer’s address can mean that the service is restarting after a deployment. Retry the request after a minute.
The artifact registry holds datasets and scoring bundles. akka reaches the registry at AKKA_OPTIMIZE_URL too, or at REGISTRY_URL where you set it.
Authenticate
akka uses the login of the akka CLI. After you run akka auth login, akka gets the refresh token from the current akka context. On the first request that requires authentication, it exchanges the refresh token for an access token. You do not need any other workstation configuration.
To use the login of a different akka context, name that context with the --context flag or the AKKA_CONTEXT environment variable. The flag takes precedence over the variable. akka exchanges the token at the API host that the named context specifies, so one shell can reach a service on a different platform from the current context. If the configuration file has no context with that name, or the named context holds no login, akka refuses the command and lists the contexts that the file contains.
export AKKA_CONTEXT=staging
akka training runs list
For a job that must use different credentials from the user who is signed in, set one of the following environment variables. akka uses the first variable that is set:
| Variable | Description |
|---|---|
|
An access token, used as it is. |
|
A refresh token. |
|
An OAuth token. Requires |
|
A file that holds an OAuth token. |
A denied request returns 403. The response identifies the refused action, such as optimize.training.runs.create.
Conventions
- Output
-
-o textis the default and displays a table or a block of fields.-o wideadds detail where a command has more to show, such as the settings intraining runs get, and is the same as text elsewhere.-o jsonand-o json-compactreturn a document that a script can read. Results go to stdout, and notes go to stderr, so-o json > FILEwrites only the document.--jq EXPRESSIONfilters JSON output, and--json FIELDSselects fields.--json=lists the fields that a command offers. - Writes
-
A write prints one sentence that says what happened and where to look. The full object is available with
-o json. - Confirmation
-
A command that provisions compute or discards work prompts for confirmation.
--forceskips the prompt. When stdin is not a terminal, the command refuses to continue without confirmation. Pass--forcein a script.--disable-prompt, orAKKA_DISABLE_PROMPTS=true, accepts every prompt. - Waiting
-
A command that starts a run, a pipeline or an evaluation returns when the trainer accepts the work.
--waitfollows it to a terminal phase, and--exit-statusmakes the exit code reflect the outcome.endpoints create --waitreturns when the endpoint answers.adapters importfollows the import until it is registered or refused. Interrupting a wait stops the status updates, but the work continues. A laterwaitreconnects to it. - Exit codes
-
A read exits with
0, whatever its content reports, excepttraining info, which exits with a non-zero status while the trainer has not finished starting. A refusal, a failure under--exit-status, and a declined confirmation exit with1. - Identifiers
-
A command that takes an ID accepts an unambiguous prefix unless its help says that the full ID is required. Training projects also accept their assigned names. Datasets and scoring bundles take a registry reference, such as
triage/train,triage/train:v3, ortriage/train:candidate.
Command groups
The following table lists the command groups:
| Group | Manages |
|---|---|
|
Training and evaluation datasets in the artifact registry: register, list, inspect versions, read objects, and move aliases. See Datasets. |
|
Base models allowed by the deployment: list, inspect, select, and deselect. See Base models. |
|
Model inference endpoints: create and delete endpoints; list, inspect, or detach their models; send an input; and forward a local address. See Endpoints. |
|
Training projects, their evaluation settings, and history. See Training projects. |
|
Training runs: start, wait, pause, resume, cancel, and branch. Also metrics, hyperparameters, snapshots, TensorBoard, and the Grafana dashboard. |
|
One committed snapshot, and its registration as a candidate model. |
|
Evaluations of a model against a dataset: start, wait, report, and predictions. |
|
A source snapshot evaluated with its branches under one pinned contract. |
|
Ordered train and evaluate stages in one submission. |
|
Models in the artifact registry: the versions that training produced, base models, and the aliases that mark a candidate or a champion. See Evaluation. |
|
Scoring bundles in the artifact registry. See Scoring bundles. |
|
Images that dataset examples reference, uploaded on their own. |
The CLI has other command groups. models, budget, pricing-catalog, routing-policies, rulesets, use-cases, eval, the rest of registry, and the remaining groups operate other Akka Optimize services. This guide does not cover them.
Every command answers --help with its flags and examples.