Workspaces API Reference
Customer-hosted cloud features
Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.
Workspaces CLI
anyscale workspace_v2 create
Usage
anyscale workspace_v2 create [OPTIONS]
Create a workspace on Anyscale.
Options
-f/--config-file
: Path to a YAML config file to deploy. When deploying from a file, import path and arguments cannot be provided. Command-line flags will overwrite values read from the file.-n/--name
: Name of the workspace to create.--image-uri
: Container image to use for the workspace. This is exclusive with --containerfile.--registry-login-secret
: Name or identifier of the secret containing credentials to authenticate to the docker registry hosting the image. This can only be used when 'image_uri' is specified and the image is not hosted on Anyscale.--containerfile
: Path to a containerfile to build the image to use for the workspace. This is exclusive with --image-uri.--ray-version
: The Ray version (X.Y.Z) to the image specified by --image-uri. This is only used when --image-uri is provided. If not provided, the latest Ray version will be used.--compute-config
: Named compute configuration to use for the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).--project
: Named project to use for the workspace. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).-r/--requirements
: Path to a requirements.txt file containing dependencies for the workspace. These will be installed on top of the image.--env
: Environment variables to set for the workspace. The format is 'key=value'. This argument can be specified multiple times. When the same key is also specified in the config file, the value from the command-line flag will overwrite the value from the config file.
Examples
- CLI
$ anyscale workspace_v2 create -f config.yml
(anyscale +2.7s) Workspace created successfully id: expwrk_jstjkv15a1vmle2j1t59s4bm35
(anyscale +3.9s) Applied dynamic requirements to workspace id: my-workspace
(anyscale +4.8s) Applied environment variables to workspace id: my-workspace
$ cat config.yml
name: my-workspace
idle_termination_minutes: 10
env_vars:
HUMPDAY: WEDS
requirements: requirements.txt
anyscale workspace_v2 start
Usage
anyscale workspace_v2 start [OPTIONS]
Start a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.
Examples
- CLI
$ anyscale workspace_v2 start --name my-workspace
(anyscale +5.8s) Starting workspace 'my-workspace'
anyscale workspace_v2 terminate
Usage
anyscale workspace_v2 terminate [OPTIONS]
Terminate a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.
Examples
- CLI
$ anyscale workspace_v2 terminate --name my-workspace
(anyscale +2.5s) Terminating workspace 'my-workspace'
anyscale workspace_v2 status
Usage
anyscale workspace_v2 status [OPTIONS]
Get the status of a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.
Examples
- CLI
$ anyscale workspace_v2 status --name my-workspace
(anyscale +2.3s) STARTING
anyscale workspace_v2 wait
Usage
anyscale workspace_v2 wait [OPTIONS]
Wait for a workspace to reach a terminal state.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.--timeout-s
: The maximum time in seconds to wait for the workspace to reach the desired state. Default to 30 minutes.--state
: The desired terminal state to wait for. Default is 'RUNNING'.
Examples
- CLI
$ anyscale workspace_v2 wait --name my-workspace --state RUNNING
(anyscale +2.5s) Waiting for workspace 'expwrk_jstjkv15a1vmle2j1t59s4bm35' to reach target state RUNNING, currently in state: RUNNING
(anyscale +2.8s) Workspace 'expwrk_jstjkv15a1vmle2j1t59s4bm35' reached target state, exiting
anyscale workspace_v2 ssh
Usage
anyscale workspace_v2 ssh [OPTIONS]
SSH into a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
You may pass extra args for the ssh command, for example to setup port forwarding: anyscale workspace_v2 ssh -n workspace-name -- -L 9000:localhost:9000
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.
Examples
- CLI
$ anyscale workspace_v2 ssh --name my-workspace
Authorized uses only. All activity may be monitored and reported.
Warning: Permanently added '[0.0.0.0]:5020' (ED25519) to the list of known hosts.
(base) ray@ip-10-0-24-60:~/default$
anyscale workspace_v2 run_command
Usage
anyscale workspace_v2 run_command [OPTIONS] COMMAND
Run a command in a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.
Examples
- CLI
$ anyscale workspace_v2 run_command --name my-workspace "echo hello world"
Authorized uses only. All activity may be monitored and reported.
Warning: Permanently added '[0.0.0.0]:5020' (ED25519) to the list of known hosts.
hello world
anyscale workspace_v2 pull
Usage
anyscale workspace_v2 pull [OPTIONS]
Pull the working directory of a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
This command depends on rsync, please make sure it is installed on your system.
You may pass extra args for the rsync command, for example to exclude files: anyscale workspace_v2 pull -n workspace-name -- --exclude='log.txt'
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.--local-dir
: Local directory to pull the workspace directory to. If not provided, the current directory will be used.--pull-git-state
: Pull the git state of the workspace.
Examples
- CLI
$ anyscale workspace_v2 pull --name my-workspace --local-dir my-local
Warning: Permanently added '54.212.209.253' (ED25519) to the list of known hosts.
Authorized uses only. All activity may be monitored and reported.
Warning: Permanently added '[0.0.0.0]:5020' (ED25519) to the list of known hosts.
receiving incremental file list
created directory my-local
./
my-local/
my-local/main.py
sent 118 bytes received 141 bytes 172.67 bytes/sec
total size is 0 speedup is 0.00
anyscale workspace_v2 push
Usage
anyscale workspace_v2 push [OPTIONS]
Push a local directory to a workspace.
To specify the workspace by name, use the --name flag. To specify the workspace by id, use the --id flag. Either name or id should be used, specifying both will result in an error.
This command depends on rsync, please make sure it is installed on your system.
You may pass extra args for the rsync command, for example to exclude files: anyscale workspace_v2 push -n workspace-name -- --exclude='log.txt'
Options
--id/--workspace-id
: Unique ID of the workspace.--name/-n
: Name of the workspace.--cloud
: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used.--project
: Named project to use for the workpsace. If not provided, the default project for the cloud will be used.--local-dir
: Local directory to push to the workspace. If not provided, the current directory will be used.--push-git-state
: Push the git state of the workspace.
Examples
- CLI
$ anyscale workspace_v2 push --name my-workspace --local-dir my-local
Warning: Permanently added '52.10.22.124' (ED25519) to the list of known hosts.
Authorized uses only. All activity may be monitored and reported.
Warning: Permanently added '[0.0.0.0]:5020' (ED25519) to the list of known hosts.
sending incremental file list
my-local/
my-local/main.py
sent 188 bytes received 39 bytes 151.33 bytes/sec
total size is 0 speedup is 0.00
Workspaces SDK
anyscale.workspace.create
Create a workspace.
Returns the id of the created workspace.
Arguments
config
(WorkspaceConfig): The config for defining the workspace.
Returns: str
Examples
- Python
import anyscale
from anyscale.workspace.models import WorkspaceConfig
anyscale.workspace.create(
WorkspaceConfig(
name="my-workspace",
idle_termination_minutes=120,
),
)
anyscale.workspace.start
Start a workspace.
Returns the id of the started workspace.
Arguments
name
(str | None) = None: Name of the workspace.id
(str | None) = None: Unique ID of the workspacecloud
(str | None) = None: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).project
(str | None) = None: Named project to use for the workspace. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Returns: str
Examples
- Python
import anyscale
anyscale.workspace.start(
name="my-workspace",
)
anyscale.workspace.terminate
Terminate a workspace.
Returns the id of the terminated workspace.
Arguments
name
(str | None) = None: Name of the workspace.id
(str | None) = None: Unique ID of the workspacecloud
(str | None) = None: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).project
(str | None) = None: Named project to use for the workspace. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Returns: str
Examples
- Python
import anyscale
anyscale.workspace.terminate(
name="my-workspace",
)
anyscale.workspace.status
Get the status of a workspace.
Returns the status of the workspace.
Arguments
name
(str | None) = None: Name of the workspace.id
(str | None) = None: Unique ID of the workspacecloud
(str | None) = None: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).project
(str | None) = None: Named project to use for the workspace. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).
Returns: str
Examples
- Python
import anyscale
status = anyscale.workspace.status(
name="my-workspace",
)
anyscale.workspace.wait
Wait for a workspace to reach a terminal state.
Returns the status of the workspace.
Arguments
name
(str | None) = None: Name of the workspace.id
(str | None) = None: Unique ID of the workspacecloud
(str | None) = None: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).project
(str | None) = None: Named project to use for the workspace. If not provided, the default project for the cloud will be used (or, if running in a workspace, the project of the workspace).timeout_s
(float) = 1800.0: The maximum time to wait for the workspace to reach a terminal state.state
(str) = RUNNING: The desired terminal state to wait for, defaults to RUNNING.
Returns: str
Examples
- Python
import anyscale
anyscale.workspace.wait(
name="my-workspace",
)