From 1a6a7b319627d2c3a076f75cb16b1f6f2448bfa9 Mon Sep 17 00:00:00 2001 From: zmoon <15079414+zmoon@users.noreply.github.com> Date: Fri, 3 Mar 2023 19:12:54 -0500 Subject: [PATCH 1/3] cli: initial save/read support --- melodies_monet/_cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/melodies_monet/_cli.py b/melodies_monet/_cli.py index 28d43a99..d8743eb9 100644 --- a/melodies_monet/_cli.py +++ b/melodies_monet/_cli.py @@ -146,7 +146,14 @@ def run( an.open_obs() with _timer("Pairing"): - an.pair_data() + if an.read is not None: + an.read_analysis() + else: + an.pair_data() + + if an.save is not None: + with _timer("Saving paired datasets"): + an.save_analysis() if an.control_dict.get("plots") is not None: with _timer("Plotting and saving the figures"), _ignore_pandas_numeric_only_futurewarning(): From 35ea288054e06b80997c0d84b1576c61b202bdd6 Mon Sep 17 00:00:00 2001 From: zmoon <15079414+zmoon@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:08:21 -0400 Subject: [PATCH 2/3] consistency --- melodies_monet/util/read_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/melodies_monet/util/read_util.py b/melodies_monet/util/read_util.py index 42c2bfd6..264d7418 100644 --- a/melodies_monet/util/read_util.py +++ b/melodies_monet/util/read_util.py @@ -127,12 +127,12 @@ def read_analysis_ncf(filenames,xr_kws={}): import xarray as xr if len(filenames)==1: - print('Reading: ', filenames[0]) + print('Reading:', filenames[0]) ds_out = xr.open_dataset(filenames[0],**xr_kws) elif len(filenames)>1: for count, file in enumerate(filenames): - print('Reading: ', file) + print('Reading:', file) if count==0: ds_out = xr.open_dataset(file,**xr_kws) From b588ebe37baa24489d9e2605427a424550c3f327 Mon Sep 17 00:00:00 2001 From: zmoon Date: Wed, 25 Oct 2023 10:31:52 -0600 Subject: [PATCH 3/3] Separate idealized save/read cases for testing CLI --- .github/workflows/ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20ee08b0..7dc90643 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,12 +62,33 @@ jobs: done cd - + - name: Prepare idealized save/read cases + shell: python + run: | + from copy import deepcopy + import yaml + + with open('docs/examples/control_idealized.yaml') as f: + ctl = yaml.safe_load(f) + assert {'save', 'read'} < ctl['analysis'].keys() + + ctl_save = deepcopy(ctl) + del ctl_save['analysis']['read'] + with open('docs/examples/control_idealized_save.yaml', 'w') as f: + yaml.safe_dump(ctl_save, f) + + ctl_read = deepcopy(ctl) + del ctl_read['analysis']['save'] + with open('docs/examples/control_idealized_read.yaml', 'w') as f: + yaml.safe_dump(ctl_read, f) + - name: Check CLI works run: | cd docs/examples melodies-monet --version python -m melodies_monet --version - melodies-monet run control_idealized.yaml + melodies-monet run control_idealized_save.yaml + melodies-monet run control_idealized_read.yaml cd - docs: