Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
06408c7
implemented interactive-session list
l-mansouri Mar 16, 2026
86133b0
adds the interactive session creation
l-mansouri Mar 17, 2026
c9830e4
refined in testing
l-mansouri Mar 18, 2026
4fcb373
changelog
l-mansouri Mar 18, 2026
3ebc491
fix lisitng status error
l-mansouri Mar 18, 2026
bb2d61e
changed error message for invalid credentials
l-mansouri Mar 18, 2026
3fe895b
fix error message
l-mansouri Mar 18, 2026
9b0c5a5
removed tmp files
l-mansouri Mar 18, 2026
52f7ea4
updates docs
l-mansouri Mar 18, 2026
c2459f7
added cis
l-mansouri Mar 18, 2026
f7dc8a3
fix typo in ci
l-mansouri Mar 18, 2026
aeaeecf
fix typo in ci
l-mansouri Mar 18, 2026
32606f1
fix typo in ci
l-mansouri Mar 18, 2026
91888e3
cleanup
l-mansouri Mar 18, 2026
a9baa64
address sentry
l-mansouri Mar 18, 2026
2feca3f
removed gitlab token from cis
l-mansouri Mar 18, 2026
61b2801
removed gitlab token from cis
l-mansouri Mar 18, 2026
477f0f6
added azzure interactive-session creation support
l-mansouri Mar 18, 2026
b841b22
cleanup
l-mansouri Mar 18, 2026
9ff31d1
added azure cis
l-mansouri Mar 18, 2026
008dd9d
fix typo
l-mansouri Mar 18, 2026
3fde0f1
fix azure cis
l-mansouri Mar 18, 2026
8d89ee1
fix cis
l-mansouri Mar 18, 2026
91b1304
address sentry
l-mansouri Mar 18, 2026
39695e5
fix typo in ci
l-mansouri Mar 18, 2026
ad6b430
address sentry
l-mansouri Mar 18, 2026
353cd7c
draft implementation
l-mansouri Mar 19, 2026
c068a64
changed table to print full id
l-mansouri Mar 19, 2026
ce7c813
address sentry
l-mansouri Mar 19, 2026
b4d9bc6
Merge branch 'ia_sessions' of https://github.com/lifebit-ai/cloudos-c…
l-mansouri Mar 19, 2026
6e63e54
refined implementation in testing
l-mansouri Mar 19, 2026
f7118d6
updated docs
l-mansouri Mar 19, 2026
fab7087
changelog
l-mansouri Mar 19, 2026
19cb0f8
addded cis
l-mansouri Mar 19, 2026
b1b65e3
fix cis
l-mansouri Mar 19, 2026
1e46741
address sentry
l-mansouri Mar 19, 2026
6843d29
changed tip in the creation command
l-mansouri Mar 20, 2026
c410ac8
address sentry
l-mansouri Mar 20, 2026
f5579ec
addressed dani's comments
l-mansouri Mar 23, 2026
6d1fb0b
Merge branch 'main' into ia-status
l-mansouri Mar 23, 2026
7f95e77
fix typo in merge
l-mansouri Mar 23, 2026
80becd9
fix typo in merge
l-mansouri Mar 23, 2026
42026ac
fix typo in merge
l-mansouri Mar 23, 2026
11c6fb2
fix typo in merge
l-mansouri Mar 23, 2026
f24bd8a
addressed sentry
l-mansouri Mar 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,8 @@ jobs:
run: |
echo q |cloudos interactive-session list --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID
interactive_session_create:
outputs:
session_id: ${{ steps.get-session-id.outputs.session_id }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -936,12 +938,46 @@ jobs:
- name: Install dependencies
run: |
pip install -e .
- name: Run tests
- name: Create interactive session
id: get-session-id
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_ADAPT }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_ADAPT }}
CLOUDOS_URL: "https://cloudos.lifebit.ai"
PROJECT_NAME: "cloudos-cli-tests"
SESSION_NAME: "ci_test_cli"
SESSION_TYPE: "jupyter"
SHUTDOWN_IN: "10m"
run: |
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name $SESSION_NAME --session-type $SESSION_TYPE --shutdown-in $SHUTDOWN_IN 2>&1 | tee out.txt
SESSION_ID=$(grep -oP '(?<=/view/)[a-f0-9]{24}' out.txt | head -1)
echo "session_id=$SESSION_ID" >> $GITHUB_OUTPUT
interactive_session_status:
needs: interactive_session_create
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
- name: Install dependencies
run: |
pip install -e .
- name: Get session status
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_ADAPT }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_ADAPT }}
CLOUDOS_URL: "https://cloudos.lifebit.ai"
SESSION_ID: ${{ needs.interactive_session_create.outputs.session_id }}
run: |
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name ci_test_cli --session-type jupyter --shutdown-in 10m
cloudos interactive-session status --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --session-id $SESSION_ID




38 changes: 36 additions & 2 deletions .github/workflows/ci_az.yml
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ jobs:
run: |
echo q |cloudos interactive-session list --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID
interactive_session_create:
outputs:
session_id: ${{ steps.get-session-id.outputs.session_id }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -722,13 +724,45 @@ jobs:
- name: Install dependencies
run: |
pip install -e .
- name: Run tests
- name: Create interactive session
id: get-session-id
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_AZURE }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_AZURE }}
CLOUDOS_URL: "https://dev.sdlc.lifebit.ai"
PROJECT_NAME: "cloudos-cli-tests"
SESSION_NAME: "ci_test_cli"
SESSION_TYPE: "jupyter"
SHUTDOWN_IN: "10m"
EXECUTION_PLATFORM: "azure"
INSTANCE_TYPE: "Standard_D4as_v4"
run: |
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name ci_test_cli --session-type jupyter --shutdown-in 10m --execution-platform azure --instance $INSTANCE_TYPE
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name $SESSION_NAME --session-type $SESSION_TYPE --shutdown-in $SHUTDOWN_IN --execution-platform $EXECUTION_PLATFORM --instance $INSTANCE_TYPE 2>&1 | tee out.txt
SESSION_ID=$(grep -oP '(?<=/view/)[a-f0-9]{24}' out.txt | head -1)
echo "session_id=$SESSION_ID" >> $GITHUB_OUTPUT
interactive_session_status:
needs: interactive_session_create
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
- name: Install dependencies
run: |
pip install -e .
- name: Get session status
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_AZURE }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_AZURE }}
CLOUDOS_URL: "https://dev.sdlc.lifebit.ai"
SESSION_ID: ${{ needs.interactive_session_create.outputs.session_id }}
run: |
cloudos interactive-session status --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --session-id $SESSION_ID

45 changes: 39 additions & 6 deletions .github/workflows/ci_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ jobs:
run: |
echo q |cloudos interactive-session list --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID
interactive_session_create:
outputs:
session_id: ${{ steps.get-session-id.outputs.session_id }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -942,11 +944,42 @@ jobs:
- name: Install dependencies
run: |
pip install -e .
- name: Run tests
- name: Create interactive session
id: get-session-id
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_DEV }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_DEV }}
CLOUDOS_URL: "https://dev.sdlc.lifebit.ai"
PROJECT_NAME: "cloudos-cli-tests"
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_DEV }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_DEV }}
CLOUDOS_URL: "https://dev.sdlc.lifebit.ai"
PROJECT_NAME: "cloudos-cli-tests"
SESSION_NAME: "ci_test_cli"
SESSION_TYPE: "jupyter"
SHUTDOWN_IN: "10m"
run: |
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name $SESSION_NAME --session-type $SESSION_TYPE --shutdown-in $SHUTDOWN_IN 2>&1 | tee out.txt
SESSION_ID=$(grep -oP '(?<=/view/)[a-f0-9]{24}' out.txt | head -1)
echo "session_id=$SESSION_ID" >> $GITHUB_OUTPUT
interactive_session_status:
needs: interactive_session_create
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: setup.py
- name: Install dependencies
run: |
pip install -e .
- name: Get session status
env:
CLOUDOS_TOKEN: ${{ secrets.CLOUDOS_TOKEN_DEV }}
CLOUDOS_WORKSPACE_ID: ${{ secrets.CLOUDOS_WORKSPACE_ID_DEV }}
CLOUDOS_URL: "https://dev.sdlc.lifebit.ai"
SESSION_ID: ${{ needs.interactive_session_create.outputs.session_id }}
run: |
cloudos interactive-session create --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --project-name "$PROJECT_NAME" --name ci_test_cli --session-type jupyter --shutdown-in 10m
cloudos interactive-session status --cloudos-url $CLOUDOS_URL --apikey $CLOUDOS_TOKEN --workspace-id $CLOUDOS_WORKSPACE_ID --session-id $SESSION_ID
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## lifebit-ai/cloudos-cli: changelog

## v2.84.0 (2026-03-19)

### Feat

- Adds interactive session status

## v2.83.0 (2026-03-18)

