You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-74Lines changed: 66 additions & 74 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,36 @@
2
2
3
3
[](https://github.com/DesignSafe-CI/dapi/actions/workflows/build-test.yml)
`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 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.
- Submit, monitor (with progress bars), and manage jobs
17
+
- Access and download job outputs
18
+
- Discover and explore available DesignSafe applications
15
19
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
17
23
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
19
27
20
28
### Database
21
-
22
29
Connects to SQL databases on DesignSafe:
23
30
24
31
| Database | dbname | env_prefix |
25
32
|----------|--------|------------|
26
33
| NGL |`ngl`|`NGL_`|
27
-
|Earthake Recovery |`eq`|`EQ_`|
34
+
|Earthquake Recovery |`eq`|`EQ_`|
28
35
| Vp |`vp`|`VP_`|
29
36
30
37
Define the following environment variables:
@@ -37,115 +44,100 @@ Define the following environment variables:
37
44
38
45
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"`.
39
46
40
-
41
47
## Installation
42
48
43
-
Install `dapi` via pip
44
-
45
49
```shell
46
-
pip3 install dapi
50
+
pip install dapi
47
51
```
48
52
49
-
To install the current development version of the library use:
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:
63
+
Create a `.env` file with your DesignSafe credentials:
60
64
61
65
```shell
62
-
DESIGNSAFE_USERNAME=<your_designsafe_username>
63
-
DESIGNSAFE_PASSWORD=<your_designsafe_password>
66
+
DESIGNSAFE_USERNAME=your_username
67
+
DESIGNSAFE_PASSWORD=your_password
64
68
```
65
69
66
-
### Jobs
67
-
68
-
*[Jupyter Notebook Templates](example-notebooks/template-mpm-run.ipynb) using dapi.
69
-
70
-
* View [dapi API doc](https://designsafe-ci.github.io/dapi/dapi/index.html)
71
-
72
-
On [DesignSafe Jupyter](https://jupyter.designsafe-ci.org/):
73
-
74
-
Install the latest version of `dapi` and restart the kernel (Kernel >> Restart Kernel):
70
+
### Setup and submit a job
75
71
76
72
```python
77
-
# Remove any previous installations
78
-
!pip uninstall dapi -y
79
-
# Install
80
-
!pip install dapi --quiet
81
-
```
82
-
83
-
* Import `dapi` library
84
-
```python
85
-
import dapi
86
-
```
87
-
88
-
* To list all functions in `dapi`
89
-
```python
90
-
dir(dapi)
73
+
from dapi import DSClient
74
+
75
+
# Authenticate
76
+
client = DSClient()
77
+
78
+
# Establish TMS credentials (one-time per system)
79
+
client.systems.establish_credentials("frontera")
80
+
81
+
# Submit a job
82
+
job_request = client.jobs.generate_request(
83
+
app_id="matlab-r2023a",
84
+
input_dir_uri="/MyData/analysis/input/",
85
+
script_filename="run_analysis.m",
86
+
max_minutes=30,
87
+
allocation="your_allocation"
88
+
)
89
+
job = client.jobs.submit_request(job_request)
90
+
final_status = job.monitor()
91
91
```
92
92
93
93
### Database
94
+
94
95
```python
95
-
from dapi.dbimportDSDatabase
96
+
from dapi importDSClient
96
97
97
-
db = DSDatabase("ngl")
98
-
sql ='SELECT * FROM SITE'
99
-
df = db.read_sql(sql)
98
+
client = DSClient()
99
+
df = client.db.ngl.read_sql("SELECT * FROM SITE LIMIT 10")
100
100
print(df)
101
-
102
-
# Optionally, close the database connection when done
103
-
db.close()
104
101
```
105
102
106
-
107
103
## Support
108
104
109
-
For any questions, issues, or feedback submit an [issue](https://github.com/DesignSafe-CI/dapi/issues/new)
105
+
For any questions, issues, or feedback submit an [issue](https://github.com/DesignSafe-CI/dapi/issues/new).
110
106
111
107
## Development
112
108
113
-
To develop or test the library locally. Install [Poetry](https://python-poetry.org/docs/#installation). In the current repository run the following commands
0 commit comments