Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archive the experiment directory along with git status/diff output #3105

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e7e43d2
First crack at archiving the expdir and git status
DavidHuber-NOAA Nov 15, 2024
9f1a6fc
Merge remote-tracking branch 'origin/develop' into feature/archive_ex…
DavidHuber-NOAA Nov 15, 2024
2746e46
Add flake8 rules for the global workflow
DavidHuber-NOAA Nov 18, 2024
1579844
Copy expdir to ROTDIR before tar'ing
DavidHuber-NOAA Nov 18, 2024
95f04d4
Merge branch 'develop' into feature/archive_expdir
DavidHuber-NOAA Nov 18, 2024
23b0454
Allow users to specify their HPC account
DavidHuber-NOAA Nov 19, 2024
f88c077
Start archiving EXPDIR on the first full cycle and name expdir direct…
DavidHuber-NOAA Nov 19, 2024
6924428
Merge branch 'feature/archive_expdir' of github.com:davidhuber-noaa/g…
DavidHuber-NOAA Nov 19, 2024
d2db267
Merge remote-tracking branch 'origin/develop' into feature/archive_ex…
DavidHuber-NOAA Nov 19, 2024
7d0b70a
Trimmed .flake8 exclusions
DavidHuber-NOAA Nov 19, 2024
5f67730
Merge remote-tracking branch 'origin/develop' into feature/archive_ex…
DavidHuber-NOAA Nov 20, 2024
a61055e
Merge branch 'feature/archive_expdir' of github.com:davidhuber-noaa/g…
DavidHuber-NOAA Nov 20, 2024
f385f0c
Merge branch 'develop' into feature/archive_expdir
DavidHuber-NOAA Nov 25, 2024
1b4340e
Merge remote-tracking branch 'emc/develop' into feature/archive_expdir
DavidHuber-NOAA Nov 26, 2024
7ca219c
Merge branch 'NOAA-EMC:develop' into feature/archive_expdir
DavidHuber-NOAA Dec 2, 2024
12b6f95
Remove extra A option
DavidHuber-NOAA Dec 2, 2024
b8cc2ef
Add documentation on EXPDIR archiving
DavidHuber-NOAA Dec 2, 2024
5014922
Merge remote-tracking branch 'origin/develop' into feature/archive_ex…
DavidHuber-NOAA Dec 3, 2024
7ab8dc1
Apply suggestions from code review
DavidHuber-NOAA Dec 3, 2024
0dd3eb8
Apply suggestions from code review
DavidHuber-NOAA Dec 3, 2024
6d89b5c
Merge branch 'develop' into feature/archive_expdir
DavidHuber-NOAA Dec 4, 2024
28bb727
Add self to instance methods
DavidHuber-NOAA Dec 4, 2024
729be32
Merge branch 'feature/archive_expdir' of github.com:davidhuber-noaa/g…
DavidHuber-NOAA Dec 4, 2024
979f2cb
Merge branch 'develop' into feature/archive_expdir
DavidHuber-NOAA Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions parm/archive/expdir.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ expdir:
{% for config in glob(EXPDIR ~ "/config.*") %}
- [ "{{ config }}", "{{ ROTDIR }}/{{ copy_expdir }}/." ]
{% endfor %}
- [ "{{ EXPDIR }}/{{ PSLOT }}.db", "{{ ROTDIR }}/{{ copy_expdir }}/." ]
- [ "{{ EXPDIR }}/{{ PSLOT }}.xml", "{{ ROTDIR }}/{{ copy_expdir }}/." ]
{% if ARCH_HASHES or ARCH_DIFFS %}
- [ "{{ EXPDIR }}/git_info.log", "{{ ROTDIR }}/{{ copy_expdir }}/." ]
{% endif %}
target: "{{ ATARDIR }}/{{ cycle_YMDH }}/expdir.tar"
required:
- "{{ copy_expdir }}/config.*"
- "{{ copy_expdir }}/{{ PSLOT }}.db"
- "{{ copy_expdir }}/{{ PSLOT }}.xml"
{% if ARCH_HASHES or ARCH_DIFFS %}
- "{{ copy_expdir }}/git_info.log"
Expand Down
40 changes: 18 additions & 22 deletions ush/python/pygfs/task/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ def configure(self, arch_dict: Dict[str, Any]) -> (Dict[str, Any], List[Dict[str

# Determine if we are archiving the EXPDIR this cycle
if arch_dict.ARCH_EXPDIR:
self.archive_expdir = Archive._archive_expdir(arch_dict)
self.archive_expdir = self._archive_expdir(arch_dict)
arch_dict.archive_expdir = self.archive_expdir

if self.archive_expdir:
# If requested, get workflow hashes/statuses/diffs for EXPDIR archiving
if arch_dict.ARCH_HASHES or arch_dict.ARCH_DIFFS:
Archive._pop_git_info(arch_dict)
self._pop_git_info(arch_dict)

master_yaml = "master_" + arch_dict.RUN + ".yaml.j2"

Expand Down Expand Up @@ -439,7 +439,6 @@ def replace_string_from_to_file(filename_in, filename_out, search_str, replace_s

return

@staticmethod
@logit(logger)
def _archive_expdir(arch_dict: Dict[str, Any]) -> bool:
WalterKolczynski-NOAA marked this conversation as resolved.
Show resolved Hide resolved
"""
Expand Down Expand Up @@ -482,21 +481,18 @@ def _archive_expdir(arch_dict: Dict[str, Any]) -> bool:

# Determine if we should skip this cycle
# If the frequency is set to 0, only run on sdate (+assim_freq for cycled) and edate
if freq == 0:
if mode == "forecast-only" and (current_cycle != sdate or current_cycle != edate):
return False
elif mode == "cycled" and (current_cycle != sdate + assim_freq or current_cycle != edate):
return False
# Otherwise, the frequency is in hours
elif mode == "forecast-only" and (sdate - current_cycle).total_seconds() % freq != 0:
return False
elif mode == "cycled" and (sdate + assim_freq - current_cycle).total_seconds() % freq != 0:
first_full = sdate
if mode in ["cycled"]:
first_full += assim_freq
if current_cycle in [first_full, edate]:
# Always save the first and last
return True
elif (current_cycle - first_full).total_seconds() % freq == 0:
# Otherwise, the frequency is in hours
return True
else:
return False

# Looks like we are archiving the EXPDIR
return True

@staticmethod
@logit(logger)
def _pop_git_info(arch_dict: Dict[str, Any]) -> Dict[str, Any]:
"""
Expand Down Expand Up @@ -543,8 +539,8 @@ def _pop_git_info(arch_dict: Dict[str, Any]) -> Dict[str, Any]:
output += git("rev-parse", "HEAD", output=str)
output += "\nSubmodule hashes:\n"
output += git("submodule", "status", output=str)
except ProcessError:
raise OSError("FATAL ERROR Failed to run git")
except ProcessError as pe:
raise OSError("FATAL ERROR Failed to run git") from pe

# Are we running git to get diffs?
if arch_diffs:
Expand All @@ -559,16 +555,16 @@ def _pop_git_info(arch_dict: Dict[str, Any]) -> Dict[str, Any]:
print("WARNING git was unable to do a recursive diff.\n"
"Only a top level diff was performed.\n"
"Note that the git version must be >= 2.14 for this feature.")
except ProcessError:
raise OSError("FATAL ERROR Failed to run 'git diff'")
except ProcessError as pe:
raise OSError("FATAL ERROR Failed to run 'git diff'") from pe

# Write out to the log file
try:
with open(os.path.join(expdir, git_filename), 'w') as output_file:
output_file.write(output)
except OSError:
except OSError as ose:
fname = os.path.join(expdir, git_filename)
raise OSError(f"FATAL ERROR Unable to write git output to '{fname}'")
raise OSError(f"FATAL ERROR Unable to write git output to '{fname}'") from ose

return

Expand Down