From e126568fb8bff67528206c66f732e2ed0089490b Mon Sep 17 00:00:00 2001 From: Krishna Kumar Date: Fri, 27 Oct 2023 17:53:56 -0500 Subject: [PATCH] MPM template notebook with archive support --- example-notebooks/template-mpm-run.ipynb | 149 +++++++++++++++++------ 1 file changed, 112 insertions(+), 37 deletions(-) diff --git a/example-notebooks/template-mpm-run.ipynb b/example-notebooks/template-mpm-run.ipynb index df364a0..42db1ee 100644 --- a/example-notebooks/template-mpm-run.ipynb +++ b/example-notebooks/template-mpm-run.ipynb @@ -41,7 +41,17 @@ "execution_count": 2, "id": "b7fa3e9a-7bf3-441c-917f-fb57a94ee017", "metadata": {}, - "outputs": [], + "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.1\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 git+https://github.com/DesignSafe-CI/dsjobs.git --quiet" ] @@ -68,11 +78,34 @@ "outputs": [], "source": [ "# Default parameters for the MPM template notebook\n", - "path: str = \"/MyData/mpm-benchmarks/2d/uniaxial_stress/\" # path to input file\n", + "path: str = '/MyData/mpm-benchmarks/2d/uniaxial_stress/' # path to input file\n", "\n", - "input_file: str = \"mpm.json\" # input file.json\n", + "input_file: str = 'mpm.json' # input file.json\n", "\n", - "# The parameters modified in your job will be embedded below." + "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": 4, + "id": "91b811a4-45d9-4223-a145-c0f4e393af66", + "metadata": {}, + "outputs": [], + "source": [ + "from agavepy.agave import Agave\n", + "import dsjobs as ds\n", + "import json\n", + "import os" ] }, { @@ -85,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "0153c5cc-f4b9-460b-b4c6-d92eb8c6ede5", "metadata": {}, "outputs": [ @@ -93,24 +126,46 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'appId': 'mpm-1.0.0', 'name': 'mpm-uniaxial', 'batchQueue': 'skx-dev', 'nodeCount': 1, 'processorsPerNode': 1, 'memoryPerNode': '1', 'maxRunTime': '00:10:00', 'archive': True, 'inputs': {'inputDirectory': ['agave://designsafe.storage.default/kks32/mpm-benchmarks/2d/uniaxial_stress/']}, 'parameters': {'inputfile': ['mpm.json']}}\n" + "\n", + "---Job Info---\n", + "\n", + "{\n", + " \"appId\": \"mpm-1.0.0\",\n", + " \"name\": \"mpm-uniaxial\",\n", + " \"batchQueue\": \"skx-dev\",\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": [ - "from agavepy.agave import Agave\n", - "import dsjobs as ds\n", - "\n", "# authenticate\n", "ag = Agave.restore()\n", "\n", "# generate and modify job info\n", - "job_info = ds.generate_job_info(ag, appid=\"mpm-1.0.0\", jobname=\"mpm-uniaxial\")\n", + "job_info = ds.generate_job_info(ag, \n", + " appid='mpm-1.0.0', \n", + " jobname='mpm-uniaxial', \n", + " runtime=duration)\n", "\n", "# specify input path and file\n", - "job_info[\"inputs\"] = {\"inputDirectory\": [ds.get_ds_path_uri(ag, path)]}\n", - "job_info[\"parameters\"] = {\"inputfile\": [input_file]}\n", - "print(job_info)" + "job_info[\"inputs\"] = {\"inputDirectory\": [ ds.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))" ] }, { @@ -123,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "4e6dc010-d821-45d5-805b-84620363f468", "metadata": {}, "outputs": [], @@ -133,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "06dd17dc-2540-46b3-9036-3245a9b6cfae", "metadata": {}, "outputs": [ @@ -141,7 +196,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "Waiting for job to start: 2it [00:30, 15.14s/it, Status: RUNNING] \n", + "Waiting for job to start: 2it [00:30, 15.13s/it, Status: RUNNING] \n", "Monitoring job: 0%| | 0/40 [00:00