Skip to content

fre pp rename-split#717

Open
ceblanton wants to merge 44 commits intomainfrom
rename-split
Open

fre pp rename-split#717
ceblanton wants to merge 44 commits intomainfrom
rename-split

Conversation

@ceblanton
Copy link
Contributor

@ceblanton ceblanton commented Feb 3, 2026

Describe your changes

Conversion of fre-workflows rename-split shell script into fre-cli python. Preserved existing rename-split test cases.

Issue ticket number and link (if applicable)

Checklist before requesting a review

  • I ran my code
  • I tried to make my code readable
  • I tried to comment my code
  • I wrote a new test, if applicable
  • I wrote new instructions/documentation, if applicable
  • I ran pytest and inspected it's output
  • I ran pylint and attempted to implement some of it's feedback
  • No print statements; all user-facing info uses logging module

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 85.12821% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.24%. Comparing base (15f6c06) to head (b849b7b).

Files with missing lines Patch % Lines
fre/pp/rename_split_script.py 86.20% 24 Missing ⚠️
fre/app/regrid_xy/regrid_xy.py 0.00% 3 Missing ⚠️
fre/pp/frepp.py 88.88% 1 Missing ⚠️
fre/yamltools/info_parsers/pp_info_parser.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #717      +/-   ##
==========================================
+ Coverage   84.22%   84.24%   +0.01%     
==========================================
  Files          70       71       +1     
  Lines        4773     4962     +189     
==========================================
+ Hits         4020     4180     +160     
- Misses        753      782      +29     
Flag Coverage Δ
unittests 84.24% <85.12%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
fre/app/generate_time_averages/wrapper.py 94.94% <100.00%> (ø)
fre/pp/frepp.py 86.66% <88.88%> (+0.18%) ⬆️
fre/yamltools/info_parsers/pp_info_parser.py 86.72% <85.71%> (-0.55%) ⬇️
fre/app/regrid_xy/regrid_xy.py 14.04% <0.00%> (-0.36%) ⬇️
fre/pp/rename_split_script.py 86.20% <86.20%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15f6c06...b849b7b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ilaflott ilaflott self-requested a review February 4, 2026 15:10
@ilaflott
Copy link
Member

ilaflott commented Feb 4, 2026

@copilot open a PR to this branch and:

  • try reducing the cdl files to a minimal set of required data points
  • the unit tests must succeed
  • try with just the atmos_daily case(s) first

Copy link
Contributor

Copilot AI commented Feb 4, 2026

@ilaflott I've opened a new pull request, #719, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Member

@ilaflott ilaflott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bunch of this is nit picking about style, this looks largely functional. i'll ponder approving when it's taken out of draft

@ceblanton ceblanton marked this pull request as ready for review February 18, 2026 14:54
Chris Blanton and others added 4 commits February 24, 2026 16:54
This is needed for input files with one timestep and no time bounds.
- Proper docstrings
- Module import cleanup
- Indent cleanup
- Other: remove unneeded environment variables
duration_object = duration_parser.parse(duration)
date2 = date1 + duration_object - one_month
format_ = "%Y"
freq_label = duration
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewers, this elif section that assumes a history file's frequency based on its name (i.e. containing "annual") is distasteful.

The just-above "if diag_manifest exists" will be the long-term approach.

But until diag manifests are safely assumed to be available, I think this temporary hard-coding is worth it.

@ceblanton ceblanton requested review from ilaflott and singhd789 March 17, 2026 20:26
@ceblanton
Copy link
Contributor Author

I think this is completely ready now

Copy link
Member

@ilaflott ilaflott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready to approve pending response to my comment on fre/yamltools/info_parsers/pp_info_parser.py. the other comments i have are nits that are style-oriented, or have to do with untested try/except lines that don't generally give me anxiety

Comment on lines +46 to +53
def test_get_duration_from_two_dates():
"""
Lookup some durations between two dates
"""
assert "P1M" == get_duration_from_two_dates(cftime.datetime(2009, 1, 1), cftime.datetime(2009, 2, 1))
assert "P6M" == get_duration_from_two_dates(cftime.datetime(2009, 1, 1), cftime.datetime(2009, 7, 1))
assert "P1Y" == get_duration_from_two_dates(cftime.datetime(2009, 1, 1), cftime.datetime(2010, 1, 1))
assert "P5Y" == get_duration_from_two_dates(cftime.datetime(2000, 1, 1), cftime.datetime(2005, 1, 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could be parameterize cases via pytest

yaml_content_str += settings_content
fre_logger.info(" settings yaml: %s", settings)
else:
fre_logger.info(" settings yaml: not used")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this decision branch being untested is the one that worries me the most currently- especially since we're going toward no-settings-yaml. is this because the schema isn't updated yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a large necessary change that @singhd789 is making to the yaml parsing and combining methods, both to standardize the methods and to use uw config compose as the primary combining mechanism.

There will be plenty of settings yamls everywhere, in that any yaml piece can be a reusable settings yaml. But these settings yamls will be schema-controlled based on the application schema, not a top-level "settings" schema.

From the meeting today I think we almost agreed :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was a lot more than i bargained for! I was mostly trying to figure out how permissive to be on the untested-lines front. since many are hashing this out in a very thoughful manner elsewhere, trying to account for a myriad of concerns beyond the scope of the repo, i'll let it slide as a nit

@cwhitlock-NOAA
Copy link
Contributor

cwhitlock-NOAA commented Mar 18, 2026 via email

@ilaflott
Copy link
Member

ilaflott commented Mar 23, 2026

though you got conflicts to fix! so merging is still blocked for now
only for rebase

@ilaflott
Copy link
Member

it'd also be good to make sure the pipeline passes after you fix conflicts and update via rebase

ilaflott and others added 6 commits March 23, 2026 15:06
What changed:

Converted 6 inline assertions into a parametrized test with 6 test cases
Each case now runs as a separate test with clear identifiers like test_get_freq_and_format_from_two_dates[P1Y-%Y]
Cleaner output: if one case fails, others still run and report independently
Benefits:

Improved test clarity and failure reporting
Each test case shows exactly which parameters failed
Easier to add new test cases in the future
Follows pytest best practices

refactored test_get_duration_from_two_dates using the same @pytest.mark.parametrize approach. The 4 test cases now run independently, making it easy to identify which specific duration calculation fails if any of them do.
New exception tests:

test_get_freq_and_format_from_two_dates_raises_valueerror (parameterized, 2 cases)

Tests ValueError when frequency cannot be determined from dates
test_get_duration_from_two_dates_raises_valueerror (parameterized, 2 cases)

Tests ValueError when duration cannot be determined from dates
test_rename_split_raises_filenotfounderror_no_files

Tests FileNotFoundError when no files matching the component are found
test_rename_file_raises_valueerror_bad_filename

Tests ValueError when filename doesn't match the expected format
test_rename_file_raises_filenotfounderror_missing_diag_manifest

Tests FileNotFoundError when a non-existent diag manifest path is provided
All tests use pytest.raises() with appropriate error message matching. The file has no syntax errors and the tests follow the same patterns as the existing parameterized tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants