Skip to content

Commit

Permalink
remove sname, update nb_path_root, clean up names of output directories
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaganKing committed Nov 21, 2024
1 parent c0dfc85 commit cab1810
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 31 deletions.
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
1 change: 0 additions & 1 deletion 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 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
6 changes: 1 addition & 5 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
6 changes: 1 addition & 5 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
2 changes: 1 addition & 1 deletion nblibrary/atm/link_to_ADF.ipynb
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

0 comments on commit cab1810

Please sign in to comment.