Skip to content

Copy additional xml files to clone #505

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

Open
wants to merge 5,165 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
5165 commits
Select commit Hold shift + click to select a range
3336d89
Merge pull request #4723 from jedwards4b/fix/leapdatefortests
jedwards4b Dec 20, 2024
ac991f0
correct rpointer name in resubmit
jedwards4b Dec 26, 2024
7b6e8df
should be case not self
jedwards4b Dec 26, 2024
85922c0
Merge pull request #4725 from jedwards4b/resubmit_fix
jedwards4b Dec 26, 2024
6f14964
corrected leap year correction logic
jedwards4b Dec 30, 2024
ac8e583
Merge pull request #4726 from jedwards4b/leapyr_correction2
jedwards4b Dec 30, 2024
11f3b30
add try except clauses to reduce errors in testing
jedwards4b Jan 2, 2025
15b4b4d
fix an eronious message from cprnc
jedwards4b Jan 6, 2025
ef81824
Merge pull request #4729 from jedwards4b/fix_eronious_cprnc_message
jedwards4b Jan 6, 2025
cdf76d6
Merge pull request #4727 from jedwards4b/improved_reselience
jedwards4b Jan 6, 2025
58f9118
correct the SRCROOT path when using create_clone, should be new SRCRO…
jedwards4b Jan 8, 2025
addf9e6
Merge pull request #4731 from jedwards4b/SRCROOT_clone_correction
jedwards4b Jan 8, 2025
dd1213d
Some updates for E3SM
jgfouca Jan 14, 2025
954266b
Merge pull request #4734 from ESMCI/jgfouca/some_e3sm_stuff
jgfouca Jan 15, 2025
82b7382
ERS: ninst might be None
jgfouca Jan 15, 2025
19df4fa
Add --allow-baseline-skip option to create_test.
samsrabin Jan 17, 2025
7fe8120
Add --allow-baseline-skip option to create_test.
samsrabin Jan 17, 2025
eda49a9
Try return False
samsrabin Jan 17, 2025
cdd90d1
Remove diagnostic printout.
samsrabin Jan 18, 2025
31b46b0
ACTUALLY skip tests with baselines already.
samsrabin Jan 18, 2025
6e372ce
Remove now-unneeded allow_baseline_skip stuff from generate_baseline().
samsrabin Jan 18, 2025
9c8c2b3
Note incompatibility of --allow-baseline-overwrite and -skip.
samsrabin Jan 18, 2025
f48d5cf
Revert remaining changes to hist_utils.py.
samsrabin Jan 18, 2025
0aa6f54
Use mutually exclusive parsing group for existing baseline options.
samsrabin Jan 19, 2025
3f28e48
Rename --allow-baseline-skip to --skip-tests-with-existing-baselines.
samsrabin Jan 19, 2025
65970b3
Merge pull request #4735 from ESMCI/jgfouca/e3sm_cime_fixes
jedwards4b Jan 21, 2025
ff177e8
Add test_skip_run_with_existing_baseline.
samsrabin Jan 22, 2025
6751504
Reformat CIME/ with black.
samsrabin Jan 22, 2025
1e9bf30
Add previous commit to .git-blame-ignore-revs.
samsrabin Jan 22, 2025
11e8188
mct doesnt care about maxncpl
jedwards4b Jan 22, 2025
9d6673b
More ninst fixes
jgfouca Jan 22, 2025
0e4bbb9
Remove unused args from create_test call in test_skip_run_with_existi…
samsrabin Jan 22, 2025
4147a46
allow for different args in e3sm testing
jedwards4b Jan 23, 2025
664c7a2
reverse -o and --allow-baseline-overwrite so that help message is mor…
jedwards4b Jan 23, 2025
5eff840
Merge pull request #4737 from samsrabin/allow-baseline-skip
jedwards4b Jan 23, 2025
4df7a8a
build Kokkos from scratch in CAM
sjsprecious Jan 27, 2025
55b6dc1
define CAM_TARGET option for cmake files
sjsprecious Jan 27, 2025
828aba8
update cime build to use USE_KOKKOS
sjsprecious Jan 27, 2025
9448a39
clean up unused module
sjsprecious Jan 27, 2025
51eed32
always define USE_KOKKOS for cmake build
sjsprecious Jan 27, 2025
80102ad
Create env_postprocessing.xml in case root
mnlevy1981 Jan 30, 2025
99fa564
Merge pull request #4744 from ESMCI/jgfouca/e3sm_cime_fixes
jgfouca Feb 4, 2025
de945e7
ERS fix for buildnml/skip_pnl
jgfouca Feb 5, 2025
5bbdc1d
Merge pull request #4745 from ESMCI/jgfouca/ers_fix
jgfouca Feb 5, 2025
cff6a75
Archive all hist files for non-bfb tests
mkstratos Feb 6, 2025
e1a520a
Fix for env_batch.zip
jgfouca Feb 6, 2025
b6e9727
Add test name to side-effect for new case.get_value call
mkstratos Feb 7, 2025
6b0f901
Details of test-mod searching should not be printed to info
jgfouca Feb 10, 2025
3d87cf1
Merge pull request #4747 from ESMCI/jgfouca/fix_env_batch_zip
jgfouca Feb 10, 2025
cebccac
Merge pull request #4746 from ESMCI/mkstratos/bless-nbfb-tests
jgfouca Feb 10, 2025
2c1ef00
Merge pull request #4748 from ESMCI/jgfouca/reduce_test_mod_output
jgfouca Feb 10, 2025
d9fe0db
Adds vscode devcontainer.
jasonb5 Feb 11, 2025
b431d89
Adds vscode tasks.
jasonb5 Feb 11, 2025
9d2bf79
macos does not support rlimit
jedwards4b Feb 14, 2025
b9ec3c7
Refactors print_values method
jasonb5 Feb 14, 2025
2aea5d1
Adds option to print compiler details for machine
jasonb5 Feb 15, 2025
5d4b15b
Merge pull request #4750 from jedwards4b/mac_update
jedwards4b Feb 18, 2025
3572334
add a command line option to case.setup --disable-git
jedwards4b Feb 19, 2025
e6a0379
Fix for frontier test
jgfouca Feb 19, 2025
d78179f
Fix frontier time
jgfouca Feb 19, 2025
f91ad94
Merge pull request #4757 from ESMCI/jgfouca/fix_frontier_test
jedwards4b Feb 19, 2025
4e459cd
Merge remote-tracking branch 'origin/master' into feature/disable-git
jedwards4b Feb 19, 2025
6be322e
Update cprnc submodule to v1.1.1
jgfouca Feb 19, 2025
42f8474
Merge pull request #4756 from jedwards4b/feature/disable-git
jedwards4b Feb 19, 2025
1a161a5
Merge pull request #4755 from ESMCI/jgfouca/update_cprnc
jgfouca Feb 19, 2025
a085291
Adds model devcontainers
jasonb5 Feb 20, 2025
3016724
Cleans up _print_machine_values
jasonb5 Feb 21, 2025
7175fdb
Fixes file formatting
jasonb5 Feb 21, 2025
659f93d
Refactors to generalized method to print children based on attribute …
jasonb5 Feb 21, 2025
087ce16
Fixes check if compiler argument is valid
jasonb5 Feb 21, 2025
6055f46
Fixes spelling error
jasonb5 Feb 21, 2025
49c259c
Fixes error message
jasonb5 Feb 21, 2025
a2fb387
Adds comments
jasonb5 Feb 21, 2025
ad868fa
Adds initial tests
jasonb5 Feb 21, 2025
f50de54
Adds tests
jasonb5 Feb 21, 2025
39130af
Fixes black formatting
jasonb5 Feb 21, 2025
c1147fb
Fixes failing test
jasonb5 Feb 21, 2025
af09a89
Fixes changes to frontier.
jasonb5 Feb 22, 2025
28de1bb
Merge branch 'master' into adds-query_config-compiler-info
jasonb5 Feb 22, 2025
44e4b46
Merge tag 'cime6.1.67' into add_postprocessing_env_file
mnlevy1981 Feb 26, 2025
1e9b23e
Add _file_exists to Postprocessing class
mnlevy1981 Feb 28, 2025
cac27fe
create env_postprocessing.xml if spec file exists
mnlevy1981 Mar 3, 2025
3517d8a
Update action/cached to v3
mnlevy1981 Mar 3, 2025
d393f0c
Move logic to remove empty env_postprocessing.xml
mnlevy1981 Mar 4, 2025
b2bbd83
Fix CI
mnlevy1981 Mar 4, 2025
f9da5bb
Only append EnvPostprocessing in two situations:
mnlevy1981 Mar 4, 2025
abbff8a
Update logic for removing env_postprocessing.xml
mnlevy1981 Mar 4, 2025
b1f8a44
Model may not define POSTPROCESSING_SPEC_FILE
mnlevy1981 Mar 4, 2025
d58c5ea
Merge branch 'master' into add_postprocessing_env_file
mnlevy1981 Mar 4, 2025
71d2b71
Merge pull request #4742 from mnlevy1981/add_postprocessing_env_file
jedwards4b Mar 5, 2025
ab0664e
bless_test_results now allows blessing if test only failed GENERATE.
samsrabin Mar 6, 2025
049f197
Move check for only_failed_generate to minimize testing impact.
samsrabin Mar 6, 2025
89531b3
Resolve StopIterationError in test_is_bless_needed_overall_fail(). No…
samsrabin Mar 6, 2025
31f7ce0
Black-reformat test_unit_bless_test_results.py.
samsrabin Mar 6, 2025
9627c2f
make compset names case insensitive but retain user prefered case
jedwards4b Mar 6, 2025
22f76d3
update python minimum to 3.8
jedwards4b Mar 6, 2025
78bfcb8
update message string
jedwards4b Mar 6, 2025
a1e6551
make datetime backward compatible
jedwards4b Mar 6, 2025
6a2eb02
Merge pull request #4762 from jedwards4b/make_compset_case_insensitive
jedwards4b Mar 6, 2025
ab66ca0
only_failed_generate bugfix.
samsrabin Mar 6, 2025
bf55a51
safe_copy: Use /bin/cp as last resort
jgfouca Mar 7, 2025
8056075
Cleanup impl a bit
jgfouca Mar 10, 2025
daad67a
Handle case where there is no cp
jgfouca Mar 10, 2025
21cd8ef
Removes vscode devcontainers and tasks.
jasonb5 Mar 11, 2025
c69190e
Merge pull request #4763 from ESMCI/jgfouca/safe_copy_last_resort
jgfouca Mar 11, 2025
2b98c1d
Merge pull request #4761 from jedwards4b/update_python_min
jedwards4b Mar 11, 2025
11a5553
Bugfix in is_hist_bless_needed().
samsrabin Mar 12, 2025
ae21da1
Fix test_is_bless_needed_overall_fail.
samsrabin Mar 12, 2025
1e0e112
Add test_is_bless_needed_generate_fail.
samsrabin Mar 12, 2025
56cd44c
Fix ERR test for E3SM
jgfouca Mar 13, 2025
3fcb1d3
Merge pull request #4765 from ESMCI/jgfouca/fix_ERR_for_E3SM
jgfouca Mar 14, 2025
fe49f5f
Fixes error message rather than exception
jasonb5 Mar 17, 2025
36cf5e4
Merge pull request #4759 from ESMCI/adds-query_config-compiler-info
jasonb5 Mar 18, 2025
e858c2b
Set cprnc out filename to None when not created
mkstratos Mar 20, 2025
1fde6df
Merge pull request #4760 from samsrabin/bless-if-only-failed-generate
jedwards4b Mar 24, 2025
dc52499
update CIME to build Kokkos in CAM
sjsprecious Mar 26, 2025
a398049
redo REST_N calculation for IRT test
jedwards4b Mar 26, 2025
909fffe
fix debug flags for intel compiler
jedwards4b Mar 26, 2025
a176854
only check cam_target when kokkos is used
sjsprecious Mar 26, 2025
bbbd3e5
format change
sjsprecious Mar 26, 2025
4b5c6a5
update XML schema for GPU vars
sjsprecious Mar 27, 2025
fd992cb
remove complext type for gpu_type
sjsprecious Mar 27, 2025
6c6344a
format change
sjsprecious Mar 27, 2025
e05ca05
Merge pull request #4770 from jedwards4b/address_IRT_test_issue
jedwards4b Mar 27, 2025
27b68fc
fix pre-commit error
sjsprecious Mar 27, 2025
20a94bc
fix pylint error
sjsprecious Mar 27, 2025
eb7433e
Remove y100k testmod from ERS test in cime_developer
jgfouca Mar 27, 2025
e2aa10d
remove check for kokkos in Makefile system
sjsprecious Mar 27, 2025
beb06a3
rudementary support for years > 9999
jedwards4b Mar 27, 2025
7567c2f
remove shared_lib argument
sjsprecious Mar 27, 2025
dfe2282
remove the path for e3sm
sjsprecious Mar 27, 2025
dd70c2e
Ensure two related messages are printed together.
samsrabin Mar 28, 2025
59f1e25
Revert "remove shared_lib argument"
sjsprecious Mar 28, 2025
bef2dc6
disable pylint for shared_lib
sjsprecious Mar 28, 2025
c871a9f
move kokkos-related changes to CAM-specific place
sjsprecious Mar 28, 2025
1c50e5a
fix syntan error for pylint
sjsprecious Mar 28, 2025
e553887
update path to kokkos build script for CAM
sjsprecious Mar 28, 2025
9c30bff
format change
sjsprecious Mar 28, 2025
0a99500
simplify math
jedwards4b Mar 28, 2025
e5d1230
remove unneeded _rx1 from grid names
jedwards4b Mar 28, 2025
69855bf
Remove redundant print of file path in 'Cannot download file' msg.
samsrabin Mar 28, 2025
e44b161
remove _rx1 from grid description
jedwards4b Mar 28, 2025
927a9f2
black-reformat check_input_data.py.
samsrabin Mar 28, 2025
db1e626
Add previous commit to .git-blame-ignore-revs.
samsrabin Mar 28, 2025
321925f
Merge branch 'master' into fix-broken-cant-download-file-warning
samsrabin Mar 28, 2025
ed697a5
Merge pull request #4772 from sjsprecious/build_kokkos_in_cam
jedwards4b Mar 28, 2025
69721b6
Merge pull request #4774 from jedwards4b/allow_years_to_999999
jedwards4b Mar 28, 2025
e002da0
Merge pull request #4769 from ESMCI/mkstratos/fix-bless-error
jedwards4b Mar 31, 2025
e9ecd92
Merge pull request #4773 from samsrabin/fix-broken-cant-download-file…
jedwards4b Mar 31, 2025
2f91136
Merge pull request #4771 from jedwards4b/intelflagfix
jedwards4b Apr 1, 2025
1304e64
clean up CAM specific Kokkos setups
sjsprecious Apr 7, 2025
704d538
change from only noting the last jobid, to all of them
jedwards4b Apr 7, 2025
ea6b72f
Merge pull request #4778 from jedwards4b/case_submit_should_record_al…
jedwards4b Apr 7, 2025
444f2b3
set up kokkos env var and flags
sjsprecious Apr 7, 2025
4316fd2
updates needed for cesm, does not affect e3sm
jedwards4b Apr 8, 2025
249db76
Merge pull request #4779 from jedwards4b/update_mpi-serial_build
jedwards4b Apr 8, 2025
d132abb
add missing kokkos flag
sjsprecious Apr 8, 2025
3b16cf0
do not include Makefile.kokkos
sjsprecious Apr 9, 2025
0a443b8
build kokkos only when MCT coupler is used
sjsprecious Apr 9, 2025
ca73584
fix mem per node on derecho
jedwards4b Apr 9, 2025
f556dba
fix mem per node on derecho
jedwards4b Apr 9, 2025
23c5066
response to copilot review
jedwards4b Apr 9, 2025
bfda615
Merge pull request #4781 from jedwards4b/mem_per_node_fix
jedwards4b Apr 9, 2025
06bfd1b
Merge branch 'master' into clean_up_kokkos_in_cime
sjsprecious Apr 10, 2025
cd6eaf6
Merge pull request #4783 from sjsprecious/clean_up_kokkos_in_cime
jedwards4b Apr 10, 2025
ca30022
there appears to have been a merge error, removed duplicate line
jedwards4b Apr 14, 2025
26480c7
remove debug print
jedwards4b Apr 14, 2025
b7cafb6
Update CIME/case/case_st_archive.py
jedwards4b Apr 14, 2025
c8321f0
black reformat
jedwards4b Apr 14, 2025
742ff3b
Merge remote-tracking branch 'origin/master' into st_archive_fix
jedwards4b Apr 15, 2025
1ac82a1
fix unintended change in e3sm
jedwards4b Apr 15, 2025
d516f6e
Unintended change to cprnc
jedwards4b Apr 15, 2025
2440737
fix unintended change in e3sm archiving
jedwards4b Apr 15, 2025
02181be
black reformat file
jedwards4b Apr 15, 2025
30e1bcf
working again I think
jedwards4b Apr 15, 2025
50c1191
some cleanup
jedwards4b Apr 15, 2025
76af77e
black format file
jedwards4b Apr 15, 2025
f52552d
add rpointer_content
jedwards4b Apr 16, 2025
5d853b7
fix issue with no rpointer file
jedwards4b Apr 16, 2025
4d27f41
more rpointer fixes
jedwards4b Apr 16, 2025
361175a
Revert mct guard for kokkos
jgfouca Apr 16, 2025
e35bb8a
Adjust kokkos check for nuopc
jgfouca Apr 17, 2025
67569ca
Merge pull request #4787 from ESMCI/jgfouca/fix_kokkos
jgfouca Apr 17, 2025
8d44a87
softly warn users about using python <3.8
mahf708 Apr 11, 2025
2343dba
Merge pull request #4786 from jedwards4b/st_archive_fix
jedwards4b Apr 22, 2025
9a0eee5
Added code to make st-archive handle DART files
kdraeder Apr 22, 2025
b27b5dc
bless_test_results: fix stale file use case
jgfouca Apr 23, 2025
7090d7c
make pylint happy
jgfouca Apr 24, 2025
f9db6d9
Merge pull request #4789 from ESMCI/jgfouca/fix_btr_stale_file
jgfouca Apr 24, 2025
c4db1bd
fix math in calculation of startdate
jedwards4b Apr 28, 2025
401ebde
try updating cesm from master to cesm3.0-alphabranch
jedwards4b Apr 28, 2025
5f6a6a8
Merge pull request #4790 from jedwards4b/fix/startdate_math
jedwards4b Apr 28, 2025
97db1c1
modified for ftorch
jedwards4b May 1, 2025
35a66ab
add support to build and link FTorch
jedwards4b May 2, 2025
8e5ed03
output selected GPTL timing info when using NUOPC driver
sjsprecious May 2, 2025
c63fd0b
Merge pull request #4791 from sjsprecious/output_gptl_timing_info
jedwards4b May 5, 2025
1d15f35
update Makefile
jedwards4b May 6, 2025
80d7f9c
add TORCH_DIR
jedwards4b May 6, 2025
85122a8
improved interface
jedwards4b May 7, 2025
04e4feb
fix ftorch include path
jedwards4b May 8, 2025
4b8ebc1
improve FTorch interface
jedwards4b May 8, 2025
0bb5572
Changes to get mpi-serial cases to work again
ekluzek May 11, 2025
9da1b5f
Merge tag 'cime6.1.93' into change_min_mem_for_batch
ekluzek May 11, 2025
1def804
Merge remote-tracking branch 'mydev/ftorch_1236c0fed' into HEAD
jedwards4b May 12, 2025
0a1fc86
optionally build ftorch library
jedwards4b May 12, 2025
b2759d5
need to ignore these files in git as well
jedwards4b May 13, 2025
aa1c5af
Merge pull request #4784 from mahf708/fix-python-check
jasonb5 May 13, 2025
ad2830e
Merge pull request #4797 from jedwards4b/ftorch_optional_support
jedwards4b May 13, 2025
0a7f9be
model_version field should not be compared as it is expected to differ
jedwards4b May 14, 2025
38bf614
Merge pull request #4799 from jedwards4b/fix_config_compare
jedwards4b May 14, 2025
b5e908c
Add GPU_TYPE to FakeCase, fixing #4800
ekluzek May 14, 2025
1f8d709
Merge commit 'b5e908c0a' into change_min_mem_for_batch
ekluzek May 14, 2025
bf86684
Merge pull request #4798 from jedwards4b/add_pbs_output_to_gitignore
jedwards4b May 14, 2025
a2eea78
Add a simple unit test for fake_case that's in configure
ekluzek May 14, 2025
03547a0
Add a test of getting a bad value
ekluzek May 15, 2025
7f187ad
Add test for get_case_root
ekluzek May 15, 2025
dc3bb91
Add a unit test for configure that would hae detected the problem wit…
ekluzek May 15, 2025
d4d9fd3
Merge pull request #4788 from kdraeder/cime_st-arch_dart
jedwards4b May 15, 2025
83f77d1
test_schedule: big cleanup of producer
jgfouca May 15, 2025
3bb1e99
Formatting and disable fstring logging warning
jgfouca May 15, 2025
5125869
Fix race in check_input_data
jgfouca May 15, 2025
461b918
Fix trailing ws
jgfouca May 15, 2025
d100a79
Merge pull request #4801 from ESMCI/jgfouca/test_sched_cleanup
jgfouca May 15, 2025
c11bfd7
Rather than specifying derecho specifically have it figure out the de…
ekluzek May 16, 2025
4616a82
Merge tag 'cime6.1.100' into change_min_mem_for_batch
ekluzek May 16, 2025
72e30c8
Ran pre-commit which ran through black
ekluzek May 16, 2025
713ee91
Set SRCROOT with GLOBAL in utils rather than os.environ which caused …
ekluzek May 20, 2025
b7769fe
Set srcroot by just using the util, this does work for a running just…
ekluzek May 20, 2025
b53fffa
Start adding a simple test to check get_job_overrides, it fails on a …
ekluzek May 20, 2025
484d7b7
total_tasks can be a string, so should have an int around it
ekluzek May 21, 2025
742aa5d
Somewhat hardwired, but use the actual get_job_overrides for a single…
ekluzek May 21, 2025
f6144d2
Refactor to make the test more flexible and so can add more tests
ekluzek May 21, 2025
47c8322
Refactor more so FakeCase keeps the variables it needs to setup any g…
ekluzek May 21, 2025
0cbf954
Add a bunch of tests for several different task counts
ekluzek May 22, 2025
dd799fc
Make sure total_tasks is changed to integer, so math and equalities c…
ekluzek May 22, 2025
563ad85
Add a unit test for 25 tasks that currently fails, because env_batch …
ekluzek May 22, 2025
1ae7e8c
Fix the tests to work now
ekluzek May 22, 2025
4d4d8bc
Add a comment about why the FakeCase class was extended rather than u…
ekluzek May 22, 2025
454bd07
Revert "Output GPTL timing info when using NUOPC driver"
jedwards4b May 22, 2025
653865e
Merge pull request #4803 from ESMCI/revert-4791-output_gptl_timing_info
jedwards4b May 22, 2025
21c9cbd
work on e3sm build error
jedwards4b May 22, 2025
581e01d
add more logging
jedwards4b May 22, 2025
f91a660
add a new optional attribute to files.get_value attribute_required wi…
jedwards4b May 22, 2025
c85af4f
fix pylint issues
jedwards4b May 22, 2025
a49c062
black reformat files
jedwards4b May 22, 2025
8e3a3aa
improve logic
jedwards4b May 22, 2025
95ed889
my_file may not exist
jedwards4b May 22, 2025
1006c39
Merge pull request #4802 from ekluzek/change_min_mem_for_batch
jedwards4b May 22, 2025
b41e38b
copy any additional xml files in case into clone
jedwards4b Jun 25, 2025
3334305
Update CIME/case/case_clone.py
jedwards4b Jun 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Migrated code style to Black
eabf877cbb86b281fdd37a3fa3cc0edf9b8eb874
321463922724b225988e517da54a18bad90bc316
927a9f23a11bc2c83e4fc1a0d004efd98f7cb812
6751504adf095d5d034e6406fbb0e914924aecff
10 changes: 4 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ Lines should be wrapped at about 72 characters. Please also update
the CIME documentation, if necessary, in doc/source/rst and indicate
below if you need to have the gh-pages html regenerated.]

