From b08c4ed9457edb22171322652322c5c7f93a7fa3 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Thu, 1 Feb 2024 09:03:42 -0500 Subject: [PATCH] Extract nc files from tar for repro tests --- examples/hybrid/driver.jl | 5 +++++ regression_tests/compute_mse.jl | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/examples/hybrid/driver.jl b/examples/hybrid/driver.jl index 70396873fb..36594cf271 100644 --- a/examples/hybrid/driver.jl +++ b/examples/hybrid/driver.jl @@ -226,6 +226,11 @@ if ClimaComms.iamroot(config.comms_ctx) @info "Plotting done" @info "Creating tarballs" + # These NC files are used by our reproducibility tests, + # and need to be found later when comparing against the + # main branch. If "nc_files.tar" is renamed, then please + # search for "nc_files.tar" globally and rename it in the + # reproducibility test folder. Tar.create( f -> endswith(f, ".nc"), simulation.output_dir, diff --git a/regression_tests/compute_mse.jl b/regression_tests/compute_mse.jl index 942a8f2a18..646b645bb6 100644 --- a/regression_tests/compute_mse.jl +++ b/regression_tests/compute_mse.jl @@ -1,5 +1,6 @@ import NCRegressionTests import NCDatasets +import Tar import ClimaCoreTempestRemap as CCTR include("self_reference_or_path.jl") @@ -32,6 +33,23 @@ function regression_test(; job_id, reference_mse, ds_filename_computed, varname) ds_filename_reference = joinpath(path, ds_filename_computed) @info "`ds_filename_computed`: `$ds_filename_computed`" @info "`ds_filename_reference`: `$ds_filename_reference`" + if !isfile(ds_filename_reference) + # We may have converted to tarball, try to + # extract nc files from tarball first: + job_dir = dirname(ds_filename_reference) + mktempdir(joinpath(job_dir, tempdir())) do tdir + # We must extract to an empty folder, let's + # move it back to job_dir after. + Tar.extract(joinpath(job_dir, "nc_files.tar"), tdir) do hdr + basename(hdr.path) == basename(ds_filename_reference) + end + mv( + joinpath(tdir, basename(ds_filename_reference)), + joinpath(job_dir, basename(ds_filename_reference)); + force = true, + ) + end + end if !isfile(ds_filename_reference) msg = "\n\n" msg *= "Pull request author:\n"