This is an automated email from the ASF dual-hosted git repository. lahirujayathilake pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata.git
commit d3c191c8f324fca06694797b6da5022d3f94cf20 Author: lahiruj <[email protected]> AuthorDate: Tue Mar 4 15:15:20 2025 -0500 gkeyll agent image and notebook sample --- .../deployments/agent-gkeyll/Dockerfile | 6 + .../deployments/agent-gkeyll/Makefile | 17 +++ .../deployments/agent-gkeyll/README.md | 13 ++ .../jupyterhub/data/gkeyll/plotE_z.ipynb | 157 +++++++++++++++++++++ 4 files changed, 193 insertions(+) diff --git a/modules/agent-framework/deployments/agent-gkeyll/Dockerfile b/modules/agent-framework/deployments/agent-gkeyll/Dockerfile new file mode 100644 index 0000000000..c31b6bc02d --- /dev/null +++ b/modules/agent-framework/deployments/agent-gkeyll/Dockerfile @@ -0,0 +1,6 @@ +FROM cybershuttle/remote-agent-base:latest + +USER root + +RUN micromamba run -n base pip install --no-cache-dir \ + postgkyl \ No newline at end of file diff --git a/modules/agent-framework/deployments/agent-gkeyll/Makefile b/modules/agent-framework/deployments/agent-gkeyll/Makefile new file mode 100644 index 0000000000..99894ee49c --- /dev/null +++ b/modules/agent-framework/deployments/agent-gkeyll/Makefile @@ -0,0 +1,17 @@ +IMAGE_NAME=cybershuttle/remote-agent-gkeyll +AGENT_SVC_URL=api.gateway.cybershuttle.org:19900 +AGENT_ID=testx + +build-container: + docker build --platform linux/amd64 -t $(IMAGE_NAME) . && \ + docker push $(IMAGE_NAME) + +run-container: + docker run -it $(IMAGE_NAME) /opt/airavata-agent $(AGENT_SVC_URL) $(AGENT_ID) + +deploy-anvil: + ssh [email protected] srun -p shared --mem 4G -t 30 singularity pull \ + --disable-cache \ + --force \ + agent-framework/container/remote-agent-gkeyll2.sif \ + docker://$(IMAGE_NAME) \ No newline at end of file diff --git a/modules/agent-framework/deployments/agent-gkeyll/README.md b/modules/agent-framework/deployments/agent-gkeyll/README.md new file mode 100644 index 0000000000..99b9169afb --- /dev/null +++ b/modules/agent-framework/deployments/agent-gkeyll/README.md @@ -0,0 +1,13 @@ +# Cerebrum Agent + +### Building + +```shell +make build-container +``` + +### Running Locally + +```shell +make run-container +``` diff --git a/modules/agent-framework/deployments/jupyterhub/data/gkeyll/plotE_z.ipynb b/modules/agent-framework/deployments/jupyterhub/data/gkeyll/plotE_z.ipynb new file mode 100644 index 0000000000..49de4e2389 --- /dev/null +++ b/modules/agent-framework/deployments/jupyterhub/data/gkeyll/plotE_z.ipynb @@ -0,0 +1,157 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "ec13f649-d9ee-47a2-9761-131abb1e2858", + "metadata": {}, + "source": [ + "#### Initialize, Authenticate, and Configure Remote Execution Environment\n", + "\n", + "##### Start a Cybershuttle Remote Executor: This will submit a remote job to Anvil\n", + "- **Cluster** - Anvil\n", + "- **Community Allocation** - Gkeyll\n", + "- **Requested Resources** - 4 CPUs, 4GB Memory, 60 Minutes, Shared Queue" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ae3f8f6f-2c94-44de-9a33-073a02bf05a4", + "metadata": {}, + "outputs": [], + "source": [ + "%pip install --force-reinstall airavata-jupyter-magic\n", + "import airavata_jupyter_magic\n", + "\n", + "%authenticate\n", + "%request_runtime test_cpu --cluster=Anvil --cpus=4 --memory=4096 --walltime=60 --queue=shared --group=Gkeyll\n", + "%switch_runtime test_cpu" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "aebd5d11-8f1d-4251-99e2-60bd06bed837", + "metadata": {}, + "outputs": [], + "source": [ + "!ls /anvil/projects/x-phy220105/cwsmith/vlabApps/gkyldataset" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c5308aa-a6d2-4b8e-8e9e-ad6c2a6b7380", + "metadata": {}, + "outputs": [], + "source": [ + "from pathlib import Path\n", + "import matplotlib.pyplot as plt \n", + "\n", + "import os\n", + "\n", + "import postgkyl as pg\n", + "\n", + "data_base_path = \"/anvil/projects/x-phy220105/cwsmith/vlabApps/gkyldataset\"\n", + "run = Path.cwd()\n", + "\n", + "def getModelType():\n", + " frame = 0 \n", + " models = [\"5m\", \"10m\"]\n", + " for model in models:\n", + " path = Path(f\"{data_base_path}/rt-{model}-gem_field_{frame}.bp\")\n", + " if path.is_file():\n", + " return model\n", + " error = \"Failed to find input ADIOS file rt-5m-gem_field_0.bp or rt-10m-gem_field_0.bp.\"\n", + " assert False, error" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9723cde9-abad-4d95-85cb-c618b383ae48", + "metadata": {}, + "outputs": [], + "source": [ + "frame = 0 \n", + "model = getModelType()\n", + "filename = run / f\"{data_base_path}/rt-{model}-gem_field_{frame}.bp\"\n", + "filename = str(filename)\n", + "print(filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bcc09aec-5821-4e58-ad38-3765afc28fc3", + "metadata": {}, + "outputs": [], + "source": [ + "gdata = pg.GData(filename)\n", + "\n", + "vals = gdata.getValues() # cell-center values, shape is Ny * Nx * Ncomponents\n", + "grid = gdata.getGrid() # cell corner coordinates\n", + "ndim = gdata.getNumDims() # number of spatial dimensions\n", + "\n", + "assert len(vals.shape) == ndim+1 and len(grid) == ndim\n", + "\n", + "icomp = 3 \n", + "compName = r'$E_z^2$'\n", + "fileName = \"E_z.png\"\n", + "\n", + "my_vals = vals[..., icomp]\n", + "x, y = grid\n", + "\n", + "fig, ax = plt.subplots()\n", + "\n", + "im = ax.pcolormesh(x, y, my_vals.T)\n", + "fig.colorbar(im, ax=ax)\n", + "\n", + "ax.set_xlabel('x')\n", + "ax.set_ylabel('y')\n", + "ax.set_title(compName)\n", + "ax.set_aspect(1)" + ] + }, + { + "cell_type": "markdown", + "id": "eee0d482-0d84-41d0-bf6d-820ac7c3bbf3", + "metadata": {}, + "source": [ + "#### To Stop the Agent Run" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2a5581f6-e963-4e2b-bd6e-8a122e906ca6", + "metadata": {}, + "outputs": [], + "source": [ + "%stop_runtime test_cpu\n", + "%switch_runtime local" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}
