From 8f1f69e8276976de06ff556a98b06c17eaf723db Mon Sep 17 00:00:00 2001 From: Krishna Kumar Date: Tue, 1 Oct 2024 07:48:44 -0500 Subject: [PATCH] TAPIS v3 update to README --- README.md | 8 +- dapi/__init__.py | 27 ++- dapi/jobs/__init__.py | 4 +- docs/dapi.html | 103 +++++++-- docs/dapi/jobs.html | 8 +- docs/search.js | 2 +- examples/mpm/template-mpm-run.ipynb | 342 ---------------------------- 7 files changed, 116 insertions(+), 378 deletions(-) delete mode 100644 examples/mpm/template-mpm-run.ipynb diff --git a/README.md b/README.md index 79f1c8a..3123ee5 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.md) [![Docs](https://img.shields.io/badge/view-docs-8A2BE2?color=8A2BE2)](https://designsafe-ci.github.io/dapi/dapi/index.html) -`dapi` is a library that simplifies the process of submitting, running, and monitoring [TAPIS v2 / AgavePy](https://agavepy.readthedocs.io/en/latest/index.html) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org). +`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). ## Features ### Jobs -* Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities. +* 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. @@ -131,10 +131,6 @@ To run the unit test poetry run pytest -v ``` -## Known Issues - -The project only works on `Python 3.9` due to AgavePy Issue [#125](https://github.com/TACC/agavepy/issues/125). - ## License diff --git a/dapi/__init__.py b/dapi/__init__.py index 7d609d2..66053e9 100644 --- a/dapi/__init__.py +++ b/dapi/__init__.py @@ -1,13 +1,34 @@ """ -`dapi` is a library that simplifies the process of submitting, running, and monitoring [TAPIS v2 / AgavePy](https://agavepy.readthedocs.io/en/latest/index.html) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org). - +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). ## Features -* Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities. +### 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 ```shell diff --git a/dapi/jobs/__init__.py b/dapi/jobs/__init__.py index 526fa3e..8dfcb52 100644 --- a/dapi/jobs/__init__.py +++ b/dapi/jobs/__init__.py @@ -1,10 +1,10 @@ """ -`dapi` job submodule simplifies the process of submitting, running, and monitoring [TAPIS v2 / AgavePy](https://agavepy.readthedocs.io/en/latest/index.html) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org). +`dapi` job submodule 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). ## Features -* Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities. +* Simplified TAPIS v3 Calls: 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. diff --git a/docs/dapi.html b/docs/dapi.html index fb5bae4..1e246f8 100644 --- a/docs/dapi.html +++ b/docs/dapi.html @@ -49,15 +49,57 @@

Submodules

dapi

-

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

+

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

Features

+

Jobs

+
    -
  • Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. dapi abstracts away the complexities.

  • +
  • 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:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Databasedbnameenv_prefix
NGLngl| NGL_
Earthake RecoveryeqEQ_
VpvpVP_
+ +

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

@@ -71,25 +113,46 @@

Installation

 1"""
- 2`dapi` is a library that simplifies the process of submitting, running, and monitoring [TAPIS v2 / AgavePy](https://agavepy.readthedocs.io/en/latest/index.html) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org).
+ 2dapi` 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).
  3
- 4
- 5## Features
- 6
- 7* Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities.
- 8
- 9* Seamless Integration with DesignSafe Jupyter Notebooks: Launch DesignSafe applications directly from the Jupyter environment.
-10
-11## Installation
-12
-13```shell
-14pip3 install dapi
-15```
-16
-17"""
-18from . import auth
-19from . import db
-20from . import jobs
+ 4## Features
+ 5
+ 6### Jobs
+ 7
+ 8* Get TAPIS v3 templates for jobs: No need to fiddle with complex API requests. `dapi` abstracts away the complexities.
+ 9
+10* Seamless Integration with DesignSafe Jupyter Notebooks: Launch DesignSafe applications directly from the Jupyter environment.
+11
+12### Database
+13
+14Connects to SQL databases on DesignSafe:
+15
+16| Database | dbname | env_prefix |
+17|----------|--------|------------|
+18| NGL | `ngl`| `NGL_` |
+19| Earthake Recovery | `eq` | `EQ_` |
+20| Vp | `vp` | `VP_` |
+21
+22Define the following environment variables:
+23```
+24{env_prefix}DB_USER
+25{env_prefix}DB_PASSWORD
+26{env_prefix}DB_HOST
+27{env_prefix}DB_PORT
+28```
+29
+30For 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"`.
+31
+32## Installation
+33
+34```shell
+35pip3 install dapi
+36```
+37
+38"""
+39from . import auth
+40from . import db
+41from . import jobs
 
diff --git a/docs/dapi/jobs.html b/docs/dapi/jobs.html index 0811927..cf51fe8 100644 --- a/docs/dapi/jobs.html +++ b/docs/dapi/jobs.html @@ -53,12 +53,12 @@

Submodules

dapi.jobs

-

dapi job submodule simplifies the process of submitting, running, and monitoring TAPIS v2 / AgavePy jobs on DesignSafe via Jupyter Notebooks.

+

dapi job submodule simplifies the process of submitting, running, and monitoring Tapis v3 jobs on DesignSafe via Jupyter Notebooks.

Features

    -
  • Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. dapi abstracts away the complexities.

  • +
  • Simplified TAPIS v3 Calls: 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.

@@ -75,12 +75,12 @@

Installation

 1"""
- 2`dapi` job submodule simplifies the process of submitting, running, and monitoring [TAPIS v2 / AgavePy](https://agavepy.readthedocs.io/en/latest/index.html) jobs on [DesignSafe](https://designsafe-ci.org) via [Jupyter Notebooks](https://jupyter.designsafe-ci.org).
+ 2`dapi` job submodule 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).
  3
  4
  5## Features
  6
- 7* Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities.
+ 7* Simplified TAPIS v3 Calls: No need to fiddle with complex API requests. `dapi` abstracts away the complexities.
  8
  9* Seamless Integration with DesignSafe Jupyter Notebooks: Launch DesignSafe applications directly from the Jupyter environment.
 10
diff --git a/docs/search.js b/docs/search.js
index 22c2c8c..9712b25 100644
--- a/docs/search.js
+++ b/docs/search.js
@@ -1,6 +1,6 @@
 window.pdocSearch = (function(){
 /** elasticlunr - http://weixsong.github.io * Copyright (C) 2017 Oliver Nightingale * Copyright (C) 2017 Wei Song * MIT Licensed */!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();odapi is a library that simplifies the process of submitting, running, and monitoring TAPIS v2 / AgavePy jobs on DesignSafe via Jupyter Notebooks.

\n\n

Features

\n\n
    \n
  • Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. dapi abstracts away the complexities.

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

  • \n
\n\n

Installation

\n\n
\n
pip3 install dapi\n
\n
\n"}, {"fullname": "dapi.auth", "modulename": "dapi.auth", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.auth.auth", "modulename": "dapi.auth.auth", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.auth.auth.init", "modulename": "dapi.auth.auth", "qualname": "init", "kind": "function", "doc": "

Initialize a Tapis object with authentication.\nTries to read credentials from environment variables first.\nIf not found, prompts the user for input.

\n\n

Returns:\n object: The authenticated Tapis object.

\n", "signature": "():", "funcdef": "def"}, {"fullname": "dapi.db", "modulename": "dapi.db", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.name", "modulename": "dapi.db", "qualname": "name", "kind": "variable", "doc": "

\n", "default_value": "'designsafe_db'"}, {"fullname": "dapi.db.config", "modulename": "dapi.db.config", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.config.db_config", "modulename": "dapi.db.config", "qualname": "db_config", "kind": "variable", "doc": "

\n", "default_value": "{'ngl': {'dbname': 'sjbrande_ngl_db', 'env_prefix': 'NGL_'}, 'vp': {'dbname': 'sjbrande_vpdb', 'env_prefix': 'VP_'}, 'eq': {'dbname': 'post_earthquake_recovery', 'env_prefix': 'EQ_'}}"}, {"fullname": "dapi.db.db", "modulename": "dapi.db.db", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase", "modulename": "dapi.db.db", "qualname": "DSDatabase", "kind": "class", "doc": "

A database utility class for connecting to a DesignSafe SQL database.

\n\n

This class provides functionality to connect to a MySQL database using\nSQLAlchemy and PyMySQL. It supports executing SQL queries and returning\nresults in different formats.

\n\n

Attributes:\n user (str): Database username, defaults to 'dspublic'.\n password (str): Database password, defaults to 'R3ad0nlY'.\n host (str): Database host address, defaults to '129.114.52.174'.\n port (int): Database port, defaults to 3306.\n db (str): Database name, can be 'sjbrande_ngl_db', 'sjbrande_vpdb', or 'post_earthquake_recovery'.\n recycle_time (int): Time in seconds to recycle database connections.\n engine (Engine): SQLAlchemy engine for database connection.\n Session (sessionmaker): SQLAlchemy session maker bound to the engine.

\n"}, {"fullname": "dapi.db.db.DSDatabase.__init__", "modulename": "dapi.db.db", "qualname": "DSDatabase.__init__", "kind": "function", "doc": "

Initializes the DSDatabase instance with environment variables and creates the database engine.

\n\n

Args:\n dbname (str): Shorthand for the database name. Must be one of 'ngl', 'vp', or 'eq'.

\n", "signature": "(dbname='ngl')"}, {"fullname": "dapi.db.db.DSDatabase.user", "modulename": "dapi.db.db", "qualname": "DSDatabase.user", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.password", "modulename": "dapi.db.db", "qualname": "DSDatabase.password", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.host", "modulename": "dapi.db.db", "qualname": "DSDatabase.host", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.port", "modulename": "dapi.db.db", "qualname": "DSDatabase.port", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.db", "modulename": "dapi.db.db", "qualname": "DSDatabase.db", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.engine", "modulename": "dapi.db.db", "qualname": "DSDatabase.engine", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.Session", "modulename": "dapi.db.db", "qualname": "DSDatabase.Session", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.read_sql", "modulename": "dapi.db.db", "qualname": "DSDatabase.read_sql", "kind": "function", "doc": "

Executes a SQL query and returns the results.

\n\n

Args:\n sql (str): The SQL query string to be executed.\n output_type (str, optional): The format for the query results. Defaults to 'DataFrame'.\n Possible values are 'DataFrame' for a pandas DataFrame, or 'dict' for a list of dictionaries.

\n\n

Returns:\n pandas.DataFrame or list of dict: The result of the SQL query.

\n\n

Raises:\n ValueError: If the SQL query string is empty or if the output type is not valid.\n SQLAlchemyError: If an error occurs during query execution.

\n", "signature": "(self, sql, output_type='DataFrame'):", "funcdef": "def"}, {"fullname": "dapi.db.db.DSDatabase.close", "modulename": "dapi.db.db", "qualname": "DSDatabase.close", "kind": "function", "doc": "

Close the database connection.

\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "dapi.jobs", "modulename": "dapi.jobs", "kind": "module", "doc": "

dapi job submodule simplifies the process of submitting, running, and monitoring TAPIS v2 / AgavePy jobs on DesignSafe via Jupyter Notebooks.

\n\n

Features

\n\n
    \n
  • Simplified TAPIS v2 Calls: No need to fiddle with complex API requests. dapi abstracts away the complexities.

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

  • \n
\n\n

Installation

\n\n
\n
pip3 install dapi\n
\n
\n"}, {"fullname": "dapi.jobs.dir", "modulename": "dapi.jobs.dir", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.jobs.dir.get_ds_path_uri", "modulename": "dapi.jobs.dir", "qualname": "get_ds_path_uri", "kind": "function", "doc": "

Given a path on DesignSafe, determine the correct input URI for Tapis v3.

\n\n

Args:\nt (Tapis): Tapis object to fetch profiles or metadata.\npath (str): The directory path.

\n\n

Returns:\nstr: The corresponding input URI.

\n\n

Raises:\nValueError: If no matching directory pattern is found.

\n", "signature": "(t: tapipy.tapis.Tapis, path: str) -> str:", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs", "modulename": "dapi.jobs.jobs", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.jobs.jobs.generate_job_info", "modulename": "dapi.jobs.jobs", "qualname": "generate_job_info", "kind": "function", "doc": "

Generates a job info dictionary based on the provided application name, job name, input URI, input file, and optional allocation.

\n\n

Args:\n t (object): The Tapis API client object.\n app_name (str): The name of the application to use for the job.\n input_uri (str): The URI of the input data for the job.\n input_file (str): The local file path to the input data for the job.\n job_name (str, optional): The name of the job to be created. Defaults to None.\n max_minutes (int, optional): The maximum number of minutes the job can run. Defaults to None.\n node_count (int, optional): The number of nodes to use for the job. Defaults to None.\n cores_per_node (int, optional): The number of cores per node for the job. Defaults to None.\n queue (str, optional): The queue to use for the job. Defaults to None.\n allocation (str, optional): The allocation to use for the job. Defaults to None.

\n\n

Returns:\n dict: The job info dictionary.

\n", "signature": "(\tt: Any,\tapp_name: str,\tinput_uri: str,\tinput_file: str,\tjob_name: str = None,\tmax_minutes: Optional[int] = None,\tnode_count: Optional[int] = None,\tcores_per_node: Optional[int] = None,\tqueue: Optional[str] = None,\tallocation: Optional[str] = None) -> Dict[str, Any]:", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs.get_status", "modulename": "dapi.jobs.jobs", "qualname": "get_status", "kind": "function", "doc": "

Retrieves and monitors the status of a job using Tapis API.\nThis function waits for the job to start, then monitors it for up to maxMinutes.

\n\n

Args:\nt (object): The Tapis API client object.\nmjobUuid (str): The unique identifier of the job to monitor.\ntlapse (int, optional): Time interval, in seconds, to wait between status checks. Defaults to 15 seconds.

\n\n

Returns:\nstr: The final status of the job (FINISHED, FAILED, or STOPPED).

\n", "signature": "(t, mjobUuid, tlapse=15):", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs.runtime_summary", "modulename": "dapi.jobs.jobs", "qualname": "runtime_summary", "kind": "function", "doc": "

Get the runtime of a job.\nArgs:\nt (object): The Tapis v3 client object.\njob_uuid (str): The UUID of the job for which the runtime needs to be determined.\nverbose (bool): If True, prints all history events. Otherwise, prints only specific statuses.\nReturns:\nNone: This function doesn't return a value, but it prints the runtime details.

\n", "signature": "(t, job_uuid, verbose=False):", "funcdef": "def"}]; + /** pdoc search index */const docs = [{"fullname": "dapi", "modulename": "dapi", "kind": "module", "doc": "

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

\n\n

Features

\n\n

Jobs

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

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

  • \n
\n\n

Database

\n\n

Connects to SQL databases on DesignSafe:

\n\n\n\n\n \n \n \n\n\n\n\n \n \n\n\n \n \n \n\n\n \n \n \n\n\n
Databasedbnameenv_prefix
NGLngl| NGL_
Earthake RecoveryeqEQ_
VpvpVP_
\n\n

Define the following environment variables:

\n\n
{env_prefix}DB_USER\n{env_prefix}DB_PASSWORD\n{env_prefix}DB_HOST\n{env_prefix}DB_PORT\n
\n\n

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

\n\n

Installation

\n\n
\n
pip3 install dapi\n
\n
\n"}, {"fullname": "dapi.auth", "modulename": "dapi.auth", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.auth.auth", "modulename": "dapi.auth.auth", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.auth.auth.init", "modulename": "dapi.auth.auth", "qualname": "init", "kind": "function", "doc": "

Initialize a Tapis object with authentication.\nTries to read credentials from environment variables first.\nIf not found, prompts the user for input.

\n\n

Returns:\n object: The authenticated Tapis object.

\n", "signature": "():", "funcdef": "def"}, {"fullname": "dapi.db", "modulename": "dapi.db", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.name", "modulename": "dapi.db", "qualname": "name", "kind": "variable", "doc": "

\n", "default_value": "'designsafe_db'"}, {"fullname": "dapi.db.config", "modulename": "dapi.db.config", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.config.db_config", "modulename": "dapi.db.config", "qualname": "db_config", "kind": "variable", "doc": "

\n", "default_value": "{'ngl': {'dbname': 'sjbrande_ngl_db', 'env_prefix': 'NGL_'}, 'vp': {'dbname': 'sjbrande_vpdb', 'env_prefix': 'VP_'}, 'eq': {'dbname': 'post_earthquake_recovery', 'env_prefix': 'EQ_'}}"}, {"fullname": "dapi.db.db", "modulename": "dapi.db.db", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase", "modulename": "dapi.db.db", "qualname": "DSDatabase", "kind": "class", "doc": "

A database utility class for connecting to a DesignSafe SQL database.

\n\n

This class provides functionality to connect to a MySQL database using\nSQLAlchemy and PyMySQL. It supports executing SQL queries and returning\nresults in different formats.

\n\n

Attributes:\n user (str): Database username, defaults to 'dspublic'.\n password (str): Database password, defaults to 'R3ad0nlY'.\n host (str): Database host address, defaults to '129.114.52.174'.\n port (int): Database port, defaults to 3306.\n db (str): Database name, can be 'sjbrande_ngl_db', 'sjbrande_vpdb', or 'post_earthquake_recovery'.\n recycle_time (int): Time in seconds to recycle database connections.\n engine (Engine): SQLAlchemy engine for database connection.\n Session (sessionmaker): SQLAlchemy session maker bound to the engine.

\n"}, {"fullname": "dapi.db.db.DSDatabase.__init__", "modulename": "dapi.db.db", "qualname": "DSDatabase.__init__", "kind": "function", "doc": "

Initializes the DSDatabase instance with environment variables and creates the database engine.

\n\n

Args:\n dbname (str): Shorthand for the database name. Must be one of 'ngl', 'vp', or 'eq'.

\n", "signature": "(dbname='ngl')"}, {"fullname": "dapi.db.db.DSDatabase.user", "modulename": "dapi.db.db", "qualname": "DSDatabase.user", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.password", "modulename": "dapi.db.db", "qualname": "DSDatabase.password", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.host", "modulename": "dapi.db.db", "qualname": "DSDatabase.host", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.port", "modulename": "dapi.db.db", "qualname": "DSDatabase.port", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.db", "modulename": "dapi.db.db", "qualname": "DSDatabase.db", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.engine", "modulename": "dapi.db.db", "qualname": "DSDatabase.engine", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.Session", "modulename": "dapi.db.db", "qualname": "DSDatabase.Session", "kind": "variable", "doc": "

\n"}, {"fullname": "dapi.db.db.DSDatabase.read_sql", "modulename": "dapi.db.db", "qualname": "DSDatabase.read_sql", "kind": "function", "doc": "

Executes a SQL query and returns the results.

\n\n

Args:\n sql (str): The SQL query string to be executed.\n output_type (str, optional): The format for the query results. Defaults to 'DataFrame'.\n Possible values are 'DataFrame' for a pandas DataFrame, or 'dict' for a list of dictionaries.

\n\n

Returns:\n pandas.DataFrame or list of dict: The result of the SQL query.

\n\n

Raises:\n ValueError: If the SQL query string is empty or if the output type is not valid.\n SQLAlchemyError: If an error occurs during query execution.

\n", "signature": "(self, sql, output_type='DataFrame'):", "funcdef": "def"}, {"fullname": "dapi.db.db.DSDatabase.close", "modulename": "dapi.db.db", "qualname": "DSDatabase.close", "kind": "function", "doc": "

Close the database connection.

\n", "signature": "(self):", "funcdef": "def"}, {"fullname": "dapi.jobs", "modulename": "dapi.jobs", "kind": "module", "doc": "

dapi job submodule simplifies the process of submitting, running, and monitoring Tapis v3 jobs on DesignSafe via Jupyter Notebooks.

\n\n

Features

\n\n
    \n
  • Simplified TAPIS v3 Calls: No need to fiddle with complex API requests. dapi abstracts away the complexities.

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

  • \n
\n\n

Installation

\n\n
\n
pip3 install dapi\n
\n
\n"}, {"fullname": "dapi.jobs.dir", "modulename": "dapi.jobs.dir", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.jobs.dir.get_ds_path_uri", "modulename": "dapi.jobs.dir", "qualname": "get_ds_path_uri", "kind": "function", "doc": "

Given a path on DesignSafe, determine the correct input URI for Tapis v3.

\n\n

Args:\nt (Tapis): Tapis object to fetch profiles or metadata.\npath (str): The directory path.

\n\n

Returns:\nstr: The corresponding input URI.

\n\n

Raises:\nValueError: If no matching directory pattern is found.

\n", "signature": "(t: tapipy.tapis.Tapis, path: str) -> str:", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs", "modulename": "dapi.jobs.jobs", "kind": "module", "doc": "

\n"}, {"fullname": "dapi.jobs.jobs.generate_job_info", "modulename": "dapi.jobs.jobs", "qualname": "generate_job_info", "kind": "function", "doc": "

Generates a job info dictionary based on the provided application name, job name, input URI, input file, and optional allocation.

\n\n

Args:\n t (object): The Tapis API client object.\n app_name (str): The name of the application to use for the job.\n input_uri (str): The URI of the input data for the job.\n input_file (str): The local file path to the input data for the job.\n job_name (str, optional): The name of the job to be created. Defaults to None.\n max_minutes (int, optional): The maximum number of minutes the job can run. Defaults to None.\n node_count (int, optional): The number of nodes to use for the job. Defaults to None.\n cores_per_node (int, optional): The number of cores per node for the job. Defaults to None.\n queue (str, optional): The queue to use for the job. Defaults to None.\n allocation (str, optional): The allocation to use for the job. Defaults to None.

\n\n

Returns:\n dict: The job info dictionary.

\n", "signature": "(\tt: Any,\tapp_name: str,\tinput_uri: str,\tinput_file: str,\tjob_name: str = None,\tmax_minutes: Optional[int] = None,\tnode_count: Optional[int] = None,\tcores_per_node: Optional[int] = None,\tqueue: Optional[str] = None,\tallocation: Optional[str] = None) -> Dict[str, Any]:", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs.get_status", "modulename": "dapi.jobs.jobs", "qualname": "get_status", "kind": "function", "doc": "

Retrieves and monitors the status of a job using Tapis API.\nThis function waits for the job to start, then monitors it for up to maxMinutes.

\n\n

Args:\nt (object): The Tapis API client object.\nmjobUuid (str): The unique identifier of the job to monitor.\ntlapse (int, optional): Time interval, in seconds, to wait between status checks. Defaults to 15 seconds.

\n\n

Returns:\nstr: The final status of the job (FINISHED, FAILED, or STOPPED).

\n", "signature": "(t, mjobUuid, tlapse=15):", "funcdef": "def"}, {"fullname": "dapi.jobs.jobs.runtime_summary", "modulename": "dapi.jobs.jobs", "qualname": "runtime_summary", "kind": "function", "doc": "

Get the runtime of a job.\nArgs:\nt (object): The Tapis v3 client object.\njob_uuid (str): The UUID of the job for which the runtime needs to be determined.\nverbose (bool): If True, prints all history events. Otherwise, prints only specific statuses.\nReturns:\nNone: This function doesn't return a value, but it prints the runtime details.

\n", "signature": "(t, job_uuid, verbose=False):", "funcdef": "def"}]; // mirrored in build-search-index.js (part 1) // Also split on html tags. this is a cheap heuristic, but good enough. diff --git a/examples/mpm/template-mpm-run.ipynb b/examples/mpm/template-mpm-run.ipynb deleted file mode 100644 index c9480cf..0000000 --- a/examples/mpm/template-mpm-run.ipynb +++ /dev/null @@ -1,342 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "4efabb5e", - "metadata": {}, - "source": [ - "# Templatized notebook for running CB-Geo MPM TAPIS job" - ] - }, - { - "cell_type": "markdown", - "id": "abe5d8a3-32da-4233-b605-9fd51d053ec1", - "metadata": {}, - "source": [ - "## Install DSJobs" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "b7fa3e9a-7bf3-441c-917f-fb57a94ee017", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.2\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" - ] - } - ], - "source": [ - "!pip install dapi --quiet" - ] - }, - { - "cell_type": "markdown", - "id": "dd802d14-8cb5-49e7-b43c-1c21ac253961", - "metadata": {}, - "source": [ - "## Modify MPM Job parameters\n", - "\n", - "> Only change the cell below" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "8593c08c-c96a-4a66-9b52-80b8b5c27e44", - "metadata": { - "tags": [ - "parameters" - ] - }, - "outputs": [], - "source": [ - "# Default parameters for the MPM template notebook\n", - "path: str = \"/MyData/mpm-benchmarks/2d/uniaxial_stress/\" # path to input file\n", - "\n", - "input_file: str = \"mpm.json\" # input file.json\n", - "\n", - "duration: str = \"00:10:00\" # Runtime duration ('HH:MM:SS')\n", - "\n", - "# The parameters modified in your job will be included in the cell below." - ] - }, - { - "cell_type": "markdown", - "id": "89d9596b-1c14-4d0c-a127-ee6c46da2671", - "metadata": {}, - "source": [ - "## Imports" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "91b811a4-45d9-4223-a145-c0f4e393af66", - "metadata": {}, - "outputs": [], - "source": [ - "from agavepy.agave import Agave\n", - "import dapi\n", - "import json\n", - "import os" - ] - }, - { - "cell_type": "markdown", - "id": "14a18561-3bf7-4605-a6f4-98ab0b99af10", - "metadata": {}, - "source": [ - "## Configure and run MPM job" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "0153c5cc-f4b9-460b-b4c6-d92eb8c6ede5", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "---Job Info---\n", - "\n", - "{\n", - " \"appId\": \"mpm-1.1.0u3\",\n", - " \"name\": \"mpm-uniaxial\",\n", - " \"batchQueue\": \"development\",\n", - " \"nodeCount\": 1,\n", - " \"processorsPerNode\": 1,\n", - " \"memoryPerNode\": \"1\",\n", - " \"maxRunTime\": \"00:10:00\",\n", - " \"archive\": true,\n", - " \"inputs\": {\n", - " \"inputDirectory\": [\n", - " \"agave://designsafe.storage.default/kks32/mpm-benchmarks/2d/uniaxial_stress/\"\n", - " ]\n", - " },\n", - " \"parameters\": {\n", - " \"inputfile\": [\n", - " \"mpm.json\"\n", - " ]\n", - " }\n", - "}\n" - ] - } - ], - "source": [ - "# authenticate\n", - "ag = Agave.restore()\n", - "\n", - "# generate and modify job info\n", - "job_info = dapi.jobs.generate_job_info(\n", - " ag, appid=\"mpm-1.1.0u3\", jobname=\"mpm-uniaxial\", runtime=duration\n", - ")\n", - "\n", - "# specify input path and file\n", - "job_info[\"inputs\"] = {\"inputDirectory\": [dapi.jobs.get_ds_path_uri(ag, path)]}\n", - "job_info[\"parameters\"] = {\"inputfile\": [input_file]}\n", - "print(\"\\n---Job Info---\\n\\n\" + json.dumps(job_info, indent=2))" - ] - }, - { - "cell_type": "markdown", - "id": "9851e692-2ba8-4cb0-887f-b639ba8832d2", - "metadata": {}, - "source": [ - "## Submit and monitor job status" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "4e6dc010-d821-45d5-805b-84620363f468", - "metadata": {}, - "outputs": [], - "source": [ - "job = ag.jobs.submit(body=job_info)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "06dd17dc-2540-46b3-9036-3245a9b6cfae", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Waiting for job to start: 2it [00:30, 15.14s/it, Status: RUNNING]\n", - "Monitoring job: 0%| | 0/40 [00:00