Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup PR #1 #153

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NCARtips.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ and can be accessed via the following steps:
1. Open a default desktop icon.
1. Select the browser client.
1. Type `xterm` and hit enter to open a terminal.
1. In the terminal, run `cd ${CUPID_ROOT}/examples/coupled_model/computed_notebooks/quick-run/_build/html` to enter the `html` directory.
1. In the terminal, run `cd ${CUPID_ROOT}/examples/key_metrics/computed_notebooks/_build/html` to enter the `html` directory.
1. From the updated directory, run `firefox index.html &` to open a web browser pointed at the generated web page.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ please see the [Contributor's Guide](https://ncar.github.io/CUPiD/contributors_g
## Running

CUPiD currently provides an example for generating diagnostics.
To test the package out, try to run `examples/coupled-model`:
To test the package out, try to run `examples/key-metrics`:

``` bash
$ conda activate cupid-dev
$ cd examples/coupled_model
$ cd examples/key_metrics
$ # machine-dependent: request multiple compute cores
$ cupid-run
$ cupid-build # Will build HTML from Jupyter Book
```

After the last step is finished, you can use Jupyter to view generated notebooks in `${CUPID_ROOT}/examples/coupled-model/computed_notebooks/quick-run`
or you can view `${CUPID_ROOT}/examples/coupled-model/computed_notebooks/quick-run/_build/html/index.html` in a web browser.
After the last step is finished, you can use Jupyter to view generated notebooks in `${CUPID_ROOT}/examples/key-metrics/computed_notebooks`
or you can view `${CUPID_ROOT}/examples/key-metrics/computed_notebooks/_build/html/index.html` in a web browser.

Notes:

Expand Down
9 changes: 4 additions & 5 deletions cupid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ def build(config_path):
with open(config_path) as fid:
control = yaml.safe_load(fid)

sname = control["data_sources"]["sname"]
run_dir = control["data_sources"]["run_dir"]

subprocess.run(["jupyter-book", "clean", f"{run_dir}/computed_notebooks/{sname}"])
subprocess.run(["jupyter-book", "clean", f"{run_dir}/computed_notebooks"])
subprocess.run(
["jupyter-book", "build", f"{run_dir}/computed_notebooks/{sname}", "--all"],
["jupyter-book", "build", f"{run_dir}/computed_notebooks", "--all"],
)
for component in control["compute_notebooks"]:
for notebook in control["compute_notebooks"][component]:
Expand All @@ -57,7 +56,7 @@ def build(config_path):
):
shutil.copytree(
f"{run_dir}/ADF_output",
f"{run_dir}/computed_notebooks/{sname}/_build/html/ADF",
f"{run_dir}/computed_notebooks/_build/html/ADF",
)

# Originally used this code to copy jupyter book HTML to a location to host it online
Expand All @@ -69,7 +68,7 @@ def build(config_path):
# remote_dir = control["publish_location"]["remote_dir"]
# this seems more complicated than expected...people have mentioned paramiko library?
# subprocess.run(["mkdir", "-p", remote_dir])
# subprocess.run(["scp", "-r", f"{run_dir}/computed_notebooks/{sname}/_build/html/*",
# subprocess.run(["scp", "-r", f"{run_dir}/computed_notebooks/_build/html/*",
# f"{user}@{remote_mach}:{remote_dir}"])

