Skip to content

Commit 8eba67f

Browse files
authored
dapi v0.5.0: PyLauncher sweeps, API renames, Sphinx autodoc (#7)
* Add TMS credential management to dapi Add check_credentials(), establish_credentials(), and revoke_credentials() to manage Tapis Managed Secrets (TMS) SSH keys on TACC execution systems. Includes CredentialError exception, 31 tests, docs, and example notebook. Also fixes missing comma bug in __init__.py __all__ list. * Switch from mkdocs to Jupyter Book v2 Remove mkdocs.yml, add myst.yml for Jupyter Book v2 / MyST-MD. Update docs.yml workflow to use jupyter-book>=2 with Node.js. Add jupyter-book ^2.0.0 as docs dependency in pyproject.toml. Add TMS credentials example to _toc.yml. * Migrate from Poetry to uv + hatchling Replace Poetry build system with hatchling and PEP 621 metadata. Update all GitHub Actions workflows to use astral-sh/setup-uv. Remove poetry.lock. Add pytest step to CI workflow. * Update README for uv, TMS credentials, and Jupyter Book v2 * Add _build to gitignore, hide MyST footer in docs * Add ds.jobs.list() and standardize docs to use ds variable Add list_jobs() to fetch Tapis jobs as a pandas DataFrame with optional filtering by app_id and status. Includes 14 tests. Rename client variable to ds across all documentation examples. * Auto-TMS on DSClient init, configurable jobs list output - DSClient() now auto-establishes TMS credentials on TACC systems (frontera, stampede3, ls6). Skips gracefully on errors/no allocation. - ds.jobs.list() supports output="df" (default), "list", or "raw". - Simplify auth docs: DB credentials use built-in defaults, no .env needed. - Remove manual TMS step from quickstart (now automatic). - 59 tests pass (8 new for setup_tms, 6 new for output formats). * Clarify DB credentials are intentionally public read-only * WIP: parametric sweeps and redo generate and submit * Rename commands for brevity * Update pylauncher notebook sweep example * Docs * fix formatting * Using ruff instead of black * Fix tests * Fix archive system * Version update to 0.5.0 * Ruff format pylauncher notebook * Fixes #3 TMS support automatically on init client * Dapi examples 0.5.0 * Documentation
1 parent 2bd0371 commit 8eba67f

76 files changed

Lines changed: 3675 additions & 6351 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-test.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,18 @@ jobs:
77
fail-fast: false
88
matrix:
99
python-version: ["3.13"]
10-
poetry-version: ["2.1.2"]
1110
os: [ubuntu-latest]
1211
runs-on: ${{ matrix.os }}
1312
steps:
1413
- uses: actions/checkout@v4
14+
- name: Install uv
15+
uses: astral-sh/setup-uv@v4
1516
- uses: actions/setup-python@v5
1617
with:
1718
python-version: ${{ matrix.python-version }}
18-
- name: Run image
19-
uses: abatilo/actions-poetry@v2
20-
with:
21-
poetry-version: ${{ matrix.poetry-version }}
22-
- name: Update lock file
23-
run: poetry lock
24-
- name: Install the project dependencies
25-
run: poetry install
26-
- name: Lint with black
27-
run: poetry run black --check .
28-
19+
- name: Install dependencies
20+
run: uv pip install --system ".[dev]"
21+
- name: Lint and format check
22+
run: ruff format --check . && ruff check .
23+
- name: Run tests
24+
run: pytest tests/

.github/workflows/docs.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: deploy-book
1+
name: deploy-docs
22

33
on:
44
push:
@@ -16,36 +16,45 @@ concurrency:
1616
cancel-in-progress: false
1717

1818
jobs:
19-
deploy-book:
19+
build:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
2323

24-
- name: Set up Python
25-
uses: actions/setup-python@v5
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.13"
30+
31+
- name: Set up Node.js
32+
uses: actions/setup-node@v4
2633
with:
27-
python-version: "3.12"
34+
node-version: "22"
2835

2936
- name: Install dependencies
30-
run: |
31-
pip install "jupyter-book<1"
32-
pip install .
37+
run: uv pip install --system ".[docs]"
38+
39+
# Build narrative docs (guides, examples) with Jupyter Book / MyST
40+
- name: Build narrative docs
41+
run: jupyter-book build --html
3342

34-
- name: Build the book
35-
run: |
36-
jupyter-book build . --path-output out
43+
# Build API reference with Sphinx
44+
- name: Build API docs
45+
run: sphinx-build -b html docs-api _build/html/api
3746

3847
- name: Upload artifact
3948
uses: actions/upload-pages-artifact@v3
4049
with:
41-
path: ./out/_build/html
50+
path: ./_build/html
4251

4352
deploy:
4453
environment:
4554
name: github-pages
4655
url: ${{ steps.deployment.outputs.page_url }}
4756
runs-on: ubuntu-latest
48-
needs: deploy-book
57+
needs: build
4958
steps:
5059
- name: Deploy to GitHub Pages
5160
id: deployment

.github/workflows/pypi.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish to PyPI
22
on:
33
push:
44
tags:
5-
- 'v[0-9]+.[0-9]+.[0-9]+'
5+
- 'v[0-9]+.[0-9]+.[0-9]+'
66
jobs:
77
pypi-publish:
88
name: Upload release to PyPI
@@ -11,21 +11,18 @@ jobs:
1111
name: pypi
1212
url: https://pypi.org/p/dapi
1313
permissions:
14-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15-
contents: read # Required for checkout
14+
id-token: write
15+
contents: read
1616
steps:
1717
- uses: actions/checkout@v4
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v4
1820
- uses: actions/setup-python@v5
1921
with:
20-
python-version: 3.9
21-
- name: Poetry image
22-
uses: abatilo/actions-poetry@v2
23-
- name: Install the project dependencies
24-
run: poetry install
22+
python-version: "3.13"
2523
- name: Build package
26-
run: poetry build
24+
run: uv build
2725
- name: Publish package distributions to PyPI
2826
uses: pypa/gh-action-pypi-publish@release/v1
2927
with:
30-
# Enable verbose logging for debugging
3128
verbose: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ venv.bak/
141141
.ropeproject
142142

143143
# Jupyter Book build output
144+
/_build/
144145
/out/
145146

146147
# mkdocs documentation (legacy)

README.md

Lines changed: 80 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@
22

33
[![build and test](https://github.com/DesignSafe-CI/dapi/actions/workflows/build-test.yml/badge.svg)](https://github.com/DesignSafe-CI/dapi/actions/workflows/build-test.yml)
44
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md)
5-
[![Docs](https://img.shields.io/badge/view-docs-8A2BE2?color=8A2BE2)](https://designsafe-ci.github.io/dapi/dapi/index.html)
5+
[![PyPI version](https://badge.fury.io/py/dapi.svg)](https://badge.fury.io/py/dapi)
6+
[![Docs](https://img.shields.io/badge/view-docs-8A2BE2?color=8A2BE2)](https://designsafe-ci.github.io/dapi/)
67

7-
`dapi` is a library that simplifies the process of submitting, running, and monitoring [TAPIS v3](https://tapis.readthedocs.io/en/latest/) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org).
8+
`dapi` is a Python library for submitting, running, and monitoring [TAPIS v3](https://tapis.readthedocs.io/en/latest/) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org) or the command line.
89

910
<img src="https://raw.githubusercontent.com/DesignSafe-CI/dapi/main/dapi.png" alt="dapi" width="300">
1011

11-
1212
## Features
1313

1414
### Jobs
15+
- Generate TAPIS v3 job requests with automatic app parameter mapping
16+
- Submit, monitor (with progress bars), and manage jobs
17+
- Access and download job outputs
18+
- Discover and explore available DesignSafe applications
1519

16-
* Get TAPIS v3 templates for jobs: No need to fiddle with complex API requests. `dapi` abstracts away the complexities.
20+
### TMS Credentials
21+
- Establish, check, and revoke SSH keys on TACC execution systems (Frontera, Stampede3, LS6)
22+
- Works from any environment -- DesignSafe JupyterHub, command line, CI/CD
1723

18-
* Seamless Integration with DesignSafe Jupyter Notebooks: Launch DesignSafe applications directly from the Jupyter environment.
24+
### Files
25+
- Translate DesignSafe paths (`/MyData`, `/CommunityData`, `/projects`) to TAPIS URIs
26+
- Upload, download, and list files on DesignSafe storage
1927

2028
### Database
21-
2229
Connects to SQL databases on DesignSafe:
2330

2431
| Database | dbname | env_prefix |
2532
|----------|--------|------------|
2633
| NGL | `ngl`| `NGL_` |
27-
| Earthake Recovery | `eq` | `EQ_` |
34+
| Earthquake Recovery | `eq` | `EQ_` |
2835
| Vp | `vp` | `VP_` |
2936

3037
Define the following environment variables:
@@ -37,115 +44,119 @@ Define the following environment variables:
3744

3845
For e.g., to add the environment variable `NGL_DB_USER` edit `~/.bashrc`, `~/.zshrc`, or a similar shell-specific configuration file for the current user and add `export NGL_DB_USER="dspublic"`.
3946

40-
4147
## Installation
4248

43-
Install `dapi` via pip
44-
4549
```shell
46-
pip3 install dapi
50+
pip install dapi
4751
```
4852

49-
To install the current development version of the library use:
53+
To install the development version:
5054

5155
```shell
52-
pip install git+https://github.com/DesignSafe-CI/dapi.git --quiet
56+
pip install git+https://github.com/DesignSafe-CI/dapi.git@dev --quiet
5357
```
5458

55-
## Example usage:
59+
In Jupyter notebooks:
5660

57-
### Storing credentials
61+
```python
62+
%pip install dapi --quiet
63+
```
5864

59-
Dapi uses the Tapis v3 SDK to authenticate with the DesignSafe API. To store your credentials, create a `.env` file in the root of your project with the following content:
65+
To test the latest dev branch in a notebook:
6066

61-
```shell
62-
DESIGNSAFE_USERNAME=<your_designsafe_username>
63-
DESIGNSAFE_PASSWORD=<your_designsafe_password>
67+
```python
68+
%pip uninstall dapi --yes
69+
%pip install git+https://github.com/DesignSafe-CI/dapi.git@dev --quiet
6470
```
6571

66-
### Jobs
72+
For local development (editable install — changes to source are reflected immediately):
6773

68-
* [Jupyter Notebook Templates](example-notebooks/template-mpm-run.ipynb) using dapi.
74+
```shell
75+
pip install -e .
76+
```
6977

70-
* View [dapi API doc](https://designsafe-ci.github.io/dapi/dapi/index.html)
78+
## Quick Start
7179

72-
On [DesignSafe Jupyter](https://jupyter.designsafe-ci.org/):
80+
### Authentication
7381

74-
Install the latest version of `dapi` and restart the kernel (Kernel >> Restart Kernel):
82+
Create a `.env` file with your DesignSafe credentials:
7583

76-
```python
77-
# Remove any previous installations
78-
!pip uninstall dapi -y
79-
# Install
80-
!pip install dapi --quiet
84+
```shell
85+
DESIGNSAFE_USERNAME=your_username
86+
DESIGNSAFE_PASSWORD=your_password
8187
```
8288

83-
* Import `dapi` library
84-
```python
85-
import dapi
86-
```
89+
### Setup and submit a job
8790

88-
* To list all functions in `dapi`
8991
```python
90-
dir(dapi)
92+
from dapi import DSClient
93+
94+
# Authenticate
95+
client = DSClient()
96+
97+
# Establish TMS credentials (one-time per system)
98+
client.systems.establish_credentials("frontera")
99+
100+
# Submit a job
101+
job_request = client.jobs.generate(
102+
app_id="matlab-r2023a",
103+
input_dir_uri="/MyData/analysis/input/",
104+
script_filename="run_analysis.m",
105+
max_minutes=30,
106+
allocation="your_allocation"
107+
)
108+
job = client.jobs.submit(job_request)
109+
final_status = job.monitor()
91110
```
92111

93112
### Database
113+
94114
```python
95-
from dapi.db import DSDatabase
115+
from dapi import DSClient
96116

97-
db = DSDatabase("ngl")
98-
sql = 'SELECT * FROM SITE'
99-
df = db.read_sql(sql)
117+
client = DSClient()
118+
df = client.db.ngl.read_sql("SELECT * FROM SITE LIMIT 10")
100119
print(df)
101-
102-
# Optionally, close the database connection when done
103-
db.close()
104120
```
105121

106-
107122
## Support
108123

109-
For any questions, issues, or feedback submit an [issue](https://github.com/DesignSafe-CI/dapi/issues/new)
124+
For any questions, issues, or feedback submit an [issue](https://github.com/DesignSafe-CI/dapi/issues/new).
110125

111126
## Development
112127

113-
To develop or test the library locally. Install [Poetry](https://python-poetry.org/docs/#installation). In the current repository run the following commands
128+
Install [uv](https://docs.astral.sh/uv/getting-started/installation/), then:
114129

115130
```shell
116-
poetry shell
117-
poetry install
118-
poetry build
131+
uv venv
132+
uv pip install -e ".[dev]"
119133
```
120134

121-
To run the unit test
135+
Run tests:
122136
```shell
123-
poetry run pytest -v
137+
pytest tests/ -v
124138
```
125139

140+
Build the package:
141+
```shell
142+
uv build
143+
```
126144

127-
## License
128-
129-
`dapi` is licensed under the [MIT License](LICENSE.md).
130-
131-
## Authors
132-
133-
* Krishna Kumar, University of Texas at Austin
134-
* Prof. Pedro Arduino, University of Washington
135-
* Prof. Scott Brandenberg, University of California Los Angeles
136-
145+
### Documentation
137146

138-
## Documentation
147+
Documentation uses [Jupyter Book v2](https://mystmd.org). To build and serve locally:
139148

140-
View [dapi API doc](https://designsafe-ci.github.io/dapi/dapi/index.html)
149+
```shell
150+
uv pip install -e ".[docs]"
151+
jupyter-book start
152+
```
141153

142-
### Running documentation locally
154+
## License
143155

144-
To serve the MkDocs documentation locally:
156+
`dapi` is licensed under the [MIT License](LICENSE.md).
145157

146-
```shell
147-
poetry install
148-
poetry run mkdocs serve
149-
```
158+
## Authors
150159

151-
This will start a local server at `http://127.0.0.1:8000/dapi/` where you can view the documentation.
160+
- Krishna Kumar, University of Texas at Austin
161+
- Prof. Pedro Arduino, University of Washington
162+
- Prof. Scott Brandenberg, University of California Los Angeles

0 commit comments

Comments
 (0)