CLI
Create and manage Studios (ie: "VMs") via the CLI.
Installation
To use the Lightning CLI, first install the Lightning SDK:
pip install lightning-sdk -UBasic Usage
CLI commands follow the syntax
lightning [command]Get help on possible commands by running
lightning COMMAND --helpAuthentication
Authentication persists across sessions. Log in to use the CLI commands by running lightning login and entering your credentials in the browser tab that opens.
Create Studio
Create new Studios from the terminal by running
lightning studio create --teamspace <OWNER/TEAMSPACE_NAME> --name <STUDIO_NAME>Both --name and --teamspace are optional. In case --name is not specified, the Studio will be named randomly and in case --teamspace is not specified, it will ask interactively which teamspace to use (or take it from the config if specified).
Start Studio
Start an already existing Studio with
lightning studio start --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME> --machine T4Similar to Studio creation --name and --teamspace are optional, where it will ask for both of them if not specified as arguments or in the config file.
Stop Studio
Stop a running Studio with:
lightning studio stop --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME>When omitting --name and/or --teamspace, the CLI will prompt for them if it cannot resolve them from the environment.
Switch Studio Machine
Switching already running Studios to a different machine, can be achieved with:
lightning studio switch --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME> --machine H100Upload local files to Studio
Upload files or folders from your local workspace to a selected Studio. Studios do not need to be running to use this operation. Note that folders need the recursive flag (i.e. lightning cp -r)
lightning cp [LOCAL_PATH] [STUDIO_PATH]
lightning cp -r [LOCAL_PATH] [STUDIO_PATH]Arguments and Flags
LOCAL_PATH(Required/str): The path to the local file or folder to uploadSTUDIO_PATH(Required/str): The path to the file or folder within the Studio. Format:lit://{org}/{teamspace_name}/studios/{studio_name}/{studio_path}, orlit:///studios/{studio_name}/{studio_path}for a Studio in the current teamspace-ror--recursive(Required for folders): Must be specified when uploading folders
Examples
Upload a file to a specific studio:
To upload main.py to your Studio named my-studio in the my-teamspace teamspace of the my-org organization, use the following command:
lightning cp ./main.py lit://my-org/my-teamspace/studios/my-studio/local_main.pyUpload a directory to a specific location in a studio:
To upload a folder ./tests/ to the same Studio, use the following command:
lightning cp -r ./tests/ lit://my-org/my-teamspace/studios/my-studio/local_tests/Drop the org and teamspace to address a Studio in the teamspace you are already working in:
lightning cp ./main.py lit:///studios/my-studio/local_main.pyDownload studio files
Download files and folders to your local workspace from studios. Studios do not need to be running to use this operation. Note that folders need the recursive flag (i.e. lightning cp -r)
lightning cp [STUDIO_PATH] [LOCAL_PATH]
lightning cp -r [STUDIO_PATH] [LOCAL_PATH]Arguments and flags
STUDIO_PATH(Required/str): The path to the file within the Studio. Format:lit://{org}/{teamspace_name}/studios/{studio_name}/{studio_path}, orlit:///studios/{studio_name}/{studio_path}for a Studio in the current teamspaceLOCAL_PATH(Required/str): The path locally where files will be downloaded to-ror--recursive(Required for folders): Must be specified when downloading folders
Examples
Download a file from a specific studio:
To download main.py from your Studio named my-studio in the my-teamspace teamspace of the my-org organization, use the following command:
lightning cp lit://my-org/my-teamspace/studios/my-studio/main.py ./studio_main.pyDownload a directory to a specific local location:
To download the folder ~/tests/ from the same Studio, use the following command:
lightning cp -r lit://my-org/my-teamspace/studios/my-studio/tests/ ./Note: you can not download files from an s3 connection
Download the entire studio:
lightning cp -r lit://my-org/my-teamspace/studios/my-studio/ ./List, remove, and edit studio files
lightning ls lists a Studio's files without downloading them, lightning rm deletes them, and lightning edit opens one in your local editor and saves it back. All three take the same URLs as lightning cp:
lightning ls -r lit://my-org/my-teamspace/studios/my-studio/tests/
lightning rm lit:///studios/my-studio/main.py
lightning edit lit:///studios/my-studio/main.pySee the Teamspace Drive CLI reference for the full flags and URL syntax.
List Studios
Listing existing studios can be done with
lightning studio listAccessing Studio via SSH
To access Studios via SSH run:
lightning studio ssh --teamspace <OWNER/TEAMSPACE_NAME> --name <STUDIO_NAME>This will directly open a shell in the specified Studio. As with all other commands, the --name and --teamspace flags are optional and will be prompted for if not specified but required for Studio resolution.
Was this page helpful?
Thanks for the feedback.