Skip to content

Commit ebeb562

Browse files
committed
Dapi examples 0.5.0
1 parent 96165d8 commit ebeb562

26 files changed

Lines changed: 358 additions & 3793 deletions

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![PyPI version](https://badge.fury.io/py/dapi.svg)](https://badge.fury.io/py/dapi)
66
[![Docs](https://img.shields.io/badge/view-docs-8A2BE2?color=8A2BE2)](https://designsafe-ci.github.io/dapi/)
77

8-
`dapi` is a Python 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) or from the command line.
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.
99

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

@@ -50,10 +50,29 @@ For e.g., to add the environment variable `NGL_DB_USER` edit `~/.bashrc`, `~/.zs
5050
pip install dapi
5151
```
5252

53-
To install the current development version:
53+
To install the development version:
5454

5555
```shell
56-
pip install git+https://github.com/DesignSafe-CI/dapi.git --quiet
56+
pip install git+https://github.com/DesignSafe-CI/dapi.git@dev --quiet
57+
```
58+
59+
In Jupyter notebooks:
60+
61+
```python
62+
%pip install dapi --quiet
63+
```
64+
65+
To test the latest dev branch in a notebook:
66+
67+
```python
68+
%pip uninstall dapi --yes
69+
%pip install git+https://github.com/DesignSafe-CI/dapi.git@dev --quiet
70+
```
71+
72+
For local development (editable install — changes to source are reflected immediately):
73+
74+
```shell
75+
pip install -e .
5776
```
5877

5978
## Quick Start

_toc.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

dapi/__init__.py

Lines changed: 17 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,26 @@
1-
"""Dapi - A Python wrapper for interacting with DesignSafe resources via the Tapis API.
1+
"""Python client for submitting, monitoring, and managing TAPIS v3 jobs on DesignSafe.
22
3-
This package provides a high-level, user-friendly interface for working with DesignSafe
4-
resources through the Tapis V3 API. It simplifies complex operations and provides
5-
organized access to different service areas including authentication, file operations,
6-
job submission and monitoring, application discovery, system information, and database access.
3+
Also provides access to DesignSafe research databases (NGL, Earthquake Recovery, VP)
4+
and file operations (path translation, upload, download).
75
8-
Key Features:
9-
- Simplified authentication with credential resolution hierarchy
10-
- DesignSafe path translation (MyData, projects, etc.) to Tapis URIs
11-
- High-level job submission with automatic app parameter mapping
12-
- Job monitoring with progress bars and status interpretation
13-
- File upload/download with automatic directory creation
14-
- Application discovery and detailed retrieval
15-
- System queue information and resource limits
16-
- Database access for DesignSafe research databases
17-
- Comprehensive error handling with descriptive exceptions
6+
Classes:
7+
DSClient: Entry point. Provides access to jobs, files, apps, systems, and databases.
8+
SubmittedJob: Returned by ``DSClient.jobs.submit()``. Used to monitor and inspect a job.
189
19-
Main Components:
20-
DSClient: Main client class providing organized access to all services
21-
SubmittedJob: Class for managing and monitoring submitted Tapis jobs
22-
Exception classes: Specific exceptions for different error types
10+
Example::
2311
24-
Example:
25-
Basic usage with automatic authentication:
12+
from dapi import DSClient
2613
27-
>>> from dapi import DSClient
28-
>>> client = DSClient()
29-
Enter DesignSafe Username: myuser
30-
Enter DesignSafe Password: [hidden]
31-
Authentication successful.
14+
client = DSClient()
15+
job_request = client.jobs.generate(
16+
app_id="matlab-r2023a",
17+
input_dir_uri="/MyData/analysis/input/",
18+
script_filename="run_analysis.m",
19+
)
20+
job = client.jobs.submit(job_request)
21+
final_status = job.monitor()
3222
33-
>>> # File operations
34-
>>> client.files.upload("/local/file.txt", "/MyData/uploads/file.txt")
35-
>>> files = client.files.list("/MyData/uploads/")
36-
37-
>>> # Job submission and monitoring
38-
>>> job_request = client.jobs.generate(
39-
... app_id="matlab-r2023a",
40-
... input_dir_uri="/MyData/analysis/input/",
41-
... script_filename="run_analysis.m",
42-
... )
43-
>>> job = client.jobs.submit(job_request)
44-
>>> final_status = job.monitor()
45-
46-
>>> # Database access
47-
>>> df = client.db.ngl.read_sql("SELECT * FROM earthquake_data LIMIT 10")
48-
49-
Attributes:
50-
__version__ (str): The version number of the dapi package.
51-
DSClient: Main client class for DesignSafe API interactions.
52-
SubmittedJob: Class for managing submitted Tapis jobs.
53-
Exception classes: Custom exceptions for specific error conditions.
23+
df = client.db.ngl.read_sql("SELECT * FROM SITE LIMIT 10")
5424
"""
5525

5626
from .client import DSClient

docs/api/apps.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

docs/api/auth.md

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)