Skip to content

Commit

Permalink
Extract nc files from tar for repro tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Feb 1, 2024
1 parent df40a30 commit b08c4ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/hybrid/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions regression_tests/compute_mse.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import NCRegressionTests
import NCDatasets
import Tar
import ClimaCoreTempestRemap as CCTR

include("self_reference_or_path.jl")
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b08c4ed

Please sign in to comment.