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

PPS 2021 refactor #60

Merged
merged 45 commits into from
Apr 15, 2024
Merged

PPS 2021 refactor #60

merged 45 commits into from
Apr 15, 2024

Conversation

ninahakansson
Copy link
Contributor

@ninahakansson ninahakansson commented Jan 26, 2024

Update the code to support only PPS-2021 and drop support for PPS 2014. The main thing is that the pps runner need only the level1c file to run. The NWP preparation is now in a separate runner. Some refactoring, with more subroutines in prepare_nwp

  • Closes Refactor utils module #56
  • Tests added
  • Tests passed: Passes pytest nwcsafpps_runner
  • Passes flake8 nwcsafpps_runner
  • Fully documented

Nina.Hakansson added 13 commits January 16, 2024 10:25
…4oldfiles, create_xml_timestat_from_scene, get_time_control_ascii_filename, get_time_control_ascii_filename_candidates, get_product_statistics_files
get_sceneid
create_pps_call_command_sequence
get_pps_inputfile
get_xml_outputfiles
Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: Patch coverage is 74.02597% with 60 lines in your changes are missing coverage. Please review.

Project coverage is 74.24%. Comparing base (fc4314d) to head (5354d27).

❗ Current head 5354d27 differs from pull request most recent head c977117. Consider uploading reports for the commit c977117 to get more accurate results

Files Patch % Lines
nwcsafpps_runner/prepare_nwp.py 64.70% 31 Missing and 11 partials ⚠️
nwcsafpps_runner/message_utils.py 11.11% 8 Missing ⚠️
nwcsafpps_runner/utils.py 78.12% 5 Missing and 2 partials ⚠️
nwcsafpps_runner/config.py 82.35% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   70.55%   74.24%   +3.68%     
==========================================
  Files          15       15              
  Lines        2201     1778     -423     
  Branches      296      266      -30     
==========================================
- Hits         1553     1320     -233     
+ Misses        606      419     -187     
+ Partials       42       39       -3     
Flag Coverage Δ
unittests 74.24% <74.02%> (+3.68%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@pnuu pnuu left a comment

Choose a reason for hiding this comment

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

Just couple of quick comments:

  • pps_runner.py is deleted and pps2018_runner.py is modified although the description says v2014 and v2018 support are dropped. Shouldn't it be the other way around?
  • the example configs for v2014 and v2018 should be deleted for clarity if they are not supported any more
  • setup.py installs the v2018 runner

@ninahakansson
Copy link
Contributor Author

Thanks for the comments @pnuu! The pps_runner.py was for version 2014 only. The pps2018_runner.py was for version 2018 and forward. I can rename the pps2018_runner.py to pps_runner.py as there is now only one runner. I will have a look at the config files too.

Nina.Hakansson added 3 commits April 8, 2024 14:22
Had to remove the timeout from the subscr.recv, not sure if it is a problem.
bin/level1c_runner.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@@ -51,7 +51,7 @@ def run(self):
LOG.debug("Subscribe topics = %s", str(self.subscribe_topics))
with posttroll.subscriber.Subscribe("", self.subscribe_topics, True) as subscr:

for msg in subscr.recv(timeout=90):
for msg in subscr.recv():
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why we had a timeout of 90 seconds before, but is it safe to change this? Why was this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it because the patched subscriber did not have the timeout keyword. I am not sure if it is safe to remove.

Copy link
Member

Choose a reason for hiding this comment

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

The timeout is needed I think when the thread is shut down. Maybe something we need in the patched_subscriber then.

Copy link
Contributor

@adybbroe adybbroe left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the cleaning and refactoring, looks like the code is moving in the right direction, but also hard to judge with som many changes. I have a few questions. Otherwise I am good with this

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

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

Ok, I'm not sure I really understood how this module was working before, so I trust that you have tested the functionality to be confident this is working.
It's really nice with all the code removal, it will make the code easier to read. And good with new tests also!


LOG = logging.getLogger('nwp-preparation')

# datetime.datetime.utcnow => datetime.datetime.now(datetime.UTC) ~python 3.12
Copy link
Member

Choose a reason for hiding this comment

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

Is this working in 3.12?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the datetime.datetime.now(datetime.UTC) is working in python 3.12 but in 3.9 I get AttributeError: module 'datetime' has no attribute 'UTC'. The datetime.datetime.now(datetime.UTC) will also need some changes in other parts of the code as it is not expecting timezone-aware objects. Currently I get a warning in 3.12: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

@@ -51,7 +51,7 @@ def run(self):
LOG.debug("Subscribe topics = %s", str(self.subscribe_topics))
with posttroll.subscriber.Subscribe("", self.subscribe_topics, True) as subscr:

for msg in subscr.recv(timeout=90):
for msg in subscr.recv():
Copy link
Member

Choose a reason for hiding this comment

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

The timeout is needed I think when the thread is shut down. Maybe something we need in the patched_subscriber then.

nwcsafpps_runner/tests/test_config.py Outdated Show resolved Hide resolved
nwcsafpps_runner/tests/test_config.py Outdated Show resolved Hide resolved
@@ -38,102 +39,111 @@
datefmt='%H:%M:%S')


class NWPprepareRunner(unittest.TestCase):
@pytest.fixture
Copy link
Member

Choose a reason for hiding this comment

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

Nice with a fixture!

Nina.Hakansson and others added 11 commits April 12, 2024 16:04
Also allow to test with list of files
Needed for threads that are shut down. For now it is not working with the patched reciever
Co-authored-by: Adam Dybbroe <adybbroe@users.noreply.github.com>
utcnow to be depricated
There is a logreader function also in the utils module.
@adybbroe adybbroe merged commit 3ff07af into pytroll:main Apr 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor utils module
4 participants