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

Change crop_gribs to operate on files as they arrive #191

Merged
merged 8 commits into from
Aug 9, 2023

Conversation

douglatornell
Copy link
Member

Use watchdog to detect when grib files are moved into place and crop them immediately instead of waiting until collect_weather finishes. crop_gribs is now launched concurrently with collect_weather.

Use watchdog to detect when grib files are moved into place and crop them
immediately instead of waiting until collect_weather finishes.
crop_gribs is now launched concurrently with collect_weather.
Replaced the 'on_moved' event with the 'on_closed' event because file system
events that occur when HRDPS files are moved from downloads directory to
atmospheric forcing tree are create, several modify events, and close. That is
presumably because the files are being moved from one files system to another,
so the move is actually a copy/delete.
@douglatornell
Copy link
Member Author

Tested successfully on skookum for 3aug23 18Z forecast:

  • grib files were cropped concurrently with downloads
  • after_collect_weather() launched collect_weather 00 2.5km and crop_gribs 00 2023-08-04 as expected

Pass grib_fcst_dir to observer.schedule() as string rather than Path to make
type checking happy. Path works fine, but schedule() type hints don't
acknowledge that.

Improve comments and delete commented out code.

Correct super() call in handler on_closed() method override.

Add debug log message to show number of grib files left to be processed. This is
to try to get insight into the worker finishing its job but not terminating.
Refactored `next_workers` to pass the forecast date as part of the arguments list
to the 'crop_gribs' worker. This is necessary because `crop_gribs 06` is
normally launched before midnight. So, it needs to be explicitly given the next
day's date. Tests were updated to reflect this change.
Significantly updated the 'crop_gribs' file event handling tests.
This change introduces two new tests: 'test_crop_expected_file' and
'test_ignore_unexpected_file', ensuring that the worker correctly processes
 only the expected GRIB files and properly ignores others.
 The 'test_constructor' was also updated to validate the new config
 argument.
Changed the type of the config parameter in both the _crop_grib_file and
_write_ssc_grib_file functions from dict to a more specific
py:class:`nemo_nowcast.Config`. This update provides improved type checking
in IDEs.
crop_gribs now operates on files as they are created in the atmospheric
forcing GRIB directory tree. So, it must be started before the
download_weather worker.
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #191 (078a811) into main (b684dc3) will increase coverage by 0.17%.
Report is 2 commits behind head on main.
The diff coverage is 95.55%.

@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   77.41%   77.58%   +0.17%     
==========================================
  Files         133      133              
  Lines       18483    18601     +118     
  Branches     1953     1967      +14     
==========================================
+ Hits        14309    14432     +123     
+ Misses       4119     4111       -8     
- Partials       55       58       +3     
Flag Coverage Δ
unittests 77.58% <95.55%> (+0.17%) ⬆️

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

Files Changed Coverage Δ
nowcast/workers/crop_gribs.py 93.06% <87.50%> (+12.18%) ⬆️
tests/workers/test_crop_gribs.py 99.53% <99.09%> (-0.47%) ⬇️
nowcast/next_workers.py 98.00% <100.00%> (-0.01%) ⬇️
tests/test_next_workers.py 99.74% <100.00%> (-0.01%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

re: concurrency of crop_gribs and collect_weather workers.
@douglatornell douglatornell merged commit 6f60191 into main Aug 9, 2023
@douglatornell douglatornell deleted the faster-crop_gribs branch August 9, 2023 18:36
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.

1 participant