Skip to content

Commit

Permalink
MPM template notebook with archive support
Browse files Browse the repository at this point in the history
  • Loading branch information
kks32 committed Oct 27, 2023
1 parent f9b206a commit e126568
Showing 1 changed file with 112 additions and 37 deletions.
149 changes: 112 additions & 37 deletions example-notebooks/template-mpm-run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand All @@ -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"
]
},
{
Expand All @@ -85,32 +118,54 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"id": "0153c5cc-f4b9-460b-b4c6-d92eb8c6ede5",
"metadata": {},
"outputs": [
{
"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))"
]
},
{
Expand All @@ -123,7 +178,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "4e6dc010-d821-45d5-805b-84620363f468",
"metadata": {},
"outputs": [],
Expand All @@ -133,15 +188,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"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",
"Waiting for job to start: 2it [00:30, 15.13s/it, Status: RUNNING] \n",
"Monitoring job: 0%| | 0/40 [00:00<?, ?it/s]"
]
},
Expand All @@ -152,20 +207,6 @@
"\tStatus: RUNNING\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Monitoring job: 10%|████▊ | 4/40 [01:00<09:04, 15.12s/it]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\tStatus: ARCHIVING\n"
]
},
{
"name": "stderr",
"output_type": "stream",
Expand Down Expand Up @@ -193,7 +234,7 @@
"'FINISHED'"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -204,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"id": "614f3568-d290-44d9-896d-608375293a58",
"metadata": {},
"outputs": [
Expand All @@ -219,23 +260,57 @@
"STAGING_INPUTS time: 0:00:04\n",
"STAGED time: 0:00:00\n",
"STAGING_JOB time: 0:00:04\n",
"SUBMITTING time: 0:00:05\n",
"SUBMITTING time: 0:00:06\n",
"QUEUED time: 0:00:05\n",
"RUNNING time: 0:01:08\n",
"RUNNING time: 0:01:09\n",
"CLEANING_UP time: 0:00:00\n",
"ARCHIVING time: 0:00:08\n",
"TOTAL time: 0:01:37\n",
"ARCHIVING time: 0:00:09\n",
"TOTAL time: 0:01:40\n",
"---------------\n"
]
}
],
"source": [
"ds.runtime_summary(ag, job[\"id\"])"
]
},
{
"cell_type": "markdown",
"id": "798bd1bc-44e9-4e2f-b999-0ecf3ee769a4",
"metadata": {},
"source": [
"## Archive path to view output results"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "209aae22-98fc-454c-bbd4-1946dfb4b5be",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/home/jupyter/MyData/archive/jobs/job-cdd40c86-e9a1-43bc-8b68-934826e513aa-007'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get local archive path on DesignSafe\n",
"archive_path = ds.get_archive_path(ag, job[\"id\"])\n",
"# Navigate to results folder\n",
"os.chdir(archive_path)\n",
"# Print current directory\n",
"os.getcwd()"
]
}
],
"metadata": {
"IMAGE_NAME": "taccsciapps/ds-nb-img:base-0.1.2",
"IMAGE_NAME": "taccsciapps/ds-nb-img:base-0.1.3",
"UUID": "ad99fe82-d690-11ec-8bc3-165d4cd45074",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
Expand Down

0 comments on commit e126568

Please sign in to comment.