Test suite:
Test baseline:
Test namelist changes:
Test suite:
Test baseline:
Test namelist changes:
Test status: [bit for bit, roundoff, climate changing]

Fixes [CIME Github issue #]

User interface changes?:
User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
251 changes: 251 additions & 0 deletions .github/scripts/ghcr-prune.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
import argparse
import logging
import requests
import re
import json
from datetime import datetime
from datetime import timedelta


class GHCRPruneError(Exception):
pass


description = """
This script can be used to prune container images hosted on ghcr.io.\n

Our testing workflow will build and push container images to ghcr.io
that are only used for testing. This script is used to cleanup these
temporary images.

You can filter containers by any combination of name, age, and untagged.
"""

parser = argparse.ArgumentParser(
description=description, formatter_class=argparse.RawTextHelpFormatter
)

parser.add_argument("--token", required=True, help='GitHub token with "repo" scope')
parser.add_argument("--org", required=True, help="Organization name")
parser.add_argument("--name", required=True, help="Package name")
parser.add_argument(
"--age",
type=int,
help="Filter versions by age, removing anything older than",
default=7,
)
parser.add_argument(
"--filter", help="Filter which versions are consider for pruning", default=".*"
)
parser.add_argument(
"--filter-pr",
action="store_true",
help="Filter pull requests, will skip removal if pull request is still open.",
)
parser.add_argument("--pr-prefix", default="pr-", help="Prefix for a pull request tag")
parser.add_argument("--untagged", action="store_true", help="Prune untagged versions")
parser.add_argument(
"--dry-run", action="store_true", help="Does not actually delete anything"
)

logging_group = parser.add_argument_group("logging")
logging_group.add_argument(
"--log-level", choices=("DEBUG", "INFO", "WARNING", "ERROR"), default="INFO"
)

kwargs = vars(parser.parse_args())

logging.basicConfig(level=kwargs["log_level"])

logger = logging.getLogger("ghcr-prune")

logger.debug(f"Running with arguments:\n{kwargs}")


class GitHubPaginate:
"""Iterator for GitHub API.

Provides small wrapper for GitHub API to utilize paging in API calls.

https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api?apiVersion=2022-11-28
"""

def __init__(
self, token, org, name, age, filter, untagged, filter_pr, pr_prefix, **_
):
self.token = token
self.session = None
self.url = (
f"https://api.github.com/orgs/{org}/packages/container/{name}/versions"
)
self.pr_url = f"https://api.github.com/repos/{org}/{name}/pulls"
self.expired = datetime.now() - timedelta(days=age)
self.filter_pr = filter_pr
self.pr_prefix = pr_prefix
self.filter = re.compile(filter)
self.page = None
self.untagged = untagged

def create_session(self):
self.session = requests.Session()
self.session.headers.update(
{
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {self.token}",
"X-GitHub-Api-Version": "2022-11-28",
}
)

def is_pr_open(self, pr_number):
logger.info(f"Checking if PR {pr_number} is still open")

pr_url = f"{self.pr_url}/{pr_number}"

response = self.session.get(pr_url)

response.raise_for_status()

data = response.json()

state = data["state"]

return state == "open"

def grab_page(self):
if self.session is None:
raise GHCRPruneError("Must create session first")

if self.url is None:
raise GHCRPruneError("No more pages")

response = self.session.get(self.url)

response.raise_for_status()

remaining = int(response.headers["X-RateLimit-Remaining"])

logger.debug(f"Remaining api limit {remaining}")

if remaining <= 0:
reset = response.headers["X-RateLimit-Reset"]

raise GHCRPruneError(f"Hit ratelimit will reset at {reset}")

try:
self.url = self.get_next_url(response.headers["Link"])
except Exception as e:
logger.debug(f"No Link header found {e}")

self.url = None

return self.filter_results(response.json())

def get_next_url(self, link):
match = re.match("<([^>]*)>.*", link)

if match is None:
raise Exception("Could not determine next link")

return match.group(1)

def filter_results(self, data):
results = []

logger.info(f"Processing {len(data)} containers")

logger.info(f"Expiration date set to {self.expired}")

for x in data:
url = x["url"]
updated_at = datetime.strptime(x["updated_at"], "%Y-%m-%dT%H:%M:%SZ")

logger.debug(f"Processing\n{json.dumps(x, indent=2)}")

tags = x["metadata"]["container"]["tags"]

if len(tags) == 0:
logger.info(f'Found untagged version {x["id"]}')

if self.untagged:
logger.info(f'Pruning version {x["id"]}')

results.append(url)

continue

# Any tag that is still valid will cause a pacakge version to not be removed
remove_package_version = True

for tag in tags:
if self.filter_pr and tag.startswith(self.pr_prefix):
pr_number = tag[len(self.pr_prefix) :]

if self.is_pr_open(pr_number):
logger.info(
f"Skipping package version {x['id']}, PR {pr_number} is still open"
)

remove_package_version = False

break
elif self.filter.match(tag) and updated_at > self.expired:
logger.info(
f"Skipping package version {x['id']}, tag {tag!r} matched but was updated at {updated_at}"
)

remove_package_version = False

break
else:
logger.info(f"Skipping package version {x['id']}, tag {tag!r}")

remove_package_version = False

break

if remove_package_version:
logger.info(f"Pruning package version {x['id']}")

results.append(url)

return results

def __iter__(self):
self.create_session()

return self

def __next__(self):
if self.page is None or len(self.page) == 0:
try:
self.page = self.grab_page()
except GHCRPruneError as e:
logger.debug(f"StopIteration condition {e!r}")

raise StopIteration from None

try:
item = self.page.pop(0)
except IndexError:
raise StopIteration from None

return item

def remove_container(self, url):
if self.session is None:
raise Exception("Must create session first")

response = self.session.delete(url)

response.raise_for_status()

logger.debug(f"{response.headers}")


pager = GitHubPaginate(**kwargs)

for url in pager:
logger.info(f"Pruning {url}")

if not kwargs["dry_run"]:
pager.remove_container(url)
24 changes: 24 additions & 0 deletions .github/workflows/bumpversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bump version
on:
push:
branches:
- master
permissions: {}
jobs:
build:
permissions:
contents: write # to create a tag (mathieudutour/github-tag-action)

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
create_annotated_tag: true
default_bump: patch
dry_run: false
tag_prefix: cime
fetch_all_tags: true
Loading