Skip to content

Commit

Permalink
fix some bugs in the discover nowcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
Loickemajou authored Aug 19, 2024
1 parent b9dc46d commit a8a401f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pysteps/nowcasts/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,26 @@ def discover_nowcasts():
for entry_point in pkg_resources.iter_entry_points(
group="pysteps.plugin.nowcasts", name=None
):
_nowcast_module_name = entry_point.name
if _nowcast_module_name not in _nowcast_methods:
module = importlib.import_module(entry_point.module_name)
_nowcast_methods[_nowcast_module_name] = module.forecast
_module = entry_point.load()
nowcast_module_name = entry_point.name

Check warning on line 82 in pysteps/nowcasts/interface.py

View check run for this annotation

Codecov / codecov/patch

pysteps/nowcasts/interface.py#L81-L82

Added lines #L81 - L82 were not covered by tests

if nowcast_module_name not in _nowcast_methods:
_nowcast_methods[nowcast_module_name] = _module

Check warning on line 85 in pysteps/nowcasts/interface.py

View check run for this annotation

Codecov / codecov/patch

pysteps/nowcasts/interface.py#L84-L85

Added lines #L84 - L85 were not covered by tests

else:
RuntimeWarning(

Check warning on line 88 in pysteps/nowcasts/interface.py

View check run for this annotation

Codecov / codecov/patch

pysteps/nowcasts/interface.py#L88

Added line #L88 was not covered by tests
f"The Nowcasts methode '{_nowcast_module_name}' is already available in"
f"The Nowcasts methode '{nowcast_module_name}' is already available in"
"'pysteps.nowcasts._nowcasts_methods'.\n"
f"Skipping {entry_point.module_name}:{'.'.join(entry_point.attrs)}"
)
if hasattr(nowcasts, nowcast_module_name):
RuntimeWarning(

Check warning on line 94 in pysteps/nowcasts/interface.py

View check run for this annotation

Codecov / codecov/patch

pysteps/nowcasts/interface.py#L93-L94

Added lines #L93 - L94 were not covered by tests
f"The nowcasts method '{nowcast_module_name}' is already an attribute"
"of 'pysteps.nowcasts'.\n"
f"Skipping {entry_point.module_name}:{'.'.join(entry_point.attrs)}"
)
else:
setattr(nowcasts, nowcast_module_name, _module)

Check warning on line 100 in pysteps/nowcasts/interface.py

View check run for this annotation

Codecov / codecov/patch

pysteps/nowcasts/interface.py#L100

Added line #L100 was not covered by tests


def nowcasts_info():
Expand Down

0 comments on commit a8a401f

Please sign in to comment.