-
Notifications
You must be signed in to change notification settings - Fork 5
478 caravan forcing downloads and unzips shapefiles for all caravan with each basin leads to errors fixes #478 #479
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
base: main
Are you sure you want to change the base?
Conversation
removed check on polygon, which gave errors that were not correct, possible because check was done before file was written?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #479 +/- ##
==========================================
- Coverage 78.49% 78.32% -0.17%
==========================================
Files 28 28
Lines 1888 1892 +4
Branches 162 163 +1
==========================================
Hits 1482 1482
- Misses 347 352 +5
+ Partials 59 58 -1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to make some tests for this?
As it should be done and can easily be implemented!
we absolutely want to write some tests for this. I think we should have at least one model run test (HBVLocal?) |
@RolfHut we can do that. |
shape = get_shapefiles(Path(directory), basin_id) | ||
elif Path(shape_in).name == "combined.shp": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not be the most robust way of checking for an already existing combined shapefile. It's also a bit difficult to document.
Maybe it would be better to;
- Not download automatically anymore if
shape=None
, although this breaks existing code using this feature - Add a keyword argument (like the existing
basin_id
one) for downloading the shapes,download_shape
which defaults to false.
# get download_shape from kwargs, default to false;
download_shape = kwargs.get("download_shape", False)
- Add another kwarg
combined_shapefile
that you can use to point to the combined shapefile with all basins
combined_shape = kwargs.get("combined_shape")
if combined_shape is not None:
combined_shape = Path(combined_shape)
if not combined_shape.exists():
msg = "Could not find combined shapefile."
raise FileNotFoundError(msg)
These kwargs can be properly documented in the docstring, and validating the user input is a bit easier this way.
Just be aware that downloading data from the internet during testing is not very desirable. You can have some test data included in the repository however, and "mock" the download of the test so it just points to that file. See https://docs.pytest.org/en/stable/how-to/monkeypatch.html
I think this would be good, but the tests should also be able to run without having a model installed. def model_available()
try:
import ewatercycle_leakybucket
return True
except ModuleNotFoundError:
return False
MODEL_AVAILABLE = model_available()
@pytest.mark.skipif(not MODEL_AVAILABLE, reason="requires leakybucket to be installed")
def test_function(): ... See https://docs.pytest.org/en/stable/how-to/skipping.html#id1 |
allowed the option in shape to point to combined.shp file that is already downloaded. Removed the check on polygons, which threw an error that was not correct stopping workflows