Install the CLI
Install the CosmicAC CLI, set the URLs for your deployment, and sign in.
Install the CosmicAC CLI, set the URLs for your deployment, and sign in, so that you can create and manage jobs from your terminal.
Prerequisites
Before you start, make sure that you have the following.
- Node.js 18 or later.
- npm.
- A GitHub account.
- A running CosmicAC deployment. See Set up CosmicAC.
Steps
Create a GitHub personal access token
If you already have a classic personal access token (PAT) with the read:packages scope, skip this step.
- In GitHub, go to Settings > Developer settings > Personal access tokens > Tokens (classic).
- Click Generate new token (classic).
- Enter a descriptive name, such as
CosmicAC CLI. - Select the
read:packagesscope. - Click Generate token.
- Copy the token. GitHub shows it only once.
- If the
tethertoorganization enforces single sign-on (SSO), click Configure SSO next to the token, and then authorize it fortetherto.
For more information, see Managing your personal access tokens in the GitHub documentation.
Configure npm for GitHub Packages
The CosmicAC CLI is a private package on GitHub Packages, not on the npm registry. npm needs the registry address and your token to install it.
-
Point the
@tethertoscope to GitHub Packages.npm config set @tetherto:registry https://npm.pkg.github.com -
Save your token. Replace
<your-pat>with the token that you copied.npm config set //npm.pkg.github.com/:_authToken <your-pat>
Allow GitHub Packages in Socket Firewall (optional)
If you use Socket Firewall, add GitHub Packages to its allowed registries. Otherwise, npm install fails with a 403 error.
To check whether .sfw.config in your home directory already sets SFW_CUSTOM_REGISTRIES, run the command for your operating system.
grep SFW_CUSTOM_REGISTRIES ~/.sfw.configIf the command prints an SFW_CUSTOM_REGISTRIES line, edit that line instead of adding a new one.
- Open the file in a text editor.
nano ~/.sfw.config-
Inside the quotes, after the last entry, add a comma and the two GitHub Packages hostnames. The edited line looks like the following.
SFW_CUSTOM_REGISTRIES="<existing-entries>,npm:npm.pkg.github.com,npm:pkg-npm.githubusercontent.com"<existing-entries>is the value that was already in the quotes. Leave it unchanged. -
Save the file, and then close the editor.
If the command prints nothing, or reports that the file doesn't exist, run the following command for your operating system instead. The command adds the setting to the end of the file, and creates the file if it doesn't exist.
echo 'SFW_CUSTOM_REGISTRIES="npm:npm.pkg.github.com,npm:pkg-npm.githubusercontent.com"' >> ~/.sfw.configInstall the CLI
Install the CLI globally.
npm install -g @tetherto/cosmicac-cliCheck that the CLI runs.
cosmicac --helpIf the CLI lists the available commands, the installation succeeded. For every command, see CLI commands.
Set the URLs for your deployment
Save the URLs of your deployment in a named CLI environment. This example names the environment production. Replace <base-url> with your CosmicAC base URL, and keep the /api and /inference paths.
cosmicac config set --env production \
--app-url <base-url>/api \
--inference-url <base-url>/inference \
--web-url <base-url>The base URL is the address of your CosmicAC web interface, such as localhost, a server IP address, or a domain name.
Sign in
Sign in to your deployment.
cosmicac loginThe CLI opens the CosmicAC web interface in your browser. Approve the request within 5 minutes.
If no browser is available, for example, over SSH, print the sign-in URL instead, and then open it on another machine.
cosmicac login --no-browserAfter you sign in, the CLI selects a team and prints its name. To use another team, list your teams, and then select one by its ID or name.
cosmicac teams list
cosmicac teams use <team>Confirm the configuration
Check the active environment.
cosmicac config showThe output shows the active environment, its URLs, and its TEAM_ID.
Check your user and teams.
cosmicac whoamiUse more than one deployment
The CLI stores the URLs, sign-in, and active team of each deployment as a separate named environment. Commands use the active environment.
To add another deployment, set its URLs with a new --env name, and then sign in. The new environment becomes the active environment, and it starts signed out with no active team.
cosmicac config set --env staging \
--app-url <staging-base-url>/api \
--inference-url <staging-base-url>/inference \
--web-url <staging-base-url>
cosmicac loginTo switch to an environment that you already set up, run cosmicac config set with only the --env flag. The environment keeps its sign-in and active team, so you don't need to sign in again.
cosmicac config set --env productionIf you change the --app-url value of an environment, the CLI signs you out of that environment and clears its active team. To sign in again, run cosmicac login.