return None
Expand Down
2 changes: 1 addition & 1 deletion cupid/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def run(
# Grab paths

run_dir = os.path.realpath(os.path.expanduser(control["data_sources"]["run_dir"]))
output_dir = run_dir + "/computed_notebooks/" + control["data_sources"]["sname"]
output_dir = run_dir + "/computed_notebooks/"
temp_data_path = run_dir + "/temp_data"
nb_path_root = os.path.realpath(
os.path.expanduser(control["data_sources"]["nb_path_root"]),
Expand Down
2 changes: 1 addition & 1 deletion cupid/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def setup_book(config_path):

os.makedirs(output_root, exist_ok=True)

output_dir = f'{output_root}/{control["data_sources"]["sname"]}'
output_dir = f"{output_root}"

os.makedirs(output_dir, exist_ok=True)

Expand Down
3 changes: 1 addition & 2 deletions docs/addingnotebookstocollection.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Generally, a good fit for a diagnostic notebook is one that reads in CESM output
1. Install the `environments/cupid-analysis.yml` environment (see [installation instructions](https://ncar.github.io/CUPiD/index.html#installing)). Make sure that your notebook runs properly in this environment. If there are conflicts or missing dependencies, open an issue or talk to CUPiD developers so we can find a solution.
2. In your notebook, move all variables you might want to change (paths to data, dates to select, etc.) to a cell near the top. For example:

sname = "run_name"
data_path = "path/to/data"
dates = {"start_date" = "01/01/01",
"end_date" = "01/01/02"}
Expand All @@ -15,7 +14,7 @@ Generally, a good fit for a diagnostic notebook is one that reads in CESM output
---
**If you want to run your notebook through the `CUPiD` workflow yourself, follow the rest of the instructions:**

4. Move your new diagnostic notebook to the folder called `examples/nblibrary`.
4. Move your new diagnostic notebook to the folder called `nblibrary`.

5. Open `config.yml`. First, add your new notebook (as its name, minus the `.ipynb`) to the list of notebooks that will be computed (`compute_notebooks`). The notebooks will be executed in the order they are listed here. For example:

Expand Down
2 changes: 0 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ This page describes the fields in the configuration file that might commonly be
<img src="_static/images/config/config_1.png" alt="CUPiD Config 1" width=1000 />
The data sources section of the configuration file describes general data sources and expected directory structure for running CUPiD.

`sname`: nickname for this configuration as a string. This will be used as the name of the folder your computed notebooks are put in

<img src="_static/images/config/config_2.png" alt="CUPiD Config 2" width=1000 />
The computation config section of the configuration file supplies the default kernel for running CUPiD. This should usually be `cupid-analysis`. If a contributor wants to include additional packages, please create an issue describing the packages you'd like to add to this conda environment.

Expand Down
6 changes: 1 addition & 5 deletions examples/coupled_model/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Data Sources #
################
data_sources:
# sname is any string used as a nickname for this configuration. It will be
### used as the name of the folder your computed notebooks are put in
sname: quick-run

# run_dir is the path to the folder you want
### all the files associated with this configuration
### to be created in
Expand All @@ -17,7 +13,7 @@ data_sources:
### look for your template notebooks in. It doesn't have to
### be inside run_dir, or be specific to this project, as
### long as the notebooks are there
nb_path_root: ../nblibrary
nb_path_root: ../../nblibrary

######################
# Computation Config #
Expand Down
8 changes: 2 additions & 6 deletions examples/external_diag_packages/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Data Sources #
################
data_sources:
# sname is any string used as a nickname for this configuration. It will be
### used as the name of the folder your computed notebooks are put in
sname: external_diag_packages

# run_dir is the path to the folder you want
### all the files associated with this configuration
### to be created in
Expand All @@ -17,7 +13,7 @@ data_sources:
### look for your template notebooks in. It doesn't have to
### be inside run_dir, or be specific to this project, as
### long as the notebooks are there
nb_path_root: ../nblibrary
nb_path_root: ../../nblibrary

######################
# Computation Config #
Expand Down Expand Up @@ -118,7 +114,7 @@ compute_notebooks:
kernel_name: cupid-dev
parameter_groups:
none:
adf_root: ../../external_diag_packages/ADF/
adf_root: ../../examples/external_diag_packages/ADF_output/
case_year_range: "1_100"
base_case_year_range: "1995_2006"
external_tool:
Expand Down
40 changes: 18 additions & 22 deletions examples/key_metrics/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Data Sources #
################
data_sources:
# sname is any string used as a nickname for this configuration. It will be
### used as the name of the folder your computed notebooks are put in
sname: key_metrics

# run_dir is the path to the folder you want
### all the files associated with this configuration
### to be created in
Expand All @@ -17,7 +13,7 @@ data_sources:
### look for your template notebooks in. It doesn't have to
### be inside run_dir, or be specific to this project, as
### long as the notebooks are there
nb_path_root: ../nblibrary
nb_path_root: ../../nblibrary

######################
# Computation Config #
Expand Down Expand Up @@ -129,23 +125,23 @@ compute_notebooks:
obs_name: 'GrIS_MARv3.12_climo_1960_1999.nc'
climo_nyears: 40

rof:
global_discharge_gauge_compare_obs:
parameter_groups:
none:
analysis_name: ""
grid_name: 'f09_f09_mosart' # ROF grid name
rof_start_date: '0091-01-01'
rof_end_date: '0101-01-01'
figureSave: False
global_discharge_ocean_compare_obs:
parameter_groups:
none:
analysis_name: ""
grid_name: 'f09_f09_mosart' # ROF grid name
rof_start_date: '0091-01-01'
rof_end_date: '0101-01-01'
figureSave: False
# rof:
# global_discharge_gauge_compare_obs:
# parameter_groups:
# none:
# analysis_name: ""
# grid_name: 'f09_f09_mosart' # ROF grid name
# rof_start_date: '0091-01-01'
# rof_end_date: '0101-01-01'
# figureSave: False
# global_discharge_ocean_compare_obs:
# parameter_groups:
# none:
# analysis_name: ""
# grid_name: 'f09_f09_mosart' # ROF grid name
# rof_start_date: '0091-01-01'
# rof_end_date: '0101-01-01'
# figureSave: False

# ice:
# seaice:
Expand Down
2 changes: 1 addition & 1 deletion helper_scripts/generate_adf_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def generate_adf_config(cesm_root, cupid_example, adf_file, out_file):
valid_examples = [
example
for example in next(os.walk(cupid_examples))[1]
if example not in ["ilamb", "nblibrary"]
if example not in ["ilamb"]
]
if cupid_example not in valid_examples:
error_msg = f"argument --cupid-example: invalid choice '{cupid_example}'"
Expand Down
2 changes: 1 addition & 1 deletion helper_scripts/generate_cupid_config_for_cesm_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def generate_cupid_config(case_root, cesm_root, cupid_example):
valid_examples = [
example
for example in next(os.walk(cupid_examples))[1]
if example not in ["ilamb", "nblibrary"]
if example not in ["ilamb"]
]
if cupid_example not in valid_examples:
error_msg = f"argument --cupid-example: invalid choice '{cupid_example}'"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"base_case_name = None\n",
"case_year_range = None\n",
"base_case_year_range = None\n",
"# adf_root will be external_diag_packages/computed_notebooks/external_diag_packages/ADF/"
"# adf_root will be external_diag_packages/computed_notebooks/ADF/"
]
},
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading