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

Adapt pysteps to allow for nowcast plugins. #418

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

Loickemajou
Copy link

Creating a DGMR plugin to be intergrated into the pysteps nowcasts methods.

Copy link

codecov bot commented Aug 8, 2024

Codecov Report

Attention: Patch coverage is 81.39535% with 8 lines in your changes missing coverage. Please review.

Project coverage is 83.99%. Comparing base (917c83b) to head (45070d4).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
pysteps/nowcasts/interface.py 78.37% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #418      +/-   ##
==========================================
+ Coverage   83.88%   83.99%   +0.10%     
==========================================
  Files         160      160              
  Lines       12780    12924     +144     
==========================================
+ Hits        10720    10855     +135     
- Misses       2060     2069       +9     
Flag Coverage Δ
unit_tests 83.99% <81.39%> (+0.10%) ⬆️

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.

@Loickemajou Loickemajou reopened this Aug 12, 2024
Copy link
Member

@dnerini dnerini left a comment

Choose a reason for hiding this comment

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

apologies for the slow action on this, I left few comments to clarify certain parts, but otherwise this is looking good!

So the actual plugin would be https://github.com/pySTEPS/pysteps-dgmr-nowcasts right? is everything ready on that side?

pysteps/nowcasts/interface.py Outdated Show resolved Hide resolved
try:
from dgmr_module_plugin import dgmr
except ImportError:
dgmr = None
Copy link
Member

Choose a reason for hiding this comment

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

why this block? the dgmr plugin, if installed, will be discovered below in discover_nowcasts()

Copy link
Member

Choose a reason for hiding this comment

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

oh I see, is it because the function is called forecast and it should be added to a module named dgmr? https://github.com/pySTEPS/pysteps-dgmr-nowcasts/blob/c8903bfa689951c555cfb275fb2100e36a683e40/setup.py#L86

Copy link
Author

Choose a reason for hiding this comment

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

oh I see, is it because the function is called forecast and it should be added to a module named dgmr? https://github.com/pySTEPS/pysteps-dgmr-nowcasts/blob/c8903bfa689951c555cfb275fb2100e36a683e40/setup.py#L86

Also, in the get_method, actually when the plugin is installed, the dgmr is discovered by pysteps and it is possible to

dgmr=get_method('dgmr').

Though is not quite a nice way, included this block so that when the plugin is installed we could called it directly by doing

from pysteps.nowcasts import dgmr.

Had no idea on how to do that differently and will be very delighted to have some suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

I see you removed that part, @Loickemajou , does it mean that you found an alternative solution?

Copy link
Author

Choose a reason for hiding this comment

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

I see you removed that part, @Loickemajou , does it mean that you found an alternative solution?

Hello @dnerini

I have removed the conflicting dependencies and model weights to ensure that they do not interfere with PySTEPS during execution.

However, I have not yet found an alternative solution and would appreciate any suggestions or insights you might have to help improve the integration process.

@Loickemajou
Copy link
Author

Loickemajou commented Aug 22, 2024

apologies for the slow action on this, I left few comments to clarify certain parts, but otherwise this is looking good!

So the actual plugin would be https://github.com/pySTEPS/pysteps-dgmr-nowcasts right? is everything ready on that side?

Hello @dnerini , thanks for reviewing the code.

Concerning the plugin, everything is ok, just left to include a test for the plugin.

@ladc
Copy link
Contributor

ladc commented Aug 27, 2024

I think this can soon be merged, although it shows that the current way the plugins are structured is hitting its limits. It leads to a lot of duplicate code and maintainability issues, and also it's not so flexible. I'll open a separate issue about that.

These modifications allow the pysteps-nowcast-dgmr plugin and other future nowcast plugins to be detected if installed.

@ladc ladc changed the title Dgmr plugin Adapt pysteps to allow for nowcast plugins. Aug 27, 2024
@dnerini
Copy link
Member

dnerini commented Sep 8, 2024

I think this can soon be merged, although it shows that the current way the plugins are structured is hitting its limits. It leads to a lot of duplicate code and maintainability issues, and also it's not so flexible. I'll open a separate issue about that.

Hi @ladc, could you please elaborate on the issues that you mentioned? anything we can do to improve it or should we rather go ahead with this PR as it is now and improve it in a separate effort?

@ladc
Copy link
Contributor

ladc commented Sep 9, 2024

I think the current state is fine, it enables nowcast plugins in pysteps, opening the door for all kinds of data driven methods. The reason why I said it's hitting its limits is because another internship student, @viktor40, wanted to create a plugin which included both post-processing and visualisation functionality, but the way the plugin system is currently designed only allows a single functionality type to be added. I suppose it's not too difficult to extend it but currently the internships are mostly finished so we'll have to do that at a later time.
I would also need to add a test for the nowcast loader, but for that we need to update the cookiecutter - so I propose to go ahead and merge this in, if it's ok for everyone.

# nowcasts methods available in the `nowcasts` package
available_nowcasts = [
attr.split(".")[0]
for attr in os.listdir(" ".join(nowcasts.__path__))
Copy link
Contributor

Choose a reason for hiding this comment

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

@Loickemajou Is there a more elegant way to detect all the nowcast methods that doesn't use os.listdir?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @ladc, for the remark.

I will take time to look into alternative approaches and see if I can find a more elegant way to achieve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants