cloudos-cli 2.83.0__tar.gz → 2.84.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/PKG-INFO +125 -2
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/README.md +124 -1
- cloudos_cli-2.84.0/cloudos_cli/_version.py +1 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/clos.py +0 -38
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/interactive_session/cli.py +239 -2
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/interactive_session/interactive_session.py +615 -2
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/PKG-INFO +125 -2
- cloudos_cli-2.83.0/cloudos_cli/_version.py +0 -1
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/LICENSE +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/__main__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/bash/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/bash/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/configure/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/configure/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/configure/configure.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/constants.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/cost/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/cost/cost.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/cromwell/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/cromwell/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/datasets/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/datasets/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/datasets/datasets.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/import_wf/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/import_wf/import_wf.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/interactive_session/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/jobs/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/jobs/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/jobs/job.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/link/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/link/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/link/link.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/logging/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/logging/logger.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/procurement/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/procurement/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/procurement/images.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/projects/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/projects/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/queue/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/queue/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/queue/queue.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/related_analyses/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/related_analyses/related_analyses.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/array_job.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/cli_helpers.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/cloud.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/details.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/errors.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/last_wf.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/requests.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/utils/resources.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/workflows/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli/workflows/cli.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/SOURCES.txt +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/requires.txt +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/cloudos_cli.egg-info/top_level.txt +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/setup.cfg +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/setup.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/functions_for_pytest.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_cli_project_create.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_cost/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_cost/test_job_cost.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_error_messages.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_interactive_session/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_interactive_session/test_create_session.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_interactive_session/test_list_sessions.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_logging/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_logging/test_logger.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_related_analyses/__init__.py +0 -0
- {cloudos_cli-2.83.0 → cloudos_cli-2.84.0}/tests/test_related_analyses/test_related_analyses.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloudos_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.84.0
|
|
4
4
|
Summary: Python package for interacting with CloudOS
|
|
5
5
|
Home-page: https://github.com/lifebit-ai/cloudos-cli
|
|
6
6
|
Author: David Piñeyro
|
|
@@ -100,6 +100,7 @@ Python package for interacting with CloudOS
|
|
|
100
100
|
- [Use multiple projects for files in `--parameter` option](#use-multiple-projects-for-files-in---parameter-option)
|
|
101
101
|
- [Interactive Sessions](#interactive-sessions)
|
|
102
102
|
- [List Interactive Sessions](#list-interactive-sessions)
|
|
103
|
+
- [Get Interactive Session Status](#get-interactive-session-status)
|
|
103
104
|
- [Create Interactive Session](#create-interactive-session)
|
|
104
105
|
- [Datasets](#datasets)
|
|
105
106
|
- [List Files](#list-files)
|
|
@@ -1987,7 +1988,7 @@ Interactive sessions allow you to work within the platform using different virtu
|
|
|
1987
1988
|
|
|
1988
1989
|
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:
|
|
1989
1990
|
|
|
1990
|
-
- **stdout** (default):
|
|
1991
|
+
- **stdout** (default): Displays a table directly in the terminal with interactive pagination
|
|
1991
1992
|
- **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
|
|
1992
1993
|
- **json**: Saves complete session information to a JSON file with all available fields
|
|
1993
1994
|
|
|
@@ -2070,6 +2071,128 @@ cloudos interactive-session list --profile my_profile --table-columns "status,na
|
|
|
2070
2071
|
|
|
2071
2072
|
Available columns: `backend`, `cost`, `cost_limit`, `created_at`, `id`, `instance`, `name`, `owner`, `project`, `resources`, `runtime`, `saved_at`, `spot`, `status`, `time_left`, `type`, `version`
|
|
2072
2073
|
|
|
2074
|
+
#### Get Interactive Session Status
|
|
2075
|
+
|
|
2076
|
+
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.
|
|
2077
|
+
|
|
2078
|
+
**Basic Usage**
|
|
2079
|
+
|
|
2080
|
+
Get the status of a session:
|
|
2081
|
+
|
|
2082
|
+
```bash
|
|
2083
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile
|
|
2084
|
+
```
|
|
2085
|
+
|
|
2086
|
+
The command displays session information in a formatted table:
|
|
2087
|
+
|
|
2088
|
+
```console
|
|
2089
|
+
╔════════════════════╦═════════════════════════════════════════════════════╗
|
|
2090
|
+
║ Property ║ Value ║
|
|
2091
|
+
╠════════════════════╬═════════════════════════════════════════════════════╣
|
|
2092
|
+
║ Session ID ║ 69bc00cb1488084e5a6cae70 ║
|
|
2093
|
+
║ Name ║ analysis-dev (linked) ║
|
|
2094
|
+
║ Status ║ running ║
|
|
2095
|
+
║ Backend ║ awsJupyterNotebook ║
|
|
2096
|
+
║ Owner ║ John Doe ║
|
|
2097
|
+
║ Project ║ research ║
|
|
2098
|
+
║ Instance Type ║ c5.xlarge ║
|
|
2099
|
+
║ Storage ║ 50 GB ║
|
|
2100
|
+
║ Cost ║ $2.45/hour ║
|
|
2101
|
+
║ Runtime ║ 2h 15m 30s ║
|
|
2102
|
+
║ Created At ║ 2024-03-19 10:30:00 UTC ║
|
|
2103
|
+
║ Last Saved ║ 2024-03-19 12:30:00 UTC ║
|
|
2104
|
+
║ Auto-Shutdown At ║ 2024-03-19 18:30:00 UTC ║
|
|
2105
|
+
╚════════════════════╩═════════════════════════════════════════════════════╝
|
|
2106
|
+
```
|
|
2107
|
+
|
|
2108
|
+
**Watch Mode for Provisioning Sessions**
|
|
2109
|
+
|
|
2110
|
+
Use the `--watch` flag to continuously monitor a session's status as it provisions, with real-time status change notifications:
|
|
2111
|
+
|
|
2112
|
+
```bash
|
|
2113
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2114
|
+
```
|
|
2115
|
+
|
|
2116
|
+
Watch mode automatically tracks status changes and polls until the session reaches a terminal state:
|
|
2117
|
+
|
|
2118
|
+
```console
|
|
2119
|
+
Session 69bc00cb1488084e5a6cae70 currently is in initialising...
|
|
2120
|
+
Status changed: initialising → provisioning
|
|
2121
|
+
Status changed: provisioning → running
|
|
2122
|
+
✓ Session is now running and ready to use!
|
|
2123
|
+
```
|
|
2124
|
+
|
|
2125
|
+
**Watch Mode Behavior**
|
|
2126
|
+
|
|
2127
|
+
- **Pre-running sessions** (setup, initialising, scheduled): Watch mode will continuously poll and display status changes every 30 seconds (default)
|
|
2128
|
+
- **Running/stopped sessions**: Watch mode will show a warning and display the current status instead
|
|
2129
|
+
|
|
2130
|
+
Example with a running session:
|
|
2131
|
+
|
|
2132
|
+
```bash
|
|
2133
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2134
|
+
```
|
|
2135
|
+
|
|
2136
|
+
```console
|
|
2137
|
+
⚠ Warning: Watch mode only works for pre-running statuses (setup, initialising, scheduled). Current status: running. Showing session status instead.
|
|
2138
|
+
[session status table displayed]
|
|
2139
|
+
```
|
|
2140
|
+
|
|
2141
|
+
**Polling Interval**
|
|
2142
|
+
|
|
2143
|
+
Customize the polling interval for watch mode:
|
|
2144
|
+
|
|
2145
|
+
```bash
|
|
2146
|
+
# Poll every 15 seconds instead of default 30
|
|
2147
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --watch-interval 15
|
|
2148
|
+
```
|
|
2149
|
+
|
|
2150
|
+
**Watch Mode Timeout**
|
|
2151
|
+
|
|
2152
|
+
Set a maximum time to wait for the session to reach running state. The `--max-wait-time` option accepts human-friendly duration formats:
|
|
2153
|
+
|
|
2154
|
+
```bash
|
|
2155
|
+
# 30 minutes (default)
|
|
2156
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2157
|
+
|
|
2158
|
+
# 5 minutes
|
|
2159
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 5m
|
|
2160
|
+
|
|
2161
|
+
# 2 hours
|
|
2162
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 2h
|
|
2163
|
+
|
|
2164
|
+
# 1 day
|
|
2165
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 1d
|
|
2166
|
+
|
|
2167
|
+
# 60 seconds
|
|
2168
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 60s
|
|
2169
|
+
```
|
|
2170
|
+
|
|
2171
|
+
**Supported timeout formats:**
|
|
2172
|
+
- `30s` - seconds
|
|
2173
|
+
- `5m` - minutes
|
|
2174
|
+
- `2h` - hours
|
|
2175
|
+
- `1d` - days
|
|
2176
|
+
|
|
2177
|
+
If the session does not reach running state within the specified timeout, the watch mode exits with a clear message:
|
|
2178
|
+
|
|
2179
|
+
```console
|
|
2180
|
+
Timeout: Session did not reach running state within 30m. Current status: provisioning. Exiting watch mode.
|
|
2181
|
+
```
|
|
2182
|
+
|
|
2183
|
+
**Output Formats**
|
|
2184
|
+
|
|
2185
|
+
Save session status to a file:
|
|
2186
|
+
|
|
2187
|
+
```bash
|
|
2188
|
+
# Save as JSON
|
|
2189
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format json --output-basename /tmp/session_status
|
|
2190
|
+
# Creates: /tmp/session_status.json
|
|
2191
|
+
|
|
2192
|
+
# Save as CSV
|
|
2193
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format csv --output-basename /tmp/session_status
|
|
2194
|
+
# Creates: /tmp/session_status.csv
|
|
2195
|
+
```
|
|
2073
2196
|
|
|
2074
2197
|
#### Create Interactive Session
|
|
2075
2198
|
|
|
@@ -65,6 +65,7 @@ Python package for interacting with CloudOS
|
|
|
65
65
|
- [Use multiple projects for files in `--parameter` option](#use-multiple-projects-for-files-in---parameter-option)
|
|
66
66
|
- [Interactive Sessions](#interactive-sessions)
|
|
67
67
|
- [List Interactive Sessions](#list-interactive-sessions)
|
|
68
|
+
- [Get Interactive Session Status](#get-interactive-session-status)
|
|
68
69
|
- [Create Interactive Session](#create-interactive-session)
|
|
69
70
|
- [Datasets](#datasets)
|
|
70
71
|
- [List Files](#list-files)
|
|
@@ -1952,7 +1953,7 @@ Interactive sessions allow you to work within the platform using different virtu
|
|
|
1952
1953
|
|
|
1953
1954
|
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:
|
|
1954
1955
|
|
|
1955
|
-
- **stdout** (default):
|
|
1956
|
+
- **stdout** (default): Displays a table directly in the terminal with interactive pagination
|
|
1956
1957
|
- **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
|
|
1957
1958
|
- **json**: Saves complete session information to a JSON file with all available fields
|
|
1958
1959
|
|
|
@@ -2035,6 +2036,128 @@ cloudos interactive-session list --profile my_profile --table-columns "status,na
|
|
|
2035
2036
|
|
|
2036
2037
|
Available columns: `backend`, `cost`, `cost_limit`, `created_at`, `id`, `instance`, `name`, `owner`, `project`, `resources`, `runtime`, `saved_at`, `spot`, `status`, `time_left`, `type`, `version`
|
|
2037
2038
|
|
|
2039
|
+
#### Get Interactive Session Status
|
|
2040
|
+
|
|
2041
|
+
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.
|
|
2042
|
+
|
|
2043
|
+
**Basic Usage**
|
|
2044
|
+
|
|
2045
|
+
Get the status of a session:
|
|
2046
|
+
|
|
2047
|
+
```bash
|
|
2048
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile
|
|
2049
|
+
```
|
|
2050
|
+
|
|
2051
|
+
The command displays session information in a formatted table:
|
|
2052
|
+
|
|
2053
|
+
```console
|
|
2054
|
+
╔════════════════════╦═════════════════════════════════════════════════════╗
|
|
2055
|
+
║ Property ║ Value ║
|
|
2056
|
+
╠════════════════════╬═════════════════════════════════════════════════════╣
|
|
2057
|
+
║ Session ID ║ 69bc00cb1488084e5a6cae70 ║
|
|
2058
|
+
║ Name ║ analysis-dev (linked) ║
|
|
2059
|
+
║ Status ║ running ║
|
|
2060
|
+
║ Backend ║ awsJupyterNotebook ║
|
|
2061
|
+
║ Owner ║ John Doe ║
|
|
2062
|
+
║ Project ║ research ║
|
|
2063
|
+
║ Instance Type ║ c5.xlarge ║
|
|
2064
|
+
║ Storage ║ 50 GB ║
|
|
2065
|
+
║ Cost ║ $2.45/hour ║
|
|
2066
|
+
║ Runtime ║ 2h 15m 30s ║
|
|
2067
|
+
║ Created At ║ 2024-03-19 10:30:00 UTC ║
|
|
2068
|
+
║ Last Saved ║ 2024-03-19 12:30:00 UTC ║
|
|
2069
|
+
║ Auto-Shutdown At ║ 2024-03-19 18:30:00 UTC ║
|
|
2070
|
+
╚════════════════════╩═════════════════════════════════════════════════════╝
|
|
2071
|
+
```
|
|
2072
|
+
|
|
2073
|
+
**Watch Mode for Provisioning Sessions**
|
|
2074
|
+
|
|
2075
|
+
Use the `--watch` flag to continuously monitor a session's status as it provisions, with real-time status change notifications:
|
|
2076
|
+
|
|
2077
|
+
```bash
|
|
2078
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2079
|
+
```
|
|
2080
|
+
|
|
2081
|
+
Watch mode automatically tracks status changes and polls until the session reaches a terminal state:
|
|
2082
|
+
|
|
2083
|
+
```console
|
|
2084
|
+
Session 69bc00cb1488084e5a6cae70 currently is in initialising...
|
|
2085
|
+
Status changed: initialising → provisioning
|
|
2086
|
+
Status changed: provisioning → running
|
|
2087
|
+
✓ Session is now running and ready to use!
|
|
2088
|
+
```
|
|
2089
|
+
|
|
2090
|
+
**Watch Mode Behavior**
|
|
2091
|
+
|
|
2092
|
+
- **Pre-running sessions** (setup, initialising, scheduled): Watch mode will continuously poll and display status changes every 30 seconds (default)
|
|
2093
|
+
- **Running/stopped sessions**: Watch mode will show a warning and display the current status instead
|
|
2094
|
+
|
|
2095
|
+
Example with a running session:
|
|
2096
|
+
|
|
2097
|
+
```bash
|
|
2098
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2099
|
+
```
|
|
2100
|
+
|
|
2101
|
+
```console
|
|
2102
|
+
⚠ Warning: Watch mode only works for pre-running statuses (setup, initialising, scheduled). Current status: running. Showing session status instead.
|
|
2103
|
+
[session status table displayed]
|
|
2104
|
+
```
|
|
2105
|
+
|
|
2106
|
+
**Polling Interval**
|
|
2107
|
+
|
|
2108
|
+
Customize the polling interval for watch mode:
|
|
2109
|
+
|
|
2110
|
+
```bash
|
|
2111
|
+
# Poll every 15 seconds instead of default 30
|
|
2112
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --watch-interval 15
|
|
2113
|
+
```
|
|
2114
|
+
|
|
2115
|
+
**Watch Mode Timeout**
|
|
2116
|
+
|
|
2117
|
+
Set a maximum time to wait for the session to reach running state. The `--max-wait-time` option accepts human-friendly duration formats:
|
|
2118
|
+
|
|
2119
|
+
```bash
|
|
2120
|
+
# 30 minutes (default)
|
|
2121
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch
|
|
2122
|
+
|
|
2123
|
+
# 5 minutes
|
|
2124
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 5m
|
|
2125
|
+
|
|
2126
|
+
# 2 hours
|
|
2127
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 2h
|
|
2128
|
+
|
|
2129
|
+
# 1 day
|
|
2130
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 1d
|
|
2131
|
+
|
|
2132
|
+
# 60 seconds
|
|
2133
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --watch --max-wait-time 60s
|
|
2134
|
+
```
|
|
2135
|
+
|
|
2136
|
+
**Supported timeout formats:**
|
|
2137
|
+
- `30s` - seconds
|
|
2138
|
+
- `5m` - minutes
|
|
2139
|
+
- `2h` - hours
|
|
2140
|
+
- `1d` - days
|
|
2141
|
+
|
|
2142
|
+
If the session does not reach running state within the specified timeout, the watch mode exits with a clear message:
|
|
2143
|
+
|
|
2144
|
+
```console
|
|
2145
|
+
Timeout: Session did not reach running state within 30m. Current status: provisioning. Exiting watch mode.
|
|
2146
|
+
```
|
|
2147
|
+
|
|
2148
|
+
**Output Formats**
|
|
2149
|
+
|
|
2150
|
+
Save session status to a file:
|
|
2151
|
+
|
|
2152
|
+
```bash
|
|
2153
|
+
# Save as JSON
|
|
2154
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format json --output-basename /tmp/session_status
|
|
2155
|
+
# Creates: /tmp/session_status.json
|
|
2156
|
+
|
|
2157
|
+
# Save as CSV
|
|
2158
|
+
cloudos interactive-session status --session-id <SESSION_ID> --profile my_profile --output-format csv --output-basename /tmp/session_status
|
|
2159
|
+
# Creates: /tmp/session_status.csv
|
|
2160
|
+
```
|
|
2038
2161
|
|
|
2039
2162
|
#### Create Interactive Session
|
|
2040
2163
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.84.0'
|
|
@@ -2418,42 +2418,4 @@ class Cloudos:
|
|
|
2418
2418
|
content = r.json()
|
|
2419
2419
|
return content
|
|
2420
2420
|
|
|
2421
|
-
## FOR FUTURE COMMANDS IMPLEMENTATION
|
|
2422
|
-
# def get_interactive_session(self, team_id, session_id, verify=True):
|
|
2423
|
-
# """Get details of a specific interactive session.
|
|
2424
|
-
|
|
2425
|
-
# Parameters
|
|
2426
|
-
# ----------
|
|
2427
|
-
# team_id : string
|
|
2428
|
-
# The CloudOS team id (workspace id).
|
|
2429
|
-
# session_id : string
|
|
2430
|
-
# The interactive session id (MongoDB ObjectId).
|
|
2431
|
-
# verify: [bool|string], default=True
|
|
2432
|
-
# Whether to use SSL verification or not.
|
|
2433
|
-
|
|
2434
|
-
# Returns
|
|
2435
|
-
# -------
|
|
2436
|
-
# dict
|
|
2437
|
-
# Session object with current status and full details.
|
|
2438
|
-
# """
|
|
2439
|
-
# if not team_id or not isinstance(team_id, str):
|
|
2440
|
-
# raise ValueError("Invalid team_id: must be a non-empty string")
|
|
2441
|
-
|
|
2442
|
-
# if not session_id or not isinstance(session_id, str):
|
|
2443
|
-
# raise ValueError("Invalid session_id: must be a non-empty string")
|
|
2444
|
-
|
|
2445
|
-
# headers = {
|
|
2446
|
-
# "Content-type": "application/json",
|
|
2447
|
-
# "apikey": self.apikey
|
|
2448
|
-
# }
|
|
2449
|
-
|
|
2450
|
-
# # Build URL for getting specific session
|
|
2451
|
-
# url = f"{self.cloudos_url}/api/v2/interactive-sessions/{session_id}?teamId={team_id}"
|
|
2452
|
-
|
|
2453
|
-
# r = retry_requests_get(url, headers=headers, verify=verify)
|
|
2454
|
-
|
|
2455
|
-
# if r.status_code >= 400:
|
|
2456
|
-
# raise BadRequestException(r)
|
|
2457
2421
|
|
|
2458
|
-
# content = r.json()
|
|
2459
|
-
# return content
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import rich_click as click
|
|
4
4
|
import json
|
|
5
|
+
import time
|
|
5
6
|
from cloudos_cli.clos import Cloudos
|
|
6
7
|
from cloudos_cli.datasets import Datasets
|
|
7
8
|
from cloudos_cli.utils.errors import BadRequestException
|
|
@@ -11,16 +12,24 @@ from cloudos_cli.interactive_session.interactive_session import (
|
|
|
11
12
|
process_interactive_session_list,
|
|
12
13
|
save_interactive_session_list_to_csv,
|
|
13
14
|
parse_shutdown_duration,
|
|
15
|
+
parse_watch_timeout_duration,
|
|
14
16
|
parse_data_file,
|
|
15
17
|
parse_link_path,
|
|
16
18
|
build_session_payload,
|
|
17
19
|
format_session_creation_table,
|
|
18
20
|
resolve_data_file_id,
|
|
19
|
-
|
|
21
|
+
validate_session_id,
|
|
22
|
+
validate_instance_type,
|
|
23
|
+
get_interactive_session_status,
|
|
24
|
+
format_session_status_table,
|
|
25
|
+
transform_session_response,
|
|
26
|
+
export_session_status_json,
|
|
27
|
+
export_session_status_csv,
|
|
28
|
+
map_status,
|
|
29
|
+
PRE_RUNNING_STATUSES,
|
|
20
30
|
)
|
|
21
31
|
from cloudos_cli.configure.configure import with_profile_config, CLOUDOS_URL
|
|
22
32
|
from cloudos_cli.utils.cli_helpers import pass_debug_to_subcommands
|
|
23
|
-
from cloudos_cli.utils.requests import retry_requests_get
|
|
24
33
|
|
|
25
34
|
|
|
26
35
|
# Create the interactive_session group
|
|
@@ -602,6 +611,9 @@ def create_session(ctx,
|
|
|
602
611
|
s3_mounts=parsed_s3_mounts
|
|
603
612
|
)
|
|
604
613
|
|
|
614
|
+
# Output session link in greppable format for CI/automation
|
|
615
|
+
click.echo(f"Session link: {cloudos_url}/app/data-science/interactive-analysis/view/{session_id}")
|
|
616
|
+
|
|
605
617
|
if verbose:
|
|
606
618
|
print('\tSession creation completed successfully!')
|
|
607
619
|
|
|
@@ -623,3 +635,228 @@ def create_session(ctx,
|
|
|
623
635
|
else:
|
|
624
636
|
click.secho(f'Error: {str(e)}', fg='red', err=True)
|
|
625
637
|
raise SystemExit(1)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
|
|
641
|
+
@interactive_session.command('status')
|
|
642
|
+
@click.option('-k',
|
|
643
|
+
'--apikey',
|
|
644
|
+
help='Your CloudOS API key',
|
|
645
|
+
required=False)
|
|
646
|
+
@click.option('-c',
|
|
647
|
+
'--cloudos-url',
|
|
648
|
+
help=(f'The CloudOS url you are trying to access to. Default={CLOUDOS_URL}.'),
|
|
649
|
+
default=CLOUDOS_URL,
|
|
650
|
+
required=False)
|
|
651
|
+
@click.option('--session-id',
|
|
652
|
+
help='The session ID to retrieve status for (24-character hex string).',
|
|
653
|
+
required=True)
|
|
654
|
+
@click.option('--workspace-id',
|
|
655
|
+
help='The specific CloudOS workspace id.',
|
|
656
|
+
required=False)
|
|
657
|
+
@click.option('--output-format',
|
|
658
|
+
help='Output format for session status.',
|
|
659
|
+
type=click.Choice(['stdout', 'csv', 'json'], case_sensitive=False),
|
|
660
|
+
default='stdout')
|
|
661
|
+
@click.option('--output-basename',
|
|
662
|
+
help=('Output file base name to save session status. ' +
|
|
663
|
+
'Default=interactive_session_status'),
|
|
664
|
+
default='interactive_session_status',
|
|
665
|
+
required=False)
|
|
666
|
+
@click.option('--watch',
|
|
667
|
+
is_flag=True,
|
|
668
|
+
help='Continuously poll status until session reaches running state (only for pre-running statuses).')
|
|
669
|
+
@click.option('--watch-interval',
|
|
670
|
+
type=int,
|
|
671
|
+
default=30,
|
|
672
|
+
help='Poll interval in seconds when using --watch. Default=30.')
|
|
673
|
+
@click.option('--max-wait-time',
|
|
674
|
+
type=str,
|
|
675
|
+
default='30m',
|
|
676
|
+
help='Maximum time to wait for session in watch mode. Accepts formats: 30s, 5m, 2h, 1d. Default=30m (30 minutes).')
|
|
677
|
+
@click.option('--verbose',
|
|
678
|
+
help='Whether to print information messages or not.',
|
|
679
|
+
is_flag=True)
|
|
680
|
+
@click.option('--disable-ssl-verification',
|
|
681
|
+
help=('Disable SSL certificate verification. Please, remember that this option is ' +
|
|
682
|
+
'not generally recommended for security reasons.'),
|
|
683
|
+
is_flag=True)
|
|
684
|
+
@click.option('--ssl-cert',
|
|
685
|
+
help='Path to your SSL certificate file.')
|
|
686
|
+
@click.option('--profile', help='Profile to use from the config file', default=None)
|
|
687
|
+
@click.pass_context
|
|
688
|
+
@with_profile_config(required_params=['apikey', 'workspace_id'])
|
|
689
|
+
def get_session_status(ctx,
|
|
690
|
+
apikey,
|
|
691
|
+
cloudos_url,
|
|
692
|
+
session_id,
|
|
693
|
+
workspace_id,
|
|
694
|
+
output_format,
|
|
695
|
+
output_basename,
|
|
696
|
+
watch,
|
|
697
|
+
watch_interval,
|
|
698
|
+
max_wait_time,
|
|
699
|
+
verbose,
|
|
700
|
+
disable_ssl_verification,
|
|
701
|
+
ssl_cert,
|
|
702
|
+
profile):
|
|
703
|
+
"""Get status of an interactive session."""
|
|
704
|
+
|
|
705
|
+
verify_ssl = ssl_selector(disable_ssl_verification, ssl_cert)
|
|
706
|
+
|
|
707
|
+
# Validate session ID format
|
|
708
|
+
if not validate_session_id(session_id):
|
|
709
|
+
click.secho(f'Error: Invalid session ID format. Expected 24-character hex string, got: {session_id}', fg='red', err=True)
|
|
710
|
+
raise SystemExit(1)
|
|
711
|
+
|
|
712
|
+
# Validate watch-interval
|
|
713
|
+
if watch_interval <= 0:
|
|
714
|
+
click.secho(f'Error: --watch-interval must be a positive number, got: {watch_interval}', fg='red', err=True)
|
|
715
|
+
raise SystemExit(1)
|
|
716
|
+
|
|
717
|
+
# Parse and validate max-wait-time
|
|
718
|
+
try:
|
|
719
|
+
max_wait_time_seconds = parse_watch_timeout_duration(max_wait_time)
|
|
720
|
+
except ValueError as e:
|
|
721
|
+
click.secho(f'Error: Invalid --max-wait-time format: {str(e)}', fg='red', err=True)
|
|
722
|
+
raise SystemExit(1)
|
|
723
|
+
|
|
724
|
+
# Validate output format
|
|
725
|
+
if output_format.lower() not in ['stdout', 'csv', 'json']:
|
|
726
|
+
click.secho(f'Error: Invalid output format. Must be one of: stdout, csv, json', fg='red', err=True)
|
|
727
|
+
raise SystemExit(1)
|
|
728
|
+
|
|
729
|
+
if verbose:
|
|
730
|
+
print('Executable: get interactive session status...')
|
|
731
|
+
print('\t...Preparing objects')
|
|
732
|
+
|
|
733
|
+
try:
|
|
734
|
+
# Get initial status
|
|
735
|
+
if verbose:
|
|
736
|
+
print(f'\tRetrieving session status from: {cloudos_url}')
|
|
737
|
+
|
|
738
|
+
session_response = get_interactive_session_status(
|
|
739
|
+
cloudos_url=cloudos_url,
|
|
740
|
+
apikey=apikey,
|
|
741
|
+
session_id=session_id,
|
|
742
|
+
team_id=workspace_id,
|
|
743
|
+
verify_ssl=verify_ssl,
|
|
744
|
+
verbose=verbose
|
|
745
|
+
)
|
|
746
|
+
|
|
747
|
+
if verbose:
|
|
748
|
+
print(f'\t✓ Session retrieved successfully')
|
|
749
|
+
|
|
750
|
+
# Get mapped status for display
|
|
751
|
+
api_status = session_response.get('status', '')
|
|
752
|
+
display_status = map_status(api_status)
|
|
753
|
+
|
|
754
|
+
# Apply watch mode if requested
|
|
755
|
+
if watch:
|
|
756
|
+
# Check if watch mode is appropriate for this session status
|
|
757
|
+
if display_status not in PRE_RUNNING_STATUSES:
|
|
758
|
+
click.secho(
|
|
759
|
+
f'⚠ Warning: Watch mode only works for pre-running statuses (setup, initialising, scheduled). '
|
|
760
|
+
f'Current status: {display_status}. Showing session status instead.',
|
|
761
|
+
fg='yellow',
|
|
762
|
+
err=True
|
|
763
|
+
)
|
|
764
|
+
else:
|
|
765
|
+
# Print initial status message before starting watch
|
|
766
|
+
click.echo(f'Session {session_id} currently is in {display_status}...')
|
|
767
|
+
|
|
768
|
+
start_time = time.time()
|
|
769
|
+
previous_status = display_status # Track previous status to detect changes
|
|
770
|
+
|
|
771
|
+
while True:
|
|
772
|
+
# Get current status
|
|
773
|
+
api_status = session_response.get('status', '')
|
|
774
|
+
display_status = map_status(api_status)
|
|
775
|
+
|
|
776
|
+
elapsed = time.time() - start_time
|
|
777
|
+
|
|
778
|
+
if verbose:
|
|
779
|
+
print(f'\tPolling... Status: {display_status} | Elapsed: {int(elapsed)}s')
|
|
780
|
+
|
|
781
|
+
# Print status change message
|
|
782
|
+
if display_status != previous_status:
|
|
783
|
+
click.echo(f'Status changed: {previous_status} → {display_status}')
|
|
784
|
+
previous_status = display_status
|
|
785
|
+
|
|
786
|
+
# Exit watch mode if session is ready or terminated
|
|
787
|
+
if display_status == 'running':
|
|
788
|
+
click.secho('✓ Session is now running and ready to use!', fg='green')
|
|
789
|
+
break
|
|
790
|
+
elif display_status in ['stopped', 'terminated']:
|
|
791
|
+
click.secho(f'⚠ Session reached terminal state: {display_status}', fg='yellow')
|
|
792
|
+
break
|
|
793
|
+
|
|
794
|
+
# Check timeout AFTER evaluating current status
|
|
795
|
+
if elapsed > max_wait_time_seconds:
|
|
796
|
+
click.secho(
|
|
797
|
+
f'Timeout: Session did not reach running state within {max_wait_time}. '
|
|
798
|
+
f'Current status: {display_status}. Exiting watch mode.',
|
|
799
|
+
fg='red',
|
|
800
|
+
err=True
|
|
801
|
+
)
|
|
802
|
+
break
|
|
803
|
+
|
|
804
|
+
# Wait before next poll
|
|
805
|
+
time.sleep(watch_interval)
|
|
806
|
+
|
|
807
|
+
# Fetch updated status for next iteration
|
|
808
|
+
session_response = get_interactive_session_status(
|
|
809
|
+
cloudos_url=cloudos_url,
|
|
810
|
+
apikey=apikey,
|
|
811
|
+
session_id=session_id,
|
|
812
|
+
team_id=workspace_id,
|
|
813
|
+
verify_ssl=verify_ssl,
|
|
814
|
+
verbose=False
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
# Transform and display response based on format
|
|
818
|
+
if output_format.lower() == 'json':
|
|
819
|
+
json_output = export_session_status_json(session_response)
|
|
820
|
+
outfile = f"{output_basename}.json"
|
|
821
|
+
with open(outfile, 'w') as f:
|
|
822
|
+
f.write(json_output)
|
|
823
|
+
click.echo(f'Session status saved to {outfile}')
|
|
824
|
+
|
|
825
|
+
elif output_format.lower() == 'csv':
|
|
826
|
+
transformed_data = transform_session_response(session_response)
|
|
827
|
+
csv_output = export_session_status_csv(transformed_data)
|
|
828
|
+
outfile = f"{output_basename}.csv"
|
|
829
|
+
with open(outfile, 'w') as f:
|
|
830
|
+
f.write(csv_output)
|
|
831
|
+
click.echo(f'Session status saved to {outfile}')
|
|
832
|
+
|
|
833
|
+
else: # stdout (default)
|
|
834
|
+
transformed_data = transform_session_response(session_response)
|
|
835
|
+
format_session_status_table(transformed_data, cloudos_url=cloudos_url)
|
|
836
|
+
|
|
837
|
+
except ValueError as e:
|
|
838
|
+
# Handle validation errors (e.g., session not found)
|
|
839
|
+
click.secho(f'Error: {str(e)}', fg='red', err=True)
|
|
840
|
+
raise SystemExit(1)
|
|
841
|
+
|
|
842
|
+
except PermissionError as e:
|
|
843
|
+
# Handle authentication/permission errors
|
|
844
|
+
click.secho(f'Error: {str(e)}', fg='red', err=True)
|
|
845
|
+
if '401' in str(e) or 'Unauthorized' in str(e):
|
|
846
|
+
click.secho('Please check your API credentials (apikey and cloudos-url).', fg='yellow', err=True)
|
|
847
|
+
raise SystemExit(1)
|
|
848
|
+
|
|
849
|
+
except KeyboardInterrupt:
|
|
850
|
+
click.secho('\n⚠ Watch mode interrupted by user.', fg='yellow', err=True)
|
|
851
|
+
raise SystemExit(0)
|
|
852
|
+
|
|
853
|
+
except Exception as e:
|
|
854
|
+
error_str = str(e)
|
|
855
|
+
# Check for network errors
|
|
856
|
+
if 'Failed to resolve' in error_str or 'Name or service not known' in error_str:
|
|
857
|
+
click.secho(f'Error: Unable to connect to CloudOS. Please verify the CloudOS URL is correct.', fg='red', err=True)
|
|
858
|
+
elif '401' in error_str or 'Unauthorized' in error_str:
|
|
859
|
+
click.secho(f'Error: Failed to retrieve session status. Please check your credentials.', fg='red', err=True)
|
|
860
|
+
else:
|
|
861
|
+
click.secho(f'Error: Failed to retrieve session status: {str(e)}', fg='red', err=True)
|
|
862
|
+
raise SystemExit(1)
|