jump2-client 0.1.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.
- jump2_client-0.1.0/.gitignore +250 -0
- jump2_client-0.1.0/LICENSE +21 -0
- jump2_client-0.1.0/PKG-INFO +102 -0
- jump2_client-0.1.0/README.md +67 -0
- jump2_client-0.1.0/jump2_client/__init__.py +49 -0
- jump2_client-0.1.0/jump2_client/_pretty.py +44 -0
- jump2_client-0.1.0/jump2_client/admin/__init__.py +57 -0
- jump2_client-0.1.0/jump2_client/admin/ingest.py +193 -0
- jump2_client-0.1.0/jump2_client/admin/schedules.py +164 -0
- jump2_client-0.1.0/jump2_client/admin/users.py +88 -0
- jump2_client-0.1.0/jump2_client/client.py +299 -0
- jump2_client-0.1.0/jump2_client/data.py +245 -0
- jump2_client-0.1.0/jump2_client/discovery.py +71 -0
- jump2_client-0.1.0/jump2_client/errors.py +136 -0
- jump2_client-0.1.0/jump2_client/health.py +129 -0
- jump2_client-0.1.0/jump2_client/jobs.py +124 -0
- jump2_client-0.1.0/jump2_client/query.py +318 -0
- jump2_client-0.1.0/jump2_client/session.py +228 -0
- jump2_client-0.1.0/pyproject.toml +77 -0
- jump2_client-0.1.0/tests/__init__.py +0 -0
- jump2_client-0.1.0/tests/integration/__init__.py +0 -0
- jump2_client-0.1.0/tests/integration/test_integration.py +337 -0
- jump2_client-0.1.0/tests/test_admin_ingest.py +164 -0
- jump2_client-0.1.0/tests/test_admin_schedules.py +116 -0
- jump2_client-0.1.0/tests/test_admin_users.py +36 -0
- jump2_client-0.1.0/tests/test_client.py +126 -0
- jump2_client-0.1.0/tests/test_data.py +160 -0
- jump2_client-0.1.0/tests/test_discovery.py +102 -0
- jump2_client-0.1.0/tests/test_errors.py +144 -0
- jump2_client-0.1.0/tests/test_health.py +75 -0
- jump2_client-0.1.0/tests/test_jobs.py +87 -0
- jump2_client-0.1.0/tests/test_pretty.py +49 -0
- jump2_client-0.1.0/tests/test_query_builder.py +220 -0
- jump2_client-0.1.0/tests/test_session.py +248 -0
- jump2_client-0.1.0/uv.lock +711 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
*.tsbuildinfo
|
|
11
|
+
.Python
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py.cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
#Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
#uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
#poetry.lock
|
|
110
|
+
#poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
#pdm.lock
|
|
117
|
+
#pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
#pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# SageMath parsed files
|
|
136
|
+
*.sage.py
|
|
137
|
+
|
|
138
|
+
# Environments
|
|
139
|
+
.env
|
|
140
|
+
.env.dev
|
|
141
|
+
.envrc
|
|
142
|
+
node/.env.node
|
|
143
|
+
.venv
|
|
144
|
+
env/
|
|
145
|
+
venv/
|
|
146
|
+
ENV/
|
|
147
|
+
env.bak/
|
|
148
|
+
venv.bak/
|
|
149
|
+
|
|
150
|
+
# Spyder project settings
|
|
151
|
+
.spyderproject
|
|
152
|
+
.spyproject
|
|
153
|
+
|
|
154
|
+
# Rope project settings
|
|
155
|
+
.ropeproject
|
|
156
|
+
|
|
157
|
+
# mkdocs documentation
|
|
158
|
+
/site
|
|
159
|
+
|
|
160
|
+
# mypy
|
|
161
|
+
.mypy_cache/
|
|
162
|
+
.dmypy.json
|
|
163
|
+
dmypy.json
|
|
164
|
+
|
|
165
|
+
# Pyre type checker
|
|
166
|
+
.pyre/
|
|
167
|
+
|
|
168
|
+
# pytype static type analyzer
|
|
169
|
+
.pytype/
|
|
170
|
+
|
|
171
|
+
# Cython debug symbols
|
|
172
|
+
cython_debug/
|
|
173
|
+
|
|
174
|
+
# PyCharm
|
|
175
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
176
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
177
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
178
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
179
|
+
#.idea/
|
|
180
|
+
|
|
181
|
+
# Abstra
|
|
182
|
+
# Abstra is an AI-powered process automation framework.
|
|
183
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
184
|
+
# Learn more at https://abstra.io/docs
|
|
185
|
+
.abstra/
|
|
186
|
+
|
|
187
|
+
# Visual Studio Code
|
|
188
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
189
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
190
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
191
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
192
|
+
# .vscode/
|
|
193
|
+
|
|
194
|
+
# Ruff stuff:
|
|
195
|
+
.ruff_cache/
|
|
196
|
+
|
|
197
|
+
# PyPI configuration file
|
|
198
|
+
.pypirc
|
|
199
|
+
|
|
200
|
+
# Cursor
|
|
201
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
202
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
203
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
204
|
+
.cursorignore
|
|
205
|
+
.cursorindexingignore
|
|
206
|
+
|
|
207
|
+
# DS_Store
|
|
208
|
+
*.DS_Store
|
|
209
|
+
|
|
210
|
+
# local data
|
|
211
|
+
data/*
|
|
212
|
+
*.swp
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# DS_Store
|
|
220
|
+
.DS_Store
|
|
221
|
+
|
|
222
|
+
# Database backups
|
|
223
|
+
db-backups/
|
|
224
|
+
|
|
225
|
+
# Node modules
|
|
226
|
+
node_modules
|
|
227
|
+
|
|
228
|
+
# debugging
|
|
229
|
+
diff.txt
|
|
230
|
+
|
|
231
|
+
# VS Code and Zed
|
|
232
|
+
.vscode
|
|
233
|
+
.zed
|
|
234
|
+
|
|
235
|
+
# Testing
|
|
236
|
+
test-results/
|
|
237
|
+
tests/results/
|
|
238
|
+
playwright-report
|
|
239
|
+
test-data/
|
|
240
|
+
!test-data/kpf-remote/
|
|
241
|
+
|
|
242
|
+
# Tutorial files
|
|
243
|
+
tutorials/demo_data
|
|
244
|
+
.worktrees/
|
|
245
|
+
|
|
246
|
+
# Local CLI config (environment-specific, not committed)
|
|
247
|
+
jump2.toml
|
|
248
|
+
|
|
249
|
+
# nginx
|
|
250
|
+
docker/nginx/.nfs*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 California Planet Search
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jump2-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Jump 2.0 Python client — standalone, pip-installable, works in JupyterHub or locally.
|
|
5
|
+
Project-URL: Repository, https://github.com/California-Planet-Search/jump2
|
|
6
|
+
Project-URL: Documentation, https://github.com/California-Planet-Search/jump2/blob/main/docs/CLIENT.md
|
|
7
|
+
Author: California Planet Search
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: api-client,astronomy,jump2,jupyter
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: pandas>=2.0.0
|
|
21
|
+
Requires-Dist: requests>=2.31.0
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Requires-Dist: sqlglot>=25.0.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
26
|
+
Requires-Dist: pandas-stubs; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-mock>=3.14.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
30
|
+
Requires-Dist: types-requests; extra == 'dev'
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
|
|
33
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# jump2-client
|
|
37
|
+
|
|
38
|
+
Standalone Python client for the [Jump 2.0](https://github.com/keck-community/jump2) astronomical data portal.
|
|
39
|
+
|
|
40
|
+
Works in **JupyterHub** (zero-config — credentials injected at spawn) or **locally** with an API key.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install jump2-client
|
|
46
|
+
# or, from source:
|
|
47
|
+
cd client && uv sync
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requirements: Python ≥ 3.11, `requests`, `sqlglot ≥ 25.0`.
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from jump2_client import Client
|
|
56
|
+
|
|
57
|
+
# In JupyterHub — no setup needed:
|
|
58
|
+
c = Client()
|
|
59
|
+
c.status() # connectivity + ACL check
|
|
60
|
+
c.discover() # browse the API endpoint catalogue
|
|
61
|
+
c.docs # print cheat-sheet
|
|
62
|
+
|
|
63
|
+
# Locally:
|
|
64
|
+
c = Client(base_url="https://jump2.example.org", api_key="jump2_live_…")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Data access
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
# Raw SQL → DataFrame (RLS enforced server-side):
|
|
71
|
+
df = c.data.query("SELECT url_slug, vmag FROM core_star ORDER BY vmag LIMIT 20")
|
|
72
|
+
|
|
73
|
+
# Fluent query builder:
|
|
74
|
+
df = (c.data.table("core_star")
|
|
75
|
+
.select("url_slug", "vmag", "ra", "dec")
|
|
76
|
+
.where(vmag__lt=8)
|
|
77
|
+
.order_by("vmag")
|
|
78
|
+
.limit(25)
|
|
79
|
+
.df())
|
|
80
|
+
|
|
81
|
+
# Stars and observations:
|
|
82
|
+
for star in c.data.stars():
|
|
83
|
+
print(star["url_slug"])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Error handling
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from jump2_client import AuthError, ValidationError, NotFoundError
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
df = c.data.query("SELECT * FROM bad_table")
|
|
93
|
+
except ValidationError as e:
|
|
94
|
+
print(e.detail) # server message
|
|
95
|
+
print(e.hint) # remediation hint
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Full documentation
|
|
99
|
+
|
|
100
|
+
See [`docs/CLIENT.md`](../docs/CLIENT.md) in the jump2 repository for the complete reference:
|
|
101
|
+
authentication modes, URL prefix convention, QueryBuilder operators, admin API, error model,
|
|
102
|
+
and key regeneration flow.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# jump2-client
|
|
2
|
+
|
|
3
|
+
Standalone Python client for the [Jump 2.0](https://github.com/keck-community/jump2) astronomical data portal.
|
|
4
|
+
|
|
5
|
+
Works in **JupyterHub** (zero-config — credentials injected at spawn) or **locally** with an API key.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install jump2-client
|
|
11
|
+
# or, from source:
|
|
12
|
+
cd client && uv sync
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requirements: Python ≥ 3.11, `requests`, `sqlglot ≥ 25.0`.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from jump2_client import Client
|
|
21
|
+
|
|
22
|
+
# In JupyterHub — no setup needed:
|
|
23
|
+
c = Client()
|
|
24
|
+
c.status() # connectivity + ACL check
|
|
25
|
+
c.discover() # browse the API endpoint catalogue
|
|
26
|
+
c.docs # print cheat-sheet
|
|
27
|
+
|
|
28
|
+
# Locally:
|
|
29
|
+
c = Client(base_url="https://jump2.example.org", api_key="jump2_live_…")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Data access
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
# Raw SQL → DataFrame (RLS enforced server-side):
|
|
36
|
+
df = c.data.query("SELECT url_slug, vmag FROM core_star ORDER BY vmag LIMIT 20")
|
|
37
|
+
|
|
38
|
+
# Fluent query builder:
|
|
39
|
+
df = (c.data.table("core_star")
|
|
40
|
+
.select("url_slug", "vmag", "ra", "dec")
|
|
41
|
+
.where(vmag__lt=8)
|
|
42
|
+
.order_by("vmag")
|
|
43
|
+
.limit(25)
|
|
44
|
+
.df())
|
|
45
|
+
|
|
46
|
+
# Stars and observations:
|
|
47
|
+
for star in c.data.stars():
|
|
48
|
+
print(star["url_slug"])
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Error handling
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from jump2_client import AuthError, ValidationError, NotFoundError
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
df = c.data.query("SELECT * FROM bad_table")
|
|
58
|
+
except ValidationError as e:
|
|
59
|
+
print(e.detail) # server message
|
|
60
|
+
print(e.hint) # remediation hint
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Full documentation
|
|
64
|
+
|
|
65
|
+
See [`docs/CLIENT.md`](../docs/CLIENT.md) in the jump2 repository for the complete reference:
|
|
66
|
+
authentication modes, URL prefix convention, QueryBuilder operators, admin API, error model,
|
|
67
|
+
and key regeneration flow.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
jump2_client — Jump 2.0 Python client.
|
|
3
|
+
|
|
4
|
+
Lightweight, standalone, pip-installable. Works in JupyterHub (picks up
|
|
5
|
+
credentials from the environment automatically) or locally (provide
|
|
6
|
+
``base_url`` and ``api_key``, or use :meth:`~jump2_client.client.Client.login`).
|
|
7
|
+
|
|
8
|
+
Quick start::
|
|
9
|
+
|
|
10
|
+
from jump2_client import Client
|
|
11
|
+
|
|
12
|
+
# In JupyterHub — zero config needed, credentials injected at spawn:
|
|
13
|
+
c = Client()
|
|
14
|
+
c.status() # connectivity + ACL check
|
|
15
|
+
c.discover() # browse the API
|
|
16
|
+
|
|
17
|
+
# Locally:
|
|
18
|
+
c = Client(base_url="https://jump2.example.org", api_key="...")
|
|
19
|
+
# or:
|
|
20
|
+
c = Client(base_url="https://jump2.example.org").login("user", "pass")
|
|
21
|
+
|
|
22
|
+
# Data access (RLS invisible — server handles authorisation):
|
|
23
|
+
df = c.data.query("SELECT url_slug, vmag FROM core_star LIMIT 20")
|
|
24
|
+
files = c.data.files("hd-209458")
|
|
25
|
+
|
|
26
|
+
# Jobs:
|
|
27
|
+
result = c.jobs.poll(42)
|
|
28
|
+
|
|
29
|
+
# Admin (requires elevated permissions):
|
|
30
|
+
job = c.admin.ingest.launch(instruments=["apf"])
|
|
31
|
+
c.admin.schedules.list()
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
from .client import Client
|
|
35
|
+
from .errors import AuthError, Jump2Error, NotFoundError, ServerError, ValidationError
|
|
36
|
+
from .query import QueryBuilder
|
|
37
|
+
|
|
38
|
+
__version__ = "0.1.0"
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"Client",
|
|
42
|
+
"Jump2Error",
|
|
43
|
+
"AuthError",
|
|
44
|
+
"NotFoundError",
|
|
45
|
+
"ServerError",
|
|
46
|
+
"ValidationError",
|
|
47
|
+
"QueryBuilder",
|
|
48
|
+
"__version__",
|
|
49
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
jump2_client._pretty — rich rendering helpers.
|
|
3
|
+
|
|
4
|
+
Kept in a private module so the public API stays clean. The ``rich``
|
|
5
|
+
library is always available (it is a declared dependency), but callers
|
|
6
|
+
never need to import it themselves — just call the public methods on the
|
|
7
|
+
client objects and they print formatted tables automatically.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _rich() -> Any:
|
|
15
|
+
"""Lazy import of rich.console.Console to avoid import-time overhead."""
|
|
16
|
+
from rich.console import Console
|
|
17
|
+
return Console()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def print_table(title: str, columns: list[str], rows: list[list[Any]]) -> None:
|
|
21
|
+
"""Print a labelled rich table to stdout."""
|
|
22
|
+
from rich.table import Table
|
|
23
|
+
|
|
24
|
+
console = _rich()
|
|
25
|
+
table = Table(title=title, show_header=True, header_style="bold cyan")
|
|
26
|
+
for col in columns:
|
|
27
|
+
table.add_column(col, overflow="fold")
|
|
28
|
+
for row in rows:
|
|
29
|
+
table.add_row(*[str(v) if v is not None else "" for v in row])
|
|
30
|
+
console.print(table)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def print_dict(title: str, data: dict[str, Any]) -> None:
|
|
34
|
+
"""Print a two-column key/value rich table."""
|
|
35
|
+
print_table(title, ["Key", "Value"], [[k, v] for k, v in data.items()])
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def format_bytes(n: int | float) -> str:
|
|
39
|
+
"""Human-readable byte size (e.g. ``"3.2 GiB"``)."""
|
|
40
|
+
for unit in ("B", "KiB", "MiB", "GiB", "TiB"):
|
|
41
|
+
if abs(n) < 1024.0:
|
|
42
|
+
return f"{n:.1f} {unit}"
|
|
43
|
+
n /= 1024.0
|
|
44
|
+
return f"{n:.1f} PiB"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
jump2_client.admin — admin-only operations.
|
|
3
|
+
|
|
4
|
+
All actions in this submodule require elevated permissions (``run_jobs``,
|
|
5
|
+
``manage_schedules``, ``manage_users`` etc.). Authorisation is enforced
|
|
6
|
+
server-side — calling these without the required tokens raises
|
|
7
|
+
:exc:`~jump2_client.errors.AuthError`.
|
|
8
|
+
|
|
9
|
+
Submodules
|
|
10
|
+
----------
|
|
11
|
+
``ingest``
|
|
12
|
+
Preview and launch ad-hoc ingest coordinator jobs.
|
|
13
|
+
|
|
14
|
+
``schedules``
|
|
15
|
+
CRUD for Celery-Beat ingest schedules.
|
|
16
|
+
|
|
17
|
+
``users``
|
|
18
|
+
Admin user and resource-usage views.
|
|
19
|
+
|
|
20
|
+
Example::
|
|
21
|
+
|
|
22
|
+
from jump2_client import Client
|
|
23
|
+
c = Client()
|
|
24
|
+
|
|
25
|
+
# Preview what would be ingested
|
|
26
|
+
preview = c.admin.ingest.preview()
|
|
27
|
+
|
|
28
|
+
# Launch a manual ingest
|
|
29
|
+
job = c.admin.ingest.launch()
|
|
30
|
+
result = c.jobs.poll(job["id"])
|
|
31
|
+
|
|
32
|
+
# Manage schedules
|
|
33
|
+
c.admin.schedules.list()
|
|
34
|
+
"""
|
|
35
|
+
from __future__ import annotations
|
|
36
|
+
|
|
37
|
+
from typing import TYPE_CHECKING
|
|
38
|
+
|
|
39
|
+
from .ingest import AdminIngest
|
|
40
|
+
from .schedules import AdminSchedules
|
|
41
|
+
from .users import AdminUsers
|
|
42
|
+
|
|
43
|
+
if TYPE_CHECKING:
|
|
44
|
+
from ..session import Session
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Admin:
|
|
48
|
+
"""
|
|
49
|
+
Admin-only client namespace.
|
|
50
|
+
|
|
51
|
+
Attached to :class:`~jump2_client.client.Client` as ``client.admin``.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
def __init__(self, session: Session) -> None:
|
|
55
|
+
self.ingest = AdminIngest(session)
|
|
56
|
+
self.schedules = AdminSchedules(session)
|
|
57
|
+
self.users = AdminUsers(session)
|