CLI
This section provides detailed information on how to use the GRID Enterprise Command-Line Interface (CLI). The GRID CLI acts as an orchestration module for GRID sessions. Run it by typing grid
at the terminal in the appropriate Python virtual environment.
The CLI manages GRID sessions and Docker containers, and it depends on configuration files.
When initializing the GRID CLI for the first time, you will be prompted to provide credentials for the resource configuration file, which are then stored in ~/.grid/resource_config.json. The credentials will be provided to you during your onboarding process for the GRID Enterprise platform.
Along with the credentials, the resource configuration file also contains information about the nodes where you wish to run GRID sessions, as well as information about storage for saving GRID session data. For your convenience, the resource configuration file targets localhost by default, which allows you to run sessions on the same machine. If you wish to target other remote machines, see the following sections.
Configuration Overview
Machine Configuration: The ~/.grid/resource_config.json file allows you to define remote machines. Note that the "local" section is present by default. To use a remote machine, ensure that you add the necessary keys for IP address, username, and password. For example:
{ "resources": { "local": {}, "remote": { "ip": "192.168.0.106", "username": "usernamegoeshere", "password": "passwordgoeshere" } } }
When running GRID commands, always verify your node names (e.g.,
@local
,@node0
) before executing to ensure you are running them on the right machines.Mounting Storage: To mount a folder from the host to the GRID containers, add a
storage key
under the corresponding resource. For example, if you wish to mount a folder from localhost into the GRID containers:{ "resources": { "local": { "storage": { "code": "/home/test/Documents/code" } } } }
This will mount
/home/test/Documents/code
on the host to/mnt/code
in the GRID containers.Ports for Remote Access: If you are using GRID on a remote machine, ensure that the following ports are open to access the simulation, notebooks, and visualizations:
8000: GRID server
8890: Jupyter Notebook
3080: Simulation
9090: Rerun visualization
9877: Rerun stream
Commands Overview
Below is a list of the available commands in the GRID Enterprise CLI. Resource targeting is done using the @resource_name
syntax, defaulting to @local
if no resource is specified.
The first step is to log into the GRID platform and initialize the containers. Open your terminal and run the following command:
gridShow Expected Output
.d8888b. 8888888b. 8888888 8888888b. d88P Y88b 888 Y88b 888 888 "Y88b 888 888 888 888 888 888 888 888 888 d88P 888 888 888 888 88888 8888888P" 888 888 888 888 888 888 T88b 888 888 888 Y88b d88P 888 T88b 888 888 .d88P "Y8888P88 888 T88b 8888888 8888888P" Enter your username: <username> Enter your password: ******** Enter your storage token:<storage_token> Resource configuration file created successfully. Loading resource configuration from /home/user/.grid/resource_config.json... General Robot Intelligence Development Platform Console Developed by Scaled Foundations, Inc. Type 'help' or 'license' for more info.
- login
Logs into the GRID registry using the username and password or access token. The resource can be specified using
@resource_name
.login @local
Show Expected Output
Logging in to Scaled Foundations - GRID registry... Login successful!
- init
Spins up the GRID containers on the specified node (defaults to
local`
if no node is specified).init @local
Show Expected Output
Spinning up grid_core on local... Spinning up grid_service on local... grid_core: ✓ grid_service: ✓ Containers are active.
- terminate
Terminates the GRID containers on the specified node.
terminate @local
Show Expected Output
grid> terminate Stopping containers... grid_core: ❌ grid_service: ❌ Containers stopped successfully. grid>
- update
Updates the GRID containers on the specified node. You must be authenticated to the container registry for this to work.
update @local
Show Expected Output
Checking for updates... Status: Image is up to date for sfgrid.azurecr.io/grid/core/sdk:latestf6b6de19a Image sfgrid.azurecr.io/grid/core/sdk:latest pulled successfully. Status: Image is up to date for sfgrid.azurecr.io/grid/serve/sdk:latest1d14d6fb Image sfgrid.azurecr.io/grid/serve/sdk:latest pulled successfully.
- session start
<session_id> <config_path> @<resource_name>
Starts a session with the specified session ID and configuration path on the chosen resource (defaults to
@local`
if no resource is specified).session start test_session ./config/session_config.json @node0
Show Expected Output
Starting session test_session ... 2024-09-10 16:42:51,676 - INFO - HTTP Request: POST http://localhost:8000/start_session "HTTP/1.1 200 OK" response: Starting session... response: Downloading resources.. response_end: Session has been started successfully Session started successfully.
- session stop
<session_id>
Stops the session with the specified ID.
session stop test_session
Show Expected Output
grid> session stop test_session Stopping session test_session ... 2024-09-10 17:11:11,411 - INFO - HTTP Request: POST http://localhost:8000/terminate_session "HTTP/1.1 200 OK" Session stopped successfully.
- session list
Lists all ongoing sessions.
session list
Show Expected Output
grid> session list 2024-09-10 17:10:53,338 - INFO - HTTP Request: GET http://localhost:8000/is_idle?session_id=hello_grid "HTTP/1.1 200 OK" +--------------+-----------+----------------------------------+ | Session ID | Node IP | Last Active Time | +==============+===========+==================================+ | test_session | localhost | 2024-09-10T23:42:51.674976+00:00 | +--------------+-----------+----------------------------------+
- open
<session_id> nb | sim | viz
- Opens the corresponding entity for the specified session:
nb: Jupyter notebook
sim: Simulation stream
viz: Rerun visualization
open test_session nb open test_session sim open test_session viz
Show Expected Output
Opening nb for session hello_grid in default browser at http://localhost:8890 Opening sim for session hello_grid in default browser at http://localhost:3080 Opening viz for session hello_grid in default browser at http://localhost:9090/?url=ws://localhost:9877
- help
Displays a list of all available commands and their functions.
help
Show Expected Output
Documented commands (type help <topic>): ======================================== EOF exit help init login node open session terminate update