From d6b0bee603aa63f21aad91af79c33ec90615c9b7 Mon Sep 17 00:00:00 2001 From: Spencer Wong Date: Tue, 20 Aug 2024 11:42:22 +1000 Subject: [PATCH 1/2] Swap to um2netcdf standalone --- test/test_conversion_driver_esm1p5.py | 11 ++--------- umpost/conversion_driver_esm1p5.py | 19 +++++-------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/test/test_conversion_driver_esm1p5.py b/test/test_conversion_driver_esm1p5.py index 49071a3..ef3e669 100644 --- a/test/test_conversion_driver_esm1p5.py +++ b/test/test_conversion_driver_esm1p5.py @@ -84,15 +84,8 @@ def test_find_matching_fields_files(): @pytest.fixture def base_mock_process(): - # Create a patch of um2netcdf4.process - - # FIXME: use temp guard block while working between gadi/local environments - # replace when full umpost.um2netcdf is ready - if esm1p5_convert.hostname.startswith("gadi"): - patcher = mock.patch("um2netcdf4.process") - else: - patcher = mock.patch("umpost.um2netcdf.process") - + # Create a patch of um2netcdf.process + patcher = mock.patch("umpost.um2netcdf.process") yield patcher.start() patcher.stop() diff --git a/umpost/conversion_driver_esm1p5.py b/umpost/conversion_driver_esm1p5.py index 3fa2fc4..36413b5 100755 --- a/umpost/conversion_driver_esm1p5.py +++ b/umpost/conversion_driver_esm1p5.py @@ -3,10 +3,10 @@ ESM1.5 conversion driver Wrapper script for automated fields file to NetCDF conversion -during ESM1.5 simulations. Runs conversion module (currently -um2netcdf4) on each atmospheric output in a specified directory. +during ESM1.5 simulations. Runs conversion module +on each atmospheric output in a specified directory. -Adapted from Martin Dix's conversion driver for CM2: +Adapted from Martin Dix's conversion driver for CM2: https://github.com/ACCESS-NRI/access-cm2-drivers/blob/main/src/run_um2netcdf.py """ @@ -20,16 +20,7 @@ import argparse import errno from pathlib import Path - -# FIXME: use temp guard block while working between gadi/local envs, local umpost.um2netcdf & -# gadi's um2netcdf4. Replace when full umpost.um2netcdf is ready -import socket -hostname = socket.gethostname() - -if hostname.startswith("gadi"): - import um2netcdf4 -else: - import umpost.um2netcdf as um2netcdf4 +from umpost import um2netcdf # TODO: um2netcdf will update the way arguments are fed to `process`. @@ -152,7 +143,7 @@ def convert_fields_file_list(fields_file_paths, nc_write_dir): nc_write_path = get_nc_write_path(fields_file_path, nc_write_dir) try: - um2netcdf4.process(fields_file_path, nc_write_path, ARG_VALS) + um2netcdf.process(fields_file_path, nc_write_path, ARG_VALS) succeeded.append((fields_file_path, nc_write_path)) except Exception as exc: From d47d5f1b856f5247f865e81a4966809f32638753 Mon Sep 17 00:00:00 2001 From: Spencer Wong Date: Tue, 20 Aug 2024 14:41:26 +1000 Subject: [PATCH 2/2] Remove reference to um2netcdf4 in CI.yml --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8a245ea..c66153a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -91,7 +91,7 @@ jobs: - name: Lint shell: bash -l {0} - run: pylint --extension-pkg-whitelist=netCDF4 --ignored-modules=um2netcdf4,umpost -E umpost + run: pylint --extension-pkg-whitelist=netCDF4 --ignored-modules=umpost -E umpost - name: Run tests shell: bash -l {0}