ReferenceCache

Polyaxon CLI creates a cache context to improve the user experience and avoid passing arguments for static information like owner, project, and last run.

Caching

When using Polyaxon CLI to run a command requiring a project or a run, you can always specify the values for these options, for example:

  • polyaxon project get --project=user_1/project_10
  • polyaxon ops get --project=user_1/project_10 --uid=UUID

Polyaxon CLI allows also you to omit these options for projects and runs, the CLI does the following:

  1. When an owner (username or an organization) is missing, the owner is inferred based on the logged-in user, if no user/owner is found the default owner is used.
  2. When a project name is missing, the name of the currently initialized project is used.
  3. When a run is missing, the last value is used.
  4. If no values are found, the CLI will show an error.

All commands and sub-command of project and ops support this caching mechanism:

  • polyaxon project ls
  • polyaxon project get
  • polyaxon ops ls
  • polyaxon ops get
  • polyaxon ops logs
  • ...

Updating the cached configuration

Every time you create a project or start a run, Polyaxon will save the response of that entity to the cache. For example:

polyaxon project create --name test [--init] will create a new project and will automatically cache the value of that project. In all subsequent commands, if the user does not provide a project --project, Polyaxon CLI will use this project that was created.

polyaxon run ... will create a new run and will automatically cache the value. In all subsequent commands, if the user does not provide a project --project/-p and a run uuid --uid/-uid, Polyaxon CLI will use the last cached project and run.

By creating new runs, Polyaxon will keep updating the cache detail to the latest created run.

You can also influence the run cache by getting a specific run, e.g. polyaxon ops get -uid UUID will fetch the information about that specific run and persist the result to the cache so that you can run further commands without the need to pass the -uid UUID, e.g. polyaxon ops logs will use the same UUID.

Caching visibility

By default, Polyaxon will cache all information on Polyaxon's global path, if you want to enable caching on local project folder(s), you can use the init command:

polyaxon init -p PROJECT_NAME

This will create a local cache folder for the project and its runs.

Anytime you use the cli, it will look first locally, then defaults to the global path.

Displayed context

Context display is disabled by default. Pass the global --show-context option before the command, or enable --verbose (-v), to show a Context: section on stderr when cached values are used. It includes the owner, project, and run (when used), with each value's source: explicit, default, local cache, or global cache. Cached values include the cache file path.

For example, polyaxon --show-context project get --project quick-start with a cached owner can show:

Context:
 Owner   acme         global cache · /home/user/.polyaxon/.user
 Project quick-start  explicit

Fully explicit commands do not show this section. JSON and streamed output stay on stdout. Cached-run ownership conflicts are checked whether or not --show-context is set.

Conflicting cached run context

The .project and .run caches are resolved independently. For example, fetching a run from acme/project-a and then running polyaxon init --project acme/project-b changes the cached project but leaves the previous run cached. A local project can also fall back to an unrelated global run cache.

When a command uses a cached run UUID, Polyaxon rejects a known owner or project mismatch before making the run request. The error includes the cached run identity and cache source, the resolved project identity, and the sources of its owner and project. Passing only --project does not override the cached run UUID.

To select an existing run explicitly, pass both options:

polyaxon ops logs --project OWNER/PROJECT --uid UUID

To update the cached context too, initialize the intended project and fetch its run:

polyaxon init --project OWNER/PROJECT
polyaxon ops get --project OWNER/PROJECT --uid UUID
polyaxon ops logs

Only known cached owner and project values are checked. Missing metadata does not itself cause an error, but any known conflicting value still does. An explicit UUID bypasses this cache check; it does not verify that the run belongs to the selected project. The server still validates the request. Creating or listing runs does not require using the cached UUID.

Switching context

Users don't have to change to a new project to access information about that project, and its ops.

All commands allow changing the project context by providing -p project or --project=project.

You can as well check other users/organizations projects without initializing the projects, -p owner/project or --project=owner/project.

Here are some examples:

  • Getting other projects experiments:

    • polyaxon project ops -p mnist -s "-created_at"
    • polyaxon project ops --project=acme/mnist -q "status: failed"
  • Getting services named tensorboard for some projects:

    • polyaxon ops ls --project=mnist --query="name: tensorboard" --sort="-created_at"
    • polyaxon tensorboards ls -p acme/mnist --query="name: tensorboard, status: running"
  • Getting information about a specific experiment:

    • polyaxon ops get -p mnist -uid UUID
    • polyaxon ops get -p acme/mnist --uid=UUID