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

localprocessing updates #434

Merged
merged 12 commits into from
Jul 13, 2023
Merged

Conversation

clausmichele
Copy link
Member

This PR contains:

  • added the implementation of resample_cube_spatial based on xArray, since the one in openeo-processes-dask based on opendatacube relies on metadata provided only when the data comes from ODC
  • added two example notebooks
  • updated the minimum required library versions

@clausmichele clausmichele marked this pull request as ready for review June 1, 2023 08:11
Copy link
Member

@soxofaan soxofaan left a comment

Choose a reason for hiding this comment

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

some quick notes

"tags": []
},
"source": [
"<img src=\"https://avatars.githubusercontent.com/u/74911464?s=200&v=4\"\n",
Copy link
Member

Choose a reason for hiding this comment

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

Not to be fixed in this PR, but I noticed that this logo looks quite ragged. I think we should host a proper version of the logo somewhere

"id": "51a9e53a-481c-4ea5-a175-652d6398828d",
"metadata": {},
"source": [
"To use this functionality, you need `3.9<=Python<3.11`.\n",
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 <3.11 constraint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comes from here: https://github.com/Open-EO/openeo-processes-dask/blob/6563c1809fc4108581b78763a970b3bea1d5d935/pyproject.toml#L25

@LukeWeidenwalker how could I help to test more Python versions? It would be good to add 3.11 at least.

Choose a reason for hiding this comment

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

When I initially set up the repo, I put 3.9, 3.10 and 3.11 in the CI matrix for github actions. 3.11 failed for a reason that I can't recall now, and since our backend runs on 3.9, I've just ignored it since. Would be in favor of becoming 3.11 compatible though! I'd start by including 3.11 in the matrix here: https://github.com/Open-EO/openeo-processes-dask/blob/main/.github/workflows/main.yml in a new PR and just seeing what breaks. Once the build passes, we can remove this constraint!

openeo/local/processing.py Outdated Show resolved Hide resolved
openeo/local/processing.py Outdated Show resolved Hide resolved
openeo/local/processing.py Outdated Show resolved Hide resolved
_log.debug(f"kwargs: {pretty_args}")
_log.debug("-" * 80)

methods_list = {
Copy link
Member

Choose a reason for hiding this comment

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

don't call a dictionary a list, that's quite confusing

also: where do these int values come from, is that ad-hoc, or is that defined somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I would then use the enum attributes directly, something like

    "near": rasterio.enums.Resampling.nearest
    ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

also note that that rasterio enum can handle the mapping itself, so I don't think you need your own:

>>> import rasterio.enums
>>> rasterio.enums.Resampling(5)
<Resampling.average: 5>
>>> rasterio.enums.Resampling(4).name
'lanczos'
>>> rasterio.enums.Resampling["gauss"].value
7

Copy link
Member Author

Choose a reason for hiding this comment

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

I created this mapping since in openEO we have "near" instead of "nearest" and "cubicspline" instead of "cubic_spline"

Copy link
Member

Choose a reason for hiding this comment

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

then I would just translate these minor differences, but let rasterio.enums.Resampling do the heavy lifting, e.g.

method = {
    "near": "nearest",
    "cubicspline": "cubic_spline"
}.get(method, method)
try:
    resampling = rasterio.enums.Resampling[method]
except KeyError:
    ValueError(
            f'Selected resampling method not available.... select one of {[r.name for r in rasterio.enums.Resampling]}" ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine. However, if we raise that ValueError, we would list nearest and cubic_spline as allowed resampling methods, that if used in a process graph would make it invalid if there's some validation mechanism in place.

Copy link
Member Author

Choose a reason for hiding this comment

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

@soxofaan I think that this is the last point open before being able to merge. Can we agree on my latest version?

openeo/local/processing.py Outdated Show resolved Hide resolved
@soxofaan soxofaan merged commit 37b3928 into Open-EO:master Jul 13, 2023
8 checks passed
@soxofaan
Copy link
Member

merged

(FYI did some post-merge cleanups in fbf69e6 , including removal of unused input_data_dims which you might want to double check)

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.

3 participants