### Feat
Expand Down
125 changes: 124 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Python package for interacting with CloudOS
- [Use multiple projects for files in `--parameter` option](#use-multiple-projects-for-files-in---parameter-option)
- [Interactive Sessions](#interactive-sessions)
- [List Interactive Sessions](#list-interactive-sessions)
- [Get Interactive Session Status](#get-interactive-session-status)
- [Create Interactive Session](#create-interactive-session)
- [Datasets](#datasets)
- [List Files](#list-files)
Expand Down Expand Up @@ -1952,7 +1953,7 @@ Interactive sessions allow you to work within the platform using different virtu

You can get a list of all interactive sessions in your workspace by running `cloudos interactive-session list`. The command can produce three different output formats that can be selected using the `--output-format` option:

- **stdout** (default): Displaysa table directly in the terminal with interactive pagination
- **stdout** (default): Displays a table directly in the terminal with interactive pagination
- **csv**: Saves session data to a CSV file with a minimum predefined set of columns by default, or all available columns using the `--all-fields` parameter
- **json**: Saves complete session information to a JSON file with all available fields

Expand Down Expand Up @@ -2035,6 +2036,128 @@ cloudos interactive-session list --profile my_profile --table-columns "status,na

Available columns: `backend`, `cost`, `cost_limit`, `created_at`, `id`, `instance`, `name`, `owner`, `project`, `resources`, `runtime`, `saved_at`, `spot`, `status`, `time_left`, `type`, `version`

#### Get Interactive Session Status

You can retrieve detailed status information for a specific interactive session using the `cloudos interactive-session status` command. This command provides comprehensive information about the session including its current state, resource allocation, costs, and more.

**Basic Usage**

Get the status of a session:

```bash
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile
```

The command displays session information in a formatted table:

```console
╔════════════════════╦═════════════════════════════════════════════════════╗
║ Property ║ Value ║
╠════════════════════╬═════════════════════════════════════════════════════╣
║ Session ID ║ 69bc00cb1488084e5a6cae70 ║
║ Name ║ analysis-dev (linked) ║
║ Status ║ running ║
║ Backend ║ awsJupyterNotebook ║
║ Owner ║ John Doe ║
║ Project ║ research ║
║ Instance Type ║ c5.xlarge ║
║ Storage ║ 50 GB ║
║ Cost ║ $2.45/hour ║
║ Runtime ║ 2h 15m 30s ║
║ Created At ║ 2024-03-19 10:30:00 UTC ║
║ Last Saved ║ 2024-03-19 12:30:00 UTC ║
║ Auto-Shutdown At ║ 2024-03-19 18:30:00 UTC ║
╚════════════════════╩═════════════════════════════════════════════════════╝
```

**Watch Mode for Provisioning Sessions**

Use the `--watch` flag to continuously monitor a session's status as it provisions, with real-time status change notifications:

```bash
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
```

Watch mode automatically tracks status changes and polls until the session reaches a terminal state:

```console
Session 69bc00cb1488084e5a6cae70 currently is in initialising...
Status changed: initialising → provisioning
Status changed: provisioning → running
✓ Session is now running and ready to use!
```

**Watch Mode Behavior**

- **Pre-running sessions** (setup, initialising, scheduled): Watch mode will continuously poll and display status changes every 30 seconds (default)
- **Running/stopped sessions**: Watch mode will show a warning and display the current status instead

Example with a running session:

```bash
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
```

```console
⚠ Warning: Watch mode only works for pre-running statuses (setup, initialising, scheduled). Current status: running. Showing session status instead.
[session status table displayed]
```

**Polling Interval**

Customize the polling interval for watch mode:

```bash
# Poll every 15 seconds instead of default 30
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --watch-interval 15
```

**Watch Mode Timeout**

Set a maximum time to wait for the session to reach running state. The `--max-wait-time` option accepts human-friendly duration formats:

```bash
# 30 minutes (default)
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch

# 5 minutes
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 5m

# 2 hours
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 2h

# 1 day
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 1d

# 60 seconds
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 60s
```

**Supported timeout formats:**
- `30s` - seconds
- `5m` - minutes
- `2h` - hours
- `1d` - days

If the session does not reach running state within the specified timeout, the watch mode exits with a clear message:

```console
Timeout: Session did not reach running state within 30m. Current status: provisioning. Exiting watch mode.
```

**Output Formats**

Save session status to a file:

```bash
# Save as JSON
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format json --output-basename /tmp/session_status
# Creates: /tmp/session_status.json

# Save as CSV
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format csv --output-basename /tmp/session_status
# Creates: /tmp/session_status.csv
```

#### Create Interactive Session

Expand Down
2 changes: 1 addition & 1 deletion cloudos_cli/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.83.0'
__version__ = '2.84.0'
38 changes: 0 additions & 38 deletions cloudos_cli/clos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2418,42 +2418,4 @@ def create_interactive_session(self, team_id, payload, verify=True):
content = r.json()
return content

## FOR FUTURE COMMANDS IMPLEMENTATION
# def get_interactive_session(self, team_id, session_id, verify=True):
# """Get details of a specific interactive session.

# Parameters
# ----------
# team_id : string
# The CloudOS team id (workspace id).
# session_id : string
# The interactive session id (MongoDB ObjectId).
# verify: [bool|string], default=True
# Whether to use SSL verification or not.

# Returns
# -------
# dict
# Session object with current status and full details.
# """
# if not team_id or not isinstance(team_id, str):
# raise ValueError("Invalid team_id: must be a non-empty string")

# if not session_id or not isinstance(session_id, str):
# raise ValueError("Invalid session_id: must be a non-empty string")

# headers = {
# "Content-type": "application/json",
# "apikey": self.apikey
# }

# # Build URL for getting specific session
# url = f"{self.cloudos_url}/api/v2/interactive-sessions/{session_id}?teamId={team_id}"

# r = retry_requests_get(url, headers=headers, verify=verify)

# if r.status_code >= 400:
# raise BadRequestException(r)

# content = r.json()
# return content
Loading
Loading