isabl-cli 2.0.1__tar.gz → 2.0.3__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.
Files changed (55) hide show
  1. isabl_cli-2.0.3/PKG-INFO +230 -0
  2. isabl_cli-2.0.3/README.md +180 -0
  3. isabl_cli-2.0.3/isabl_cli/VERSION +1 -0
  4. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/__init__.py +1 -0
  5. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/api.py +58 -2
  6. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/app.py +20 -4
  7. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/data.py +1 -1
  8. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/exceptions.py +7 -0
  9. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/settings.py +5 -2
  10. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/utils.py +33 -8
  11. isabl_cli-2.0.3/isabl_cli.egg-info/PKG-INFO +230 -0
  12. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli.egg-info/SOURCES.txt +0 -1
  13. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli.egg-info/requires.txt +1 -1
  14. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/setup.py +1 -1
  15. isabl_cli-2.0.3/tests/conftest.py +65 -0
  16. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_api.py +87 -1
  17. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_app.py +8 -1
  18. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_commands.py +19 -0
  19. isabl_cli-2.0.1/PKG-INFO +0 -120
  20. isabl_cli-2.0.1/README.md +0 -70
  21. isabl_cli-2.0.1/isabl_cli/VERSION +0 -1
  22. isabl_cli-2.0.1/isabl_cli.egg-info/PKG-INFO +0 -120
  23. isabl_cli-2.0.1/setup.json +0 -0
  24. isabl_cli-2.0.1/tests/conftest.py +0 -26
  25. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/LICENSE.md +0 -0
  26. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/MANIFEST.in +0 -0
  27. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/__main__.py +0 -0
  28. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/batch_systems/__init__.py +0 -0
  29. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/batch_systems/local.py +0 -0
  30. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/batch_systems/lsf.py +0 -0
  31. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/batch_systems/sge.py +0 -0
  32. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/batch_systems/slurm.py +0 -0
  33. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/cli.py +0 -0
  34. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/commands.py +0 -0
  35. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/data/README.md +0 -0
  36. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/factories.py +0 -0
  37. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/options.py +0 -0
  38. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/signals.py +0 -0
  39. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/test/__init__.py +0 -0
  40. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/test/utils.py +0 -0
  41. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli/validators.py +0 -0
  42. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli.egg-info/dependency_links.txt +0 -0
  43. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli.egg-info/entry_points.txt +0 -0
  44. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/isabl_cli.egg-info/top_level.txt +0 -0
  45. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/setup.cfg +0 -0
  46. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/__init__.py +0 -0
  47. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_batch_systems.py +0 -0
  48. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_cli.py +0 -0
  49. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_data.py +0 -0
  50. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_options.py +0 -0
  51. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_signals.py +0 -0
  52. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_testutils.py +0 -0
  53. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_utils.py +0 -0
  54. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_validators.py +0 -0
  55. {isabl_cli-2.0.1 → isabl_cli-2.0.3}/tests/test_version.py +0 -0
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: isabl-cli
3
+ Version: 2.0.3
4
+ Summary: isabl_cli command line client.
5
+ Home-page: https://github.com/papaemmelab/isabl_cli
6
+ Author: Juan S. Medina
7
+ License: BSD
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: Unix
13
+ Classifier: Operating System :: POSIX
14
+ Classifier: Topic :: Utilities
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.md
17
+ Requires-Dist: analytics-python>=1.4.0
18
+ Requires-Dist: cached_property>=1.4.2
19
+ Requires-Dist: Click>=7.0.0
20
+ Requires-Dist: munch>=2.3.2
21
+ Requires-Dist: python-slugify>=1.1.2
22
+ Requires-Dist: pytz>=2018.4
23
+ Requires-Dist: PyYAML>=5.3
24
+ Requires-Dist: requests>=2.19.1
25
+ Requires-Dist: six>=1.11.0
26
+ Requires-Dist: packaging>=21.0
27
+ Provides-Extra: test
28
+ Requires-Dist: black>=18.9b0; extra == "test"
29
+ Requires-Dist: coverage>=4.4.2; extra == "test"
30
+ Requires-Dist: factory-boy>=2.11.1; extra == "test"
31
+ Requires-Dist: ipdb>=0.11; extra == "test"
32
+ Requires-Dist: pluggy>=0.7.1; extra == "test"
33
+ Requires-Dist: pydocstyle>=2.1.1; extra == "test"
34
+ Requires-Dist: pylint>=1.8.1; extra == "test"
35
+ Requires-Dist: pytest>=4.5; extra == "test"
36
+ Requires-Dist: pytest-cov>=2.5.1; extra == "test"
37
+ Requires-Dist: pytest-env>=0.6.2; extra == "test"
38
+ Requires-Dist: pytest-sugar==0.9.1; extra == "test"
39
+ Requires-Dist: tox>=2.9.1; extra == "test"
40
+ Dynamic: author
41
+ Dynamic: classifier
42
+ Dynamic: description
43
+ Dynamic: description-content-type
44
+ Dynamic: home-page
45
+ Dynamic: license
46
+ Dynamic: license-file
47
+ Dynamic: provides-extra
48
+ Dynamic: requires-dist
49
+ Dynamic: summary
50
+
51
+ # Isabl CLI
52
+
53
+ [![Run Isabl CLI tests][gh_actions_badge]][gh_actions_base]
54
+ [![pypi badge][pypi_badge]][pypi_base]
55
+ [![codecov badge][codecov_badge]][codecov_base]
56
+ [![code formatting][black_badge]][black_base]
57
+ [![MCP][mcp_badge]][mcp_base]
58
+
59
+ > **_Terms of Use: Academic Research_**
60
+
61
+ > [!TIP]
62
+ > Talk to your genomics data with AI. Try the [Isabl MCP Server](https://github.com/juanesarango/isabl-mcp) with Claude Code, Cursor, or your favorite agentic tool.
63
+
64
+ `isabl_cli` is a command line client and SDK for the Isabl Platform infrastructure.
65
+
66
+ ## 🧬 Isabl Platform
67
+
68
+ - Isabl is a platform for the integration, management, and processing of individual-centric multimodal data. Welcome to the Isabl Documentation!
69
+
70
+ - Isabl is a plug-and-play data science framework designed to support the processing of multimodal patient-centric data. Have questions? Ask here.
71
+
72
+ - Isabl has been developed by the [Elli Papaemmanuil's Lab](https://papaemmelab.org) at [Memorial Sloan Kettering Cancer Center](https://www.mskcc.org/research/ski), and it's currently used by multiple scientific groups and contributors.
73
+
74
+ - Learn more: [Isabl documentation][documentation].
75
+
76
+ ## 📓 Publication
77
+
78
+ >Medina-Martínez, J.S., Arango-Ossa, J.E., Levine, M.F. et al. Isabl Platform, a digital biobank for processing multimodal patient data. BMC Bioinformatics 21, 549 (2020).
79
+
80
+ <https://doi.org/10.1186/s12859-020-03879-7>
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ pip install isabl_cli
86
+ ```
87
+
88
+ ## Development Setup
89
+
90
+ ### Prerequisites
91
+
92
+ - Python 3.6 or higher
93
+ - Docker and Docker Compose (for running integration tests)
94
+ - Git (for cloning the API repository during tests)
95
+
96
+ ### Setup Steps
97
+
98
+ 1. Clone the repository:
99
+
100
+ ```bash
101
+ git clone https://github.com/papaemmelab/isabl_cli.git
102
+ cd isabl_cli
103
+ ```
104
+
105
+ 2. Install the package in editable mode with test dependencies:
106
+
107
+ ```bash
108
+ pip install -e .[test]
109
+ ```
110
+
111
+ This installs the package in development mode along with all testing dependencies (pytest, coverage, black, etc.).
112
+
113
+ 3. Verify the installation:
114
+
115
+ ```bash
116
+ isabl --help
117
+ ```
118
+
119
+ ## Testing
120
+
121
+ The test suite can be run in two ways:
122
+
123
+ ### Running Tests via Script (Recommended)
124
+
125
+ The test script (`./tests/test-with-compose.sh`) automatically clones the `isabl_api` repository, starts the API and database through Docker containers, then executes the test suite using pytest with coverage reporting.
126
+
127
+ Run the full test suite:
128
+
129
+ ```bash
130
+ ./tests/test-with-compose.sh
131
+ ```
132
+
133
+ To skip the build step (faster for subsequent runs):
134
+
135
+ ```bash
136
+ ./tests/test-with-compose.sh --skip-build
137
+ ```
138
+
139
+ **Note**: The test script requires the API to be running. It will clone the `isabl_api` repository into a sibling `api` directory if it doesn't exist.
140
+
141
+ ### Running Tests Directly
142
+
143
+ The tests create, change and delete records and replace client settings, so only run them against a throwaway local API that you started for them. Three things stop them reaching any other API, whatever ISABL_API_URL your shell exports:
144
+
145
+ - pytest.ini sets ISABL_API_URL to http://localhost:8000/api/v1/.
146
+ - tests/conftest.py refuses to start, and refuses each test, if the URL isn't localhost.
147
+ - isabl_cli itself refuses to write to any API other than localhost while pytest is loaded. This applies to every test suite that uses isabl_cli, not only this one.
148
+
149
+ To run the tests against a disposable remote test server, change ISABL_API_URL in pytest.ini and set ISABL_ALLOW_TEST_WRITES_TO to the server's URL.
150
+
151
+ If you have a local Isabl API instance running (e.g., via `docker compose up -d` in the `isabl_api` repository), you can run pytest commands directly:
152
+
153
+ ```bash
154
+ # Set required environment variables
155
+ export ISABL_CLIENT_ID=test-cli-client
156
+ export ISABL_API_URL=http://localhost:8000/api/v1/
157
+
158
+ # Run tests with coverage
159
+ pytest --cov=isabl_cli tests/
160
+ ```
161
+
162
+ This allows for faster iteration during development without rebuilding containers.
163
+
164
+ ### Running Specific Tests
165
+
166
+ You can run specific test files or test functions:
167
+
168
+ ```bash
169
+ # Run a specific test file
170
+ pytest tests/test_api.py
171
+
172
+ # Run a specific test function
173
+ pytest tests/test_api.py::test_function_name
174
+
175
+ # Run with verbose output
176
+ pytest -v tests/
177
+ ```
178
+
179
+ ## Usage
180
+
181
+ ```bash
182
+ # Set up your environment variables
183
+ export ISABL_API_URL="http://<your-isabl-instance>/api/v1/"
184
+ export CLIENT_ID="<your-client-id>"
185
+
186
+ # Authenticate and cache credentials
187
+ isabl login
188
+
189
+ # See all available commands
190
+ isabl --help
191
+ ```
192
+
193
+ ## CI/CD Setup
194
+
195
+ The GitHub Actions workflow requires the following secrets to be configured in the repository settings:
196
+
197
+ ### Required Secrets
198
+
199
+ - **`GH_PAT`**: GitHub Personal Access Token for authenticating with GitHub (used to clone the `isabl_api` repository during tests)
200
+ - **`DOCKER_USERNAME`**: Docker Hub username for the [papaemmelab organization](https://hub.docker.com/orgs/papaemmelab/repositories)
201
+ - **`DOCKER_PASSWORD`**: Docker Hub password or access token for the [papaemmelab organization](https://hub.docker.com/orgs/papaemmelab/repositories)
202
+ - **`CODECOV_TOKEN`**: Codecov token for the [papaemmelab/isabl_cli repository](https://app.codecov.io/gh/papaemmelab/isabl_cli)
203
+
204
+ Configure these secrets in your GitHub repository under **Settings → Secrets and variables → Actions**.
205
+
206
+ ## Contributing
207
+
208
+ Contributions are welcome and greatly appreciated, check our [contributing guidelines]!
209
+
210
+ ## License
211
+
212
+ isabl is free for academic and research use. For commercial use, please contact us.
213
+
214
+ ## Credits
215
+
216
+ Isabl was created at [Elli Papaemmanuil's lab].
217
+
218
+ [documentation]: https://docs.isabl.io
219
+ [contributing guidelines]: https://docs.isabl.io/contributing-guide
220
+ [elli papaemmanuil's lab]: https://www.mskcc.org/research-areas/labs/elli-papaemmanuil
221
+ [black_badge]: https://img.shields.io/badge/code%20style-black-000000.svg
222
+ [black_base]: https://github.com/ambv/black
223
+ [codecov_badge]: https://codecov.io/github/papaemmelab/isabl_cli/graph/badge.svg?token=ODJ8DU73PH
224
+ [codecov_base]: https://codecov.io/github/papaemmelab/isabl_cli
225
+ [pypi_badge]: https://img.shields.io/pypi/v/isabl_cli.svg
226
+ [pypi_base]: https://pypi.python.org/pypi/isabl_cli
227
+ [gh_actions_badge]: https://github.com/papaemmelab/isabl_cli/actions/workflows/run-test.yaml/badge.svg
228
+ [gh_actions_base]: https://github.com/papaemmelab/isabl_cli/actions/workflows/run-test.yaml
229
+ [mcp_badge]: https://img.shields.io/badge/MCP-compatible-blue
230
+ [mcp_base]: https://github.com/juanesarango/isabl-mcp
@@ -0,0 +1,180 @@
1
+ # Isabl CLI
2
+
3
+ [![Run Isabl CLI tests][gh_actions_badge]][gh_actions_base]
4
+ [![pypi badge][pypi_badge]][pypi_base]
5
+ [![codecov badge][codecov_badge]][codecov_base]
6
+ [![code formatting][black_badge]][black_base]
7
+ [![MCP][mcp_badge]][mcp_base]
8
+
9
+ > **_Terms of Use: Academic Research_**
10
+
11
+ > [!TIP]
12
+ > Talk to your genomics data with AI. Try the [Isabl MCP Server](https://github.com/juanesarango/isabl-mcp) with Claude Code, Cursor, or your favorite agentic tool.
13
+
14
+ `isabl_cli` is a command line client and SDK for the Isabl Platform infrastructure.
15
+
16
+ ## 🧬 Isabl Platform
17
+
18
+ - Isabl is a platform for the integration, management, and processing of individual-centric multimodal data. Welcome to the Isabl Documentation!
19
+
20
+ - Isabl is a plug-and-play data science framework designed to support the processing of multimodal patient-centric data. Have questions? Ask here.
21
+
22
+ - Isabl has been developed by the [Elli Papaemmanuil's Lab](https://papaemmelab.org) at [Memorial Sloan Kettering Cancer Center](https://www.mskcc.org/research/ski), and it's currently used by multiple scientific groups and contributors.
23
+
24
+ - Learn more: [Isabl documentation][documentation].
25
+
26
+ ## 📓 Publication
27
+
28
+ >Medina-Martínez, J.S., Arango-Ossa, J.E., Levine, M.F. et al. Isabl Platform, a digital biobank for processing multimodal patient data. BMC Bioinformatics 21, 549 (2020).
29
+
30
+ <https://doi.org/10.1186/s12859-020-03879-7>
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install isabl_cli
36
+ ```
37
+
38
+ ## Development Setup
39
+
40
+ ### Prerequisites
41
+
42
+ - Python 3.6 or higher
43
+ - Docker and Docker Compose (for running integration tests)
44
+ - Git (for cloning the API repository during tests)
45
+
46
+ ### Setup Steps
47
+
48
+ 1. Clone the repository:
49
+
50
+ ```bash
51
+ git clone https://github.com/papaemmelab/isabl_cli.git
52
+ cd isabl_cli
53
+ ```
54
+
55
+ 2. Install the package in editable mode with test dependencies:
56
+
57
+ ```bash
58
+ pip install -e .[test]
59
+ ```
60
+
61
+ This installs the package in development mode along with all testing dependencies (pytest, coverage, black, etc.).
62
+
63
+ 3. Verify the installation:
64
+
65
+ ```bash
66
+ isabl --help
67
+ ```
68
+
69
+ ## Testing
70
+
71
+ The test suite can be run in two ways:
72
+
73
+ ### Running Tests via Script (Recommended)
74
+
75
+ The test script (`./tests/test-with-compose.sh`) automatically clones the `isabl_api` repository, starts the API and database through Docker containers, then executes the test suite using pytest with coverage reporting.
76
+
77
+ Run the full test suite:
78
+
79
+ ```bash
80
+ ./tests/test-with-compose.sh
81
+ ```
82
+
83
+ To skip the build step (faster for subsequent runs):
84
+
85
+ ```bash
86
+ ./tests/test-with-compose.sh --skip-build
87
+ ```
88
+
89
+ **Note**: The test script requires the API to be running. It will clone the `isabl_api` repository into a sibling `api` directory if it doesn't exist.
90
+
91
+ ### Running Tests Directly
92
+
93
+ The tests create, change and delete records and replace client settings, so only run them against a throwaway local API that you started for them. Three things stop them reaching any other API, whatever ISABL_API_URL your shell exports:
94
+
95
+ - pytest.ini sets ISABL_API_URL to http://localhost:8000/api/v1/.
96
+ - tests/conftest.py refuses to start, and refuses each test, if the URL isn't localhost.
97
+ - isabl_cli itself refuses to write to any API other than localhost while pytest is loaded. This applies to every test suite that uses isabl_cli, not only this one.
98
+
99
+ To run the tests against a disposable remote test server, change ISABL_API_URL in pytest.ini and set ISABL_ALLOW_TEST_WRITES_TO to the server's URL.
100
+
101
+ If you have a local Isabl API instance running (e.g., via `docker compose up -d` in the `isabl_api` repository), you can run pytest commands directly:
102
+
103
+ ```bash
104
+ # Set required environment variables
105
+ export ISABL_CLIENT_ID=test-cli-client
106
+ export ISABL_API_URL=http://localhost:8000/api/v1/
107
+
108
+ # Run tests with coverage
109
+ pytest --cov=isabl_cli tests/
110
+ ```
111
+
112
+ This allows for faster iteration during development without rebuilding containers.
113
+
114
+ ### Running Specific Tests
115
+
116
+ You can run specific test files or test functions:
117
+
118
+ ```bash
119
+ # Run a specific test file
120
+ pytest tests/test_api.py
121
+
122
+ # Run a specific test function
123
+ pytest tests/test_api.py::test_function_name
124
+
125
+ # Run with verbose output
126
+ pytest -v tests/
127
+ ```
128
+
129
+ ## Usage
130
+
131
+ ```bash
132
+ # Set up your environment variables
133
+ export ISABL_API_URL="http://<your-isabl-instance>/api/v1/"
134
+ export CLIENT_ID="<your-client-id>"
135
+
136
+ # Authenticate and cache credentials
137
+ isabl login
138
+
139
+ # See all available commands
140
+ isabl --help
141
+ ```
142
+
143
+ ## CI/CD Setup
144
+
145
+ The GitHub Actions workflow requires the following secrets to be configured in the repository settings:
146
+
147
+ ### Required Secrets
148
+
149
+ - **`GH_PAT`**: GitHub Personal Access Token for authenticating with GitHub (used to clone the `isabl_api` repository during tests)
150
+ - **`DOCKER_USERNAME`**: Docker Hub username for the [papaemmelab organization](https://hub.docker.com/orgs/papaemmelab/repositories)
151
+ - **`DOCKER_PASSWORD`**: Docker Hub password or access token for the [papaemmelab organization](https://hub.docker.com/orgs/papaemmelab/repositories)
152
+ - **`CODECOV_TOKEN`**: Codecov token for the [papaemmelab/isabl_cli repository](https://app.codecov.io/gh/papaemmelab/isabl_cli)
153
+
154
+ Configure these secrets in your GitHub repository under **Settings → Secrets and variables → Actions**.
155
+
156
+ ## Contributing
157
+
158
+ Contributions are welcome and greatly appreciated, check our [contributing guidelines]!
159
+
160
+ ## License
161
+
162
+ isabl is free for academic and research use. For commercial use, please contact us.
163
+
164
+ ## Credits
165
+
166
+ Isabl was created at [Elli Papaemmanuil's lab].
167
+
168
+ [documentation]: https://docs.isabl.io
169
+ [contributing guidelines]: https://docs.isabl.io/contributing-guide
170
+ [elli papaemmanuil's lab]: https://www.mskcc.org/research-areas/labs/elli-papaemmanuil
171
+ [black_badge]: https://img.shields.io/badge/code%20style-black-000000.svg
172
+ [black_base]: https://github.com/ambv/black
173
+ [codecov_badge]: https://codecov.io/github/papaemmelab/isabl_cli/graph/badge.svg?token=ODJ8DU73PH
174
+ [codecov_base]: https://codecov.io/github/papaemmelab/isabl_cli
175
+ [pypi_badge]: https://img.shields.io/pypi/v/isabl_cli.svg
176
+ [pypi_base]: https://pypi.python.org/pypi/isabl_cli
177
+ [gh_actions_badge]: https://github.com/papaemmelab/isabl_cli/actions/workflows/run-test.yaml/badge.svg
178
+ [gh_actions_base]: https://github.com/papaemmelab/isabl_cli/actions/workflows/run-test.yaml
179
+ [mcp_badge]: https://img.shields.io/badge/MCP-compatible-blue
180
+ [mcp_base]: https://github.com/juanesarango/isabl-mcp
@@ -0,0 +1 @@
1
+ 2.0.3
@@ -8,6 +8,7 @@ from isabl_cli.api import Analysis
8
8
  from isabl_cli.api import Assembly
9
9
  from isabl_cli.api import Experiment
10
10
  from isabl_cli.api import create_instance
11
+ from isabl_cli.api import delete_instance
11
12
  from isabl_cli.api import get_analyses
12
13
  from isabl_cli.api import get_experiments
13
14
  from isabl_cli.api import get_instance
@@ -194,8 +194,64 @@ def get_api_url(url):
194
194
  return url
195
195
 
196
196
 
197
+ CLI_VERSION_HEADER = "X-Isabl-CLI-Version"
198
+
199
+
200
+ @lru_cache(None)
201
+ def get_cli_headers():
202
+ """Get headers that identify this isabl_cli version to the API."""
203
+ from isabl_cli import __version__ # avoid circular import
204
+
205
+ return {
206
+ CLI_VERSION_HEADER: __version__,
207
+ "User-Agent": f"isabl_cli/{__version__} {requests.utils.default_user_agent()}",
208
+ }
209
+
210
+
211
+ # Test suites create, change and delete records and replace client settings, so a
212
+ # test session only writes to a local API. Set this variable to the URL of an API
213
+ # that is safe to write to from tests, e.g. a disposable remote test server.
214
+ LOCAL_API_HOSTS = frozenset({"localhost", "127.0.0.1", "::1"})
215
+ TEST_WRITES_URL_VARIABLE = "ISABL_ALLOW_TEST_WRITES_TO"
216
+ WRITE_METHODS = frozenset({"post", "put", "patch", "delete"})
217
+
218
+
219
+ def check_test_session_write(method, url):
220
+ """
221
+ Refuse a write from a test session to an API that isn't local.
222
+
223
+ A test session is any process that imported pytest, the same check
224
+ `get_token_headers` uses to log in as the test admin.
225
+
226
+ Raises:
227
+ exceptions.TestSessionWriteError: if the write must not be sent.
228
+ """
229
+ if method.lower() not in WRITE_METHODS or "pytest" not in sys.modules:
230
+ return
231
+
232
+ if urlparse(url).hostname in LOCAL_API_HOSTS:
233
+ return
234
+
235
+ allowed = environ.get(TEST_WRITES_URL_VARIABLE)
236
+ if allowed and url.startswith(allowed):
237
+ return
238
+
239
+ raise exceptions.TestSessionWriteError(
240
+ f"Refusing to {method.upper()} {url} from a test session: tests create, "
241
+ "change and delete records, so they only write to a local Isabl API. Point "
242
+ "ISABL_API_URL at a local test API (e.g. http://localhost:8000/api/v1/), or "
243
+ f"set {TEST_WRITES_URL_VARIABLE} to this API's URL if it is a disposable "
244
+ "test server."
245
+ )
246
+
247
+
197
248
  def retry_request(method, **kwargs):
198
249
  """Retry request operation multiple times."""
250
+ check_test_session_write(method, kwargs.get("url", ""))
251
+
252
+ # build a new dict so cached headers (e.g. get_token_headers) aren't mutated
253
+ kwargs["headers"] = {**get_cli_headers(), **(kwargs.get("headers") or {})}
254
+
199
255
  for i in [0.2, 1, 5, 10, 60, 90, 120, 300, 900]: # attempt some retries
200
256
  try:
201
257
  error = None
@@ -628,13 +684,13 @@ def patch_analysis_status(analysis, status):
628
684
  analysis["status"] = status # make sure that the analysis status is updated
629
685
  _set_analysis_permissions(analysis)
630
686
 
631
- if status in {"FAILED", "SUCCEEDED", "IN_PROGRESS", "REJECTED"}:
687
+ if status in {"FAILED", "SUCCEEDED", "IN_PROGRESS", "FINISHED", "REJECTED"}:
632
688
  data["storage_usage"] = utils.get_tree_size(storage_url)
633
689
 
634
690
  if status == "STARTED":
635
691
  data["ran_by"] = system_settings.api_username
636
692
 
637
- if status in {"SUCCEEDED", "IN_PROGRESS"}:
693
+ if status in {"SUCCEEDED", "IN_PROGRESS", "FINISHED"}:
638
694
  try:
639
695
  data["results"] = _get_analysis_results(analysis, raise_error=True)
640
696
  except Exception as error: # pragma: no cover
@@ -406,6 +406,7 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
406
406
  api.patch_analysis_status(analysis, "STARTED")
407
407
  merge_analyses(analysis, analyses)
408
408
  api.patch_analysis_status(analysis, "SUCCEEDED")
409
+ analysis.data["merged_analyses"] = len(analyses)
409
410
  except Exception as e: # pragma: no cover pylint: disable=W0703
410
411
  error_msg = traceback.format_exc()
411
412
  click.echo(error_msg, file=sys.stderr)
@@ -1159,6 +1160,7 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1159
1160
  app_name (str): `Application.name`.
1160
1161
  app_version (str): `Application.version`. If not defined, use
1161
1162
  any available. Use `any` if you want to use the latest available.
1163
+ app_assembly (str): `Application.assembly.name`. i.e: GRCh37
1162
1164
  linked (bool): if False, the analysis is not linked as a dependencie of
1163
1165
  the analysis. As adding new dependencies to an analysis forces isabl
1164
1166
  to not recognize existing ones (Default: True).
@@ -1182,6 +1184,9 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1182
1184
  result_args["application_key"] = dependency.get("app").primary_key
1183
1185
  result_args["application_name"] = dependency.get("app").NAME
1184
1186
 
1187
+ if "app_assembly" in dependency:
1188
+ result_args["application_assembly"] = dependency.get("app_assembly")
1189
+
1185
1190
  if "status" in dependency:
1186
1191
  result_args["status"] = dependency["status"]
1187
1192
 
@@ -1200,9 +1205,13 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1200
1205
  for name, result_specification in specification.items():
1201
1206
  pattern = result_specification.get("pattern")
1202
1207
  exclude = result_specification.get("exclude")
1208
+ optional = result_specification.get("optional")
1203
1209
  if pattern:
1204
1210
  results[name] = utils.first_matching_file(
1205
- analysis.storage_url, pattern, exclude
1211
+ directory=analysis.storage_url,
1212
+ pattern=pattern,
1213
+ exclude=exclude,
1214
+ optional=optional,
1206
1215
  )
1207
1216
  return results
1208
1217
 
@@ -1235,6 +1244,15 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1235
1244
  for i in specification:
1236
1245
  assert i in results, f"Missing expected result {i} in: {results}"
1237
1246
 
1247
+ # update bam with result if specified
1248
+ for key, attributes in specification.items():
1249
+ if attributes.get("store_as_bam") and results[key]:
1250
+ self.update_experiment_bam_file(
1251
+ experiment=analysis["targets"][0],
1252
+ bam_url=results[key],
1253
+ analysis_pk=analysis["pk"],
1254
+ )
1255
+
1238
1256
  return results
1239
1257
 
1240
1258
  # -----------------
@@ -1527,7 +1545,6 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1527
1545
  # validate existing analyses
1528
1546
  with click.progressbar(
1529
1547
  existing_analyses,
1530
- file=sys.stderr,
1531
1548
  label=f"Validating tuples of the {len(existing_analyses)} existing analyses...\t\t",
1532
1549
  ) as bar:
1533
1550
  for i in bar:
@@ -1543,7 +1560,6 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1543
1560
  # create new analyses and validate
1544
1561
  with click.progressbar(
1545
1562
  valid_tuples,
1546
- file=sys.stderr,
1547
1563
  label=f"Creating analyses for {len(valid_tuples)} tuples...\t\t",
1548
1564
  ) as bar:
1549
1565
  for i in bar:
@@ -1585,7 +1601,7 @@ class AbstractApplication: # pylint: disable=too-many-public-methods
1585
1601
  if not tuples: # pragma: no cover
1586
1602
  return [], []
1587
1603
 
1588
- click.echo("Checking for existing analyses...", file=sys.stderr)
1604
+ click.echo("Checking for existing analyses...")
1589
1605
  projects = {j["pk"] for i in tuples for j in i[0][0]["projects"]}
1590
1606
  cache = defaultdict(list)
1591
1607
  existing, missing = [], []
@@ -156,7 +156,7 @@ def trigger_analyses_merge(analysis):
156
156
  for i in projects.values():
157
157
  pending = api.get_instances_count(
158
158
  endpoint="analyses",
159
- status__in="STARTED,SUBMITTED",
159
+ status__in="STARTED,SUBMITTED,FINISHED",
160
160
  application=analysis["application"]["pk"],
161
161
  projects=i["pk"],
162
162
  )
@@ -46,3 +46,10 @@ class MissingDataError(PackageBaseException):
46
46
  class AutomationError(PackageBaseException):
47
47
 
48
48
  """A class to raise when automations fail."""
49
+
50
+
51
+ class TestSessionWriteError(PackageBaseException):
52
+
53
+ """A class to raise when a test session would write to an API that isn't local."""
54
+
55
+ __test__ = False # not a pytest test class
@@ -130,6 +130,7 @@ class UserSettings:
130
130
  """A class used to manage user specific configurations."""
131
131
 
132
132
  settings_path = join(expanduser("~"), ".isabl", "settings.json")
133
+ api_url = os.environ.get("ISABL_API_URL", "http://localhost:8000/api/v1/")
133
134
 
134
135
  def __repr__(self): # pragma: no cover
135
136
  """Show all configurations in `settings_path`."""
@@ -141,7 +142,7 @@ class UserSettings:
141
142
 
142
143
  def __getattr__(self, name):
143
144
  """Get attribute from `settings_path`."""
144
- return self._read().get(name, None)
145
+ return self._read().get(self.api_url, {}).get(name, None)
145
146
 
146
147
  def _read(self):
147
148
  """Read settings.json."""
@@ -157,7 +158,9 @@ class UserSettings:
157
158
  data = self._read()
158
159
 
159
160
  with open(self.settings_path, "w") as f:
160
- data[name] = value
161
+ if self.api_url not in data:
162
+ data[self.api_url] = {}
163
+ data[self.api_url][name] = value
161
164
  json.dump(data, f, indent=4, sort_keys=True)
162
165
 
163
166
  os.chmod(self.settings_path, 0o600)