From 71c06aa71253d55786c40535b01bbfdb19835b1b Mon Sep 17 00:00:00 2001 From: Bart Schilperoort Date: Thu, 11 Jan 2024 08:03:28 +0100 Subject: [PATCH] Move BMI code to bmi module --- Dockerfile | 2 +- PyStemmusScope/{ => bmi}/docker_process.py | 0 .../{bmi.py => bmi/implementation.py} | 6 ++--- PyStemmusScope/{ => bmi}/local_process.py | 0 PyStemmusScope/{bmi_utils.py => bmi/utils.py} | 0 docs/notebooks/BMI_demo.ipynb | 27 ++++++++++--------- 6 files changed, 18 insertions(+), 17 deletions(-) rename PyStemmusScope/{ => bmi}/docker_process.py (100%) rename PyStemmusScope/{bmi.py => bmi/implementation.py} (98%) rename PyStemmusScope/{ => bmi}/local_process.py (100%) rename PyStemmusScope/{bmi_utils.py => bmi/utils.py} (100%) diff --git a/Dockerfile b/Dockerfile index 57889635..6e26a813 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,4 +27,4 @@ WORKDIR / ENV STEMMUS_SCOPE ./STEMMUS_SCOPE # Start grpc4bmi server -CMD run-bmi-server --name "PyStemmusScope.bmi.StemmusScopeBmi" --port 55555 --debug +CMD run-bmi-server --name "PyStemmusScope.bmi.implementation.StemmusScopeBmi" --port 55555 --debug diff --git a/PyStemmusScope/docker_process.py b/PyStemmusScope/bmi/docker_process.py similarity index 100% rename from PyStemmusScope/docker_process.py rename to PyStemmusScope/bmi/docker_process.py diff --git a/PyStemmusScope/bmi.py b/PyStemmusScope/bmi/implementation.py similarity index 98% rename from PyStemmusScope/bmi.py rename to PyStemmusScope/bmi/implementation.py index f55c5a24..f301e7ed 100644 --- a/PyStemmusScope/bmi.py +++ b/PyStemmusScope/bmi/implementation.py @@ -8,7 +8,7 @@ import h5py import numpy as np from bmipy.bmi import Bmi -from PyStemmusScope.bmi_utils import InapplicableBmiMethods +from PyStemmusScope.bmi.utils import InapplicableBmiMethods from PyStemmusScope.config_io import read_config @@ -176,7 +176,7 @@ def load_process(mode: Literal["exe", "docker"]) -> type[StemmusScopeProcess]: """Load the right STEMMUS_SCOPE process.""" if mode == "docker": try: - from PyStemmusScope.docker_process import StemmusScopeDocker as Process + from PyStemmusScope.bmi.docker_process import StemmusScopeDocker as Process except ImportError as err: msg = ( "The docker python package is not available." @@ -184,7 +184,7 @@ def load_process(mode: Literal["exe", "docker"]) -> type[StemmusScopeProcess]: ) raise ImportError(msg) from err elif mode == "exe": - from PyStemmusScope.local_process import LocalStemmusScope as Process + from PyStemmusScope.bmi.local_process import LocalStemmusScope as Process else: msg = "Unknown mode." raise ValueError(msg) diff --git a/PyStemmusScope/local_process.py b/PyStemmusScope/bmi/local_process.py similarity index 100% rename from PyStemmusScope/local_process.py rename to PyStemmusScope/bmi/local_process.py diff --git a/PyStemmusScope/bmi_utils.py b/PyStemmusScope/bmi/utils.py similarity index 100% rename from PyStemmusScope/bmi_utils.py rename to PyStemmusScope/bmi/utils.py diff --git a/docs/notebooks/BMI_demo.ipynb b/docs/notebooks/BMI_demo.ipynb index 393d93a4..61c47e96 100644 --- a/docs/notebooks/BMI_demo.ipynb +++ b/docs/notebooks/BMI_demo.ipynb @@ -17,8 +17,8 @@ "metadata": {}, "outputs": [], "source": [ - "#cfg_file = \"/home/bart/tmp/stemmus_scope/config_docker.txt\"\n", - "cfg_file = \"/home/bart/tmp/stemmus_scope/config_exe.txt\"" + "cfg_file = \"/home/bart/tmp/stemmus_scope/config_docker.txt\"\n", + "# cfg_file = \"/home/bart/tmp/stemmus_scope/config_exe.txt\"" ] }, { @@ -42,7 +42,8 @@ " \"/home/bart/matlab_runtime/R2023a/sys/os/glnxa64:\"\n", " \"/home/bart/matlab_runtime/R2023a/extern/bin/glnxa64:\"\n", " \"/home/bart/matlab_runtime/R2023a/sys/opengl/lib/glnxa64\"\n", - " )" + " )\n", + " os.environ[\"STEMMUS_SCOPE\"] = \"/home/bart/Downloads/STEMMUS_SCOPE\"" ] }, { @@ -58,7 +59,7 @@ "metadata": {}, "outputs": [], "source": [ - "from PyStemmusScope.bmi import StemmusScopeBmi\n", + "from PyStemmusScope.bmi.implementation import StemmusScopeBmi\n", "from cftime import num2pydate\n", "from rich import print\n", "import numpy as np\n", @@ -157,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -166,7 +167,7 @@ "array([22.74423625])" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -187,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -221,7 +222,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -254,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -271,16 +272,16 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" }, @@ -308,7 +309,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [