Skip to main content

DesignSafe API

Project description

DesignSafe API (dapi)

build and test License Docs

dapi is a library that simplifies the process of submitting, running, and monitoring TAPIS v3 jobs on DesignSafe via Jupyter Notebooks.

dapi

Features

Jobs

  • Get TAPIS v3 templates for jobs: No need to fiddle with complex API requests. dapi abstracts away the complexities.

  • Seamless Integration with DesignSafe Jupyter Notebooks: Launch DesignSafe applications directly from the Jupyter environment.

Database

Connects to SQL databases on DesignSafe:

Database dbname env_prefix
NGL ngl NGL_
Earthake Recovery eq EQ_
Vp vp VP_

Define the following environment variables:

{env_prefix}DB_USER
{env_prefix}DB_PASSWORD
{env_prefix}DB_HOST
{env_prefix}DB_PORT

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".

Installation

Install dapi via pip

pip3 install dapi

To install the current development version of the library use:

pip install git+https://github.com/DesignSafe-CI/dapi.git --quiet

Example usage:

Storing credentials

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:

DESIGNSAFE_USERNAME=<your_designsafe_username>
DESIGNSAFE_PASSWORD=<your_designsafe_password>

Jobs

On DesignSafe Jupyter:

Install the latest version of dapi and restart the kernel (Kernel >> Restart Kernel):

# Remove any previous installations
!pip uninstall dapi -y
# Install
!pip install dapi --quiet
  • Import dapi library
import dapi
  • To list all functions in dapi
dir(dapi)

Database

from dapi.db import DSDatabase

db = DSDatabase("ngl")
sql = 'SELECT * FROM SITE'
df = db.read_sql(sql)
print(df)

# Optionally, close the database connection when done
db.close()

Support

For any questions, issues, or feedback submit an issue

Development

To develop or test the library locally. Install Poetry. In the current repository run the following commands

poetry shell
poetry install
poetry build

To run the unit test

poetry run pytest -v

License

dapi is licensed under the MIT License.

Authors

  • Krishna Kumar, University of Texas at Austin
  • Prof. Pedro Arduino, University of Washington
  • Prof. Scott Brandenberg, University of California Los Angeles

Documentation

View dapi API doc

Running documentation locally

To serve the MkDocs documentation locally:

poetry install
poetry run mkdocs serve

This will start a local server at http://127.0.0.1:8000/dapi/ where you can view the documentation.

API docs

To generate API docs:

pdoc --html --output-dir api-docs dapi --force

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dapi-0.4.2.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dapi-0.4.2-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file dapi-0.4.2.tar.gz.

File metadata

  • Download URL: dapi-0.4.2.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dapi-0.4.2.tar.gz
Algorithm Hash digest
SHA256 0863b47784acaa6d5cdc0801c86ed08a5c9d7099564850b576c238da31db59b7
MD5 aeb37453da0606378c5345b18150856b
BLAKE2b-256 8e2dc89d6a7fdb4db9247a6c3eded7ab0e3e9ee34819c9436013391c042081cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for dapi-0.4.2.tar.gz:

Publisher: pypi.yml on DesignSafe-CI/dapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dapi-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: dapi-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for dapi-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f22d04b8f8a248f53b42bca75956f514e952ef6f2217c62354fac6804c813fff
MD5 3da08769ca05e9c3c63c1f0c33139180
BLAKE2b-256 bae3f15ebd180231a19cb3b6ec57bfe793df8cdc50b584fdb0bbf966811741b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for dapi-0.4.2-py3-none-any.whl:

Publisher: pypi.yml on DesignSafe-CI/dapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page