Skip to content

Commit

Permalink
Merge pull request #513 from uaf-arctic-eco-modeling/508-update-examp…
Browse files Browse the repository at this point in the history
…le-notebooks-and-scripts-to-match-docker-reorganization

Fixes #508 update example notebooks and scripts to match docker reorganization
  • Loading branch information
tobeycarman authored Oct 11, 2022
2 parents 80641f8 + bb36dcd commit 582161f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion scripts/Docker-sensitivity-workflow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"1. Strat the containers <br/>\n",
"`$ docker compose up -d` <br/>\n",
"2. Enter to the container <br/>\n",
"`$ docker compose exec dvmdostem-run bash` <br/>\n",
"`$ docker compose exec dvmdostem-dev bash` <br/>\n",
"3. Start jupyter notebook inside the /work folder <br/>\n",
"`$ jupyter notebook --ip 0.0.0.0 --no-browser --allow-root` <br/>\n",
"4. Copy the url into your browser. <br/>\n",
Expand Down
2 changes: 1 addition & 1 deletion scripts/Docker-sensitivity-workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 1. Strat the containers <br/>
# `$ docker compose up -d` <br/>
# 2. Enter to the container <br/>
# `$ docker compose exec dvmdostem-run bash` <br/>
# `$ docker compose exec dvmdostem-dev bash` <br/>
# 3. Start jupyter notebook inside the /work folder <br/>
# `$ jupyter notebook --ip 0.0.0.0 --no-browser --allow-root` <br/>
# 4. Copy the url into your browser. <br/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/Docker-tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"1. Strat the containers <br/>\n",
"`$ docker compose up -d` <br/>\n",
"2. Enter to the container <br/>\n",
"`$ docker compose exec dvmdostem-run bash` <br/>\n",
"`$ docker compose exec dvmdostem-dev bash` <br/>\n",
"3. Start jupyter notebook inside the /work folder <br/>\n",
"`$ jupyter notebook --ip 0.0.0.0 --no-browser --allow-root` <br/>\n",
"4. Copy the url into your browser. <br/>\n",
Expand Down
20 changes: 10 additions & 10 deletions scripts/docker-ipython-notebook-run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"* You have the volumes setup as specified in the project's `docker-compose.yml` file and you can access the files both from your host computer and from within the docker container(s).\n",
"* You have installed the Jupyter package and can run jupyter notebooks, specifically an `IPython` notebook.\n",
"\n",
"> Note about packages and environments: the demo here shows a mixture of running dvm-dos-tem's supporting Python scripts \"natively\" (i.e. on your host computer, not in a Docker container) and running dvm-dos-tem's supporting Python scripts inside the Docker container. For the most consistent Python environment, it is best to run everyting through (inside) the Docker containers. However sometimes the extra typing required is onerous (`docker compose exec dvmdostem-run ...`), and there is a little extra overhead involved in interacting with the containers. So if you have the appropriate packages installed on your host machine you can run some of the scripts on your host as it shown here. This takes a little care to keep the paths straight for each command, i.e. whether you are referncing the path inside the guest/container, or on your host machine.\n",
"> Note about packages and environments: the demo here shows a mixture of running dvm-dos-tem's supporting Python scripts \"natively\" (i.e. on your host computer, not in a Docker container) and running dvm-dos-tem's supporting Python scripts inside the Docker container. For the most consistent Python environment, it is best to run everyting through (inside) the Docker containers. However sometimes the extra typing required is onerous (`docker compose exec dvmdostem-dev ...`), and there is a little extra overhead involved in interacting with the containers. So if you have the appropriate packages installed on your host machine you can run some of the scripts on your host as it shown here. This takes a little care to keep the paths straight for each command, i.e. whether you are referncing the path inside the guest/container, or on your host machine.\n",
"\n",
"> Note that while `dmvdostem`'s supporting scripts are largely written in Python, for the most part there is not an exposed Python API. Instead the scripts are generally provided with a command line interface. So much of this tutorial, while running inside an IPython notebook, could easily be run directly from your shell.\n",
"\n",
Expand Down Expand Up @@ -70,7 +70,7 @@
"outputs": [],
"source": [
"# Cleanup:\n",
"!docker compose exec dvmdostem-run rm -r /data/workflows/testcase_0001"
"!docker compose exec dvmdostem-dev rm -r /data/workflows/testcase_0001"
]
},
{
Expand All @@ -89,7 +89,7 @@
}
],
"source": [
"!docker compose exec dvmdostem-run scripts/setup_working_directory.py \\\n",
"!docker compose exec dvmdostem-dev scripts/setup_working_directory.py \\\n",
"--input-data-path /data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_TOOLIK_FIELD_STATION_10x10/ \\\n",
"/data/workflows/testcase_0001"
]
Expand Down Expand Up @@ -144,7 +144,7 @@
}
],
"source": [
"!docker compose exec dvmdostem-run ls /data/workflows/testcase_0001"
"!docker compose exec dvmdostem-dev ls /data/workflows/testcase_0001"
]
},
{
Expand Down Expand Up @@ -266,7 +266,7 @@
}
],
"source": [
"!docker compose exec dvmdostem-run runmask-util.py --reset \\\n",
"!docker compose exec dvmdostem-dev runmask-util.py --reset \\\n",
"--yx 0 0 \\\n",
"--show \\\n",
"/data/workflows/testcase_0001/run-mask.nc"
Expand Down Expand Up @@ -306,7 +306,7 @@
}
],
"source": [
"!docker compose exec dvmdostem-run outspec_utils.py -s /data/workflows/testcase_0001/config/output_spec.csv"
"!docker compose exec dvmdostem-dev outspec_utils.py -s /data/workflows/testcase_0001/config/output_spec.csv"
]
},
{
Expand Down Expand Up @@ -653,11 +653,11 @@
}
],
"source": [
"!docker compose exec dvmdostem-run outspec_utils.py \\\n",
"!docker compose exec dvmdostem-dev outspec_utils.py \\\n",
"/data/workflows/testcase_0001/config/output_spec.csv \\\n",
"--on GPP p m\n",
"\n",
"!docker compose exec dvmdostem-run outspec_utils.py \\\n",
"!docker compose exec dvmdostem-dev outspec_utils.py \\\n",
"/data/workflows/testcase_0001/config/output_spec.csv \\\n",
"--on CMTNUM y\n"
]
Expand Down Expand Up @@ -1087,7 +1087,7 @@
}
],
"source": [
"!docker compose exec --workdir /data/workflows/testcase_0001 dvmdostem-run \\\n",
"!docker compose exec --workdir /data/workflows/testcase_0001 dvmdostem-dev \\\n",
"dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt 4"
]
},
Expand Down Expand Up @@ -1117,7 +1117,7 @@
}
],
"source": [
"!docker compose exec dvmdostem-run ls /data/workflows/testcase_0001/output"
"!docker compose exec dvmdostem-dev ls /data/workflows/testcase_0001/output"
]
},
{
Expand Down
20 changes: 10 additions & 10 deletions scripts/docker-ipython-notebook-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# * You have the volumes setup as specified in the project's `docker-compose.yml` file and you can access the files both from your host computer and from within the docker container(s).
# * You have installed the Jupyter package and can run jupyter notebooks, specifically an `IPython` notebook.
#
# > Note about packages and environments: the demo here shows a mixture of running dvm-dos-tem's supporting Python scripts "natively" (i.e. on your host computer, not in a Docker container) and running dvm-dos-tem's supporting Python scripts inside the Docker container. For the most consistent Python environment, it is best to run everyting through (inside) the Docker containers. However sometimes the extra typing required is onerous (`docker compose exec dvmdostem-run ...`), and there is a little extra overhead involved in interacting with the containers. So if you have the appropriate packages installed on your host machine you can run some of the scripts on your host as it shown here. This takes a little care to keep the paths straight for each command, i.e. whether you are referncing the path inside the guest/container, or on your host machine.
# > Note about packages and environments: the demo here shows a mixture of running dvm-dos-tem's supporting Python scripts "natively" (i.e. on your host computer, not in a Docker container) and running dvm-dos-tem's supporting Python scripts inside the Docker container. For the most consistent Python environment, it is best to run everyting through (inside) the Docker containers. However sometimes the extra typing required is onerous (`docker compose exec dvmdostem-dev ...`), and there is a little extra overhead involved in interacting with the containers. So if you have the appropriate packages installed on your host machine you can run some of the scripts on your host as it shown here. This takes a little care to keep the paths straight for each command, i.e. whether you are referncing the path inside the guest/container, or on your host machine.
#
# > Note that while `dmvdostem`'s supporting scripts are largely written in Python, for the most part there is not an exposed Python API. Instead the scripts are generally provided with a command line interface. So much of this tutorial, while running inside an IPython notebook, could easily be run directly from your shell.
#
Expand Down Expand Up @@ -56,13 +56,13 @@


# Cleanup:
get_ipython().system('docker compose exec dvmdostem-run rm -r /data/workflows/testcase_0001')
get_ipython().system('docker compose exec dvmdostem-dev rm -r /data/workflows/testcase_0001')


# In[9]:


get_ipython().system('docker compose exec dvmdostem-run scripts/setup_working_directory.py --input-data-path /data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_TOOLIK_FIELD_STATION_10x10/ /data/workflows/testcase_0001')
get_ipython().system('docker compose exec dvmdostem-dev scripts/setup_working_directory.py --input-data-path /data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_TOOLIK_FIELD_STATION_10x10/ /data/workflows/testcase_0001')


# Now note that if you investigate **from your host** (i.e. not inside the docker container) you can see the new directory you just created (in my case, I keep the workflows up two directories from my dvm-dos-tem repo; your paths might be different):
Expand All @@ -78,7 +78,7 @@
# In[11]:


get_ipython().system('docker compose exec dvmdostem-run ls /data/workflows/testcase_0001')
get_ipython().system('docker compose exec dvmdostem-dev ls /data/workflows/testcase_0001')


# ## Adjust spatial mask
Expand All @@ -87,7 +87,7 @@
# In[12]:


get_ipython().system('docker compose exec dvmdostem-run runmask-util.py --reset --yx 0 0 --show /data/workflows/testcase_0001/run-mask.nc')
get_ipython().system('docker compose exec dvmdostem-dev runmask-util.py --reset --yx 0 0 --show /data/workflows/testcase_0001/run-mask.nc')


# ## Choose output variables
Expand All @@ -97,7 +97,7 @@
# In[13]:


get_ipython().system('docker compose exec dvmdostem-run outspec_utils.py -s /data/workflows/testcase_0001/config/output_spec.csv')
get_ipython().system('docker compose exec dvmdostem-dev outspec_utils.py -s /data/workflows/testcase_0001/config/output_spec.csv')


# This is super annoying because it needs a wider screen to display this table nicely. But we can use `pandas` to display nicely in this notebook.
Expand All @@ -115,9 +115,9 @@
# In[15]:


get_ipython().system('docker compose exec dvmdostem-run outspec_utils.py /data/workflows/testcase_0001/config/output_spec.csv --on GPP p m')
get_ipython().system('docker compose exec dvmdostem-dev outspec_utils.py /data/workflows/testcase_0001/config/output_spec.csv --on GPP p m')

get_ipython().system('docker compose exec dvmdostem-run outspec_utils.py /data/workflows/testcase_0001/config/output_spec.csv --on CMTNUM y')
get_ipython().system('docker compose exec dvmdostem-dev outspec_utils.py /data/workflows/testcase_0001/config/output_spec.csv --on CMTNUM y')


# ## Adjust other settings
Expand Down Expand Up @@ -152,15 +152,15 @@
# In[17]:


get_ipython().system('docker compose exec --workdir /data/workflows/testcase_0001 dvmdostem-run dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt 4')
get_ipython().system('docker compose exec --workdir /data/workflows/testcase_0001 dvmdostem-dev dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt 4')


# Thats it! If we look in the output directory, we expect to see one output file for the equlibrium stage, GPP:

# In[18]:


get_ipython().system('docker compose exec dvmdostem-run ls /data/workflows/testcase_0001/output')
get_ipython().system('docker compose exec dvmdostem-dev ls /data/workflows/testcase_0001/output')


# In[19]:
Expand Down
10 changes: 5 additions & 5 deletions scripts/sensitivity_analysis_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@
"!rm -r {H_RUNFOLDER}\n",
"\n",
"# Place to work\n",
"!docker compose exec dvmdostem-run setup_working_directory.py \\\n",
"!docker compose exec dvmdostem-dev setup_working_directory.py \\\n",
"--input-data-path \\\n",
"/data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_CALM_Toolik_LTER_10x10/ \\\n",
"{D_RUNFOLDER}\n",
"\n",
"# Run mask\n",
"!docker compose exec dvmdostem-run runmask-util.py \\\n",
"!docker compose exec dvmdostem-dev runmask-util.py \\\n",
"--reset --yx {PXy} {PXx} {D_RUNFOLDER}/run-mask.nc\n",
"\n",
"# Outputs\n",
"!docker compose exec dvmdostem-run outspec_utils.py \\\n",
"!docker compose exec dvmdostem-dev outspec_utils.py \\\n",
"{D_RUNFOLDER}/config/output_spec.csv --on GPP m p\n",
"\n",
"!docker compose exec dvmdostem-run outspec_utils.py \\\n",
"!docker compose exec dvmdostem-dev outspec_utils.py \\\n",
"{D_RUNFOLDER}/config/output_spec.csv --on CMTNUM y\n",
"\n",
"\n",
Expand Down Expand Up @@ -149,7 +149,7 @@
"outputs": [],
"source": [
"def run_model():\n",
" !docker compose exec --workdir {D_RUNFOLDER} dvmdostem-run \\\n",
" !docker compose exec --workdir {D_RUNFOLDER} dvmdostem-dev \\\n",
" dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt {CMTNUM}\n",
"\n",
"def collect_outputs():\n",
Expand Down
10 changes: 5 additions & 5 deletions scripts/sensitivity_analysis_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
get_ipython().system('rm -r {H_RUNFOLDER}')

# Place to work
get_ipython().system('docker compose exec dvmdostem-run setup_working_directory.py --input-data-path /data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_CALM_Toolik_LTER_10x10/ {D_RUNFOLDER}')
get_ipython().system('docker compose exec dvmdostem-dev setup_working_directory.py --input-data-path /data/input-catalog/cru-ts40_ar5_rcp85_ncar-ccsm4_CALM_Toolik_LTER_10x10/ {D_RUNFOLDER}')

# Run mask
get_ipython().system('docker compose exec dvmdostem-run runmask-util.py --reset --yx {PXy} {PXx} {D_RUNFOLDER}/run-mask.nc')
get_ipython().system('docker compose exec dvmdostem-dev runmask-util.py --reset --yx {PXy} {PXx} {D_RUNFOLDER}/run-mask.nc')

# Outputs
get_ipython().system('docker compose exec dvmdostem-run outspec_utils.py {D_RUNFOLDER}/config/output_spec.csv --on GPP m p')
get_ipython().system('docker compose exec dvmdostem-dev outspec_utils.py {D_RUNFOLDER}/config/output_spec.csv --on GPP m p')

get_ipython().system('docker compose exec dvmdostem-run outspec_utils.py {D_RUNFOLDER}/config/output_spec.csv --on CMTNUM y')
get_ipython().system('docker compose exec dvmdostem-dev outspec_utils.py {D_RUNFOLDER}/config/output_spec.csv --on CMTNUM y')


# Config, enable eq outputs
Expand Down Expand Up @@ -102,7 +102,7 @@ def adjust_param(new_value):


def run_model():
get_ipython().system('docker compose exec --workdir {D_RUNFOLDER} dvmdostem-run dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt {CMTNUM}')
get_ipython().system('docker compose exec --workdir {D_RUNFOLDER} dvmdostem-dev dvmdostem -p 50 -e 200 -s 0 -t 0 -n 0 -l err --force-cmt {CMTNUM}')

def collect_outputs():
# Get the model output
Expand Down

0 comments on commit 582161f

Please sign in to comment.