diff --git a/examples/mpm/template-mpm-v3.ipynb b/examples/mpm/template-mpm-v3.ipynb new file mode 100644 index 0000000..323620f --- /dev/null +++ b/examples/mpm/template-mpm-v3.ipynb @@ -0,0 +1,550 @@ +{ + "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 DesignSafe API (dapi)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "8479c1ee-d621-44bb-8d77-7d8f2fe72c27", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: setuptools in /home/kks32/.local/lib/python3.10/site-packages (75.1.0)\n" + ] + } + ], + "source": [ + "!pip install --user --upgrade setuptools" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "bc693a16-4a20-4289-9e32-bfb3da4df601", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Requirement already satisfied: atomicwrites==1.4.0 in /home/kks32/.local/lib/python3.10/site-packages (1.4.0)\n" + ] + } + ], + "source": [ + "!pip install --user --only-binary=:all: atomicwrites==1.4.0" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "ddb991fa-5bee-4e8e-94bf-982601cfa753", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install --user jsonschema>=4.18.0" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "99f68a43-7d8d-4349-a88f-2ddb3be81a28", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting git+https://github.com/DesignSafe-CI/dapi.git@tapisv3\n", + " Cloning https://github.com/DesignSafe-CI/dapi.git (to revision tapisv3) to /tmp/pip-req-build-rlxjpkq5\n", + " Running command git clone --filter=blob:none --quiet https://github.com/DesignSafe-CI/dapi.git /tmp/pip-req-build-rlxjpkq5\n", + " Running command git checkout -b tapisv3 --track origin/tapisv3\n", + " Switched to a new branch 'tapisv3'\n", + " Branch 'tapisv3' set up to track remote branch 'tapisv3' from 'origin'.\n", + " Resolved https://github.com/DesignSafe-CI/dapi.git to commit 93eb0c04a3e37805c9ee695b8bbf3ab74ad8d4aa\n", + " Installing build dependencies ... \u001b[?25ldone\n", + "\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n", + "\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n", + "\u001b[?25hRequirement already satisfied: exceptiongroup<2.0.0,>=1.2.0 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (1.2.2)\n", + "Requirement already satisfied: numpy<3.0.0,>=2.1.1 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (2.1.1)\n", + "Requirement already satisfied: pandas<3.0.0,>=2.2.3 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (2.2.3)\n", + "Requirement already satisfied: pymysql<2.0.0,>=1.1.0 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (1.1.1)\n", + "Requirement already satisfied: python-dotenv<2.0.0,>=1.0.1 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (1.0.1)\n", + "Requirement already satisfied: sqlalchemy<3.0.0,>=2.0.23 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (2.0.35)\n", + "Requirement already satisfied: tapipy<2.0.0,>=1.6.3 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (1.6.3)\n", + "Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /home/kks32/.local/lib/python3.10/site-packages (from dapi==1.0.0) (4.66.5)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0.0,>=2.2.3->dapi==1.0.0) (2.8.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0.0,>=2.2.3->dapi==1.0.0) (2022.4)\n", + "Requirement already satisfied: tzdata>=2022.7 in /opt/conda/lib/python3.10/site-packages (from pandas<3.0.0,>=2.2.3->dapi==1.0.0) (2024.1)\n", + "Requirement already satisfied: typing-extensions>=4.6.0 in /home/kks32/.local/lib/python3.10/site-packages (from sqlalchemy<3.0.0,>=2.0.23->dapi==1.0.0) (4.12.2)\n", + "Requirement already satisfied: greenlet!=0.4.17 in /opt/conda/lib/python3.10/site-packages (from sqlalchemy<3.0.0,>=2.0.23->dapi==1.0.0) (1.1.3)\n", + "Requirement already satisfied: PyJWT>=1.7.1 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2.5.0)\n", + "Requirement already satisfied: atomicwrites<2.0.0,>=1.4.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.4.0)\n", + "Requirement already satisfied: certifi>=2020.11.8 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2022.9.24)\n", + "Requirement already satisfied: cloudpickle>=1.6.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (3.0.0)\n", + "Requirement already satisfied: cryptography>=3.3.2 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (38.0.1)\n", + "Requirement already satisfied: jsonschema>=3.2.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (4.17.3)\n", + "Requirement already satisfied: openapi_core==0.16.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.16.0)\n", + "Requirement already satisfied: openapi_spec_validator<0.6.0,>=0.5.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.5.4)\n", + "Requirement already satisfied: pyyaml>=5.4 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (6.0.2)\n", + "Requirement already satisfied: requests<3.0.0,>=2.20.0 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2.32.3)\n", + "Requirement already satisfied: setuptools>=21.0.0 in /home/kks32/.local/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (75.1.0)\n", + "Requirement already satisfied: six<2.0,>=1.10 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.16.0)\n", + "Requirement already satisfied: urllib3<2.0.0,>=1.26.5 in /opt/conda/lib/python3.10/site-packages (from tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.26.11)\n", + "Requirement already satisfied: isodate in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.6.1)\n", + "Requirement already satisfied: jsonschema-spec<0.2.0,>=0.1.1 in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.1.6)\n", + "Requirement already satisfied: more-itertools in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (10.5.0)\n", + "Requirement already satisfied: openapi-schema-validator<0.4.0,>=0.3.0 in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.3.4)\n", + "Requirement already satisfied: parse in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.20.2)\n", + "Requirement already satisfied: pathable<0.5.0,>=0.4.0 in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.4.3)\n", + "Requirement already satisfied: werkzeug in /home/kks32/.local/lib/python3.10/site-packages (from openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (3.0.4)\n", + "Requirement already satisfied: cffi>=1.12 in /opt/conda/lib/python3.10/site-packages (from cryptography>=3.3.2->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.15.1)\n", + "Requirement already satisfied: attrs>=17.4.0 in /opt/conda/lib/python3.10/site-packages (from jsonschema>=3.2.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (24.2.0)\n", + "Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /opt/conda/lib/python3.10/site-packages (from jsonschema>=3.2.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (0.18.1)\n", + "Requirement already satisfied: lazy-object-proxy<2.0.0,>=1.7.1 in /home/kks32/.local/lib/python3.10/site-packages (from openapi_spec_validator<0.6.0,>=0.5.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (1.10.0)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.20.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2.1.1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.10/site-packages (from requests<3.0.0,>=2.20.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (3.4)\n", + "Requirement already satisfied: pycparser in /opt/conda/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=3.3.2->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2.21)\n", + "Requirement already satisfied: MarkupSafe>=2.1.1 in /opt/conda/lib/python3.10/site-packages (from werkzeug->openapi_core==0.16.0->tapipy<2.0.0,>=1.6.3->dapi==1.0.0) (2.1.1)\n" + ] + } + ], + "source": [ + "!pip install git+https://github.com/DesignSafe-CI/dapi.git@tapisv3 --user" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b7fa3e9a-7bf3-441c-917f-fb57a94ee017", + "metadata": {}, + "outputs": [], + "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": 6, + "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": 13, + "id": "58d09a12-300a-4cd3-9722-b4de8e4cc8d2", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import dapi\n", + "import json" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "fd5b809f-5bc5-4e49-9ae7-e5a4b44e70c3", + "metadata": {}, + "outputs": [], + "source": [ + "# Authenticate \n", + "t = dapi.auth.init()" + ] + }, + { + "cell_type": "markdown", + "id": "14a18561-3bf7-4605-a6f4-98ab0b99af10", + "metadata": {}, + "source": [ + "## Configure and run MPM job" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "f73c5bab-83d8-4f23-8752-4ad150b4dc59", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tapis://designsafe.storage.default/kks32/mpm-benchmarks/2d/uniaxial_stress/\n" + ] + } + ], + "source": [ + "# Identify folder with input file in DesignSafe\n", + "input_uri = dapi.jobs.get_ds_path_uri(t, path)\n", + "print(input_uri)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "b6b3818d-0358-487d-a67b-f91b6431b290", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "---Job Info---\n", + "\n", + "{\n", + " \"name\": \"mpm_20241001_114511\",\n", + " \"appId\": \"mpm\",\n", + " \"appVersion\": \"1.1.0\",\n", + " \"execSystemId\": \"frontera\",\n", + " \"maxMinutes\": 10,\n", + " \"archiveOnAppError\": true,\n", + " \"fileInputs\": [\n", + " {\n", + " \"name\": \"Input Directory\",\n", + " \"sourceUrl\": \"tapis://designsafe.storage.default/kks32/mpm-benchmarks/2d/uniaxial_stress/\"\n", + " }\n", + " ],\n", + " \"execSystemLogicalQueue\": \"development\",\n", + " \"nodeCount\": 1,\n", + " \"coresPerNode\": 1,\n", + " \"parameterSet\": {\n", + " \"appArgs\": [\n", + " {\n", + " \"name\": \"Input Script\",\n", + " \"arg\": \"mpm.json\"\n", + " }\n", + " ],\n", + " \"schedulerOptions\": [\n", + " {\n", + " \"name\": \"TACC Allocation\",\n", + " \"arg\": \"-A BCS20003\"\n", + " }\n", + " ]\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "# Generate job info for mpm\n", + "job_info = dapi.jobs.generate_job_info(t, 'mpm', input_uri, input_file, allocation='BCS20003')\n", + "job_info['maxMinutes'] = 10\n", + "job_info['execSystemLogicalQueue'] = 'development'\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": 17, + "id": "004bdcf4-c93b-4770-805d-bfd05d47d7b6", + "metadata": {}, + "outputs": [], + "source": [ + "# Submit job\n", + "job = t.jobs.submitJob(**job_info)\n", + "jobUuid=job.uuid" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "17c70c97-aea3-4b92-af78-5fd63592ecd6", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Waiting for job to start: 0it [00:00, ?it/s]\n", + "Monitoring job: 0%| | 0/40 [00:00