Skip to content

Only do geometries.geoms when the attribute is present.#520

Open
EmileSonneveld wants to merge 6 commits into
masterfrom
geoms_attribute
Open

Only do geometries.geoms when the attribute is present.#520
EmileSonneveld wants to merge 6 commits into
masterfrom
geoms_attribute

Conversation

@EmileSonneveld

Copy link
Copy Markdown
Member

#519
@copilot review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Open-EO Open-EO deleted a comment from Copilot AI Jun 25, 2026
@EmileSonneveld EmileSonneveld requested a review from soxofaan June 25, 2026 11:39
Comment thread openeo_driver/save_result.py Outdated
def features_ids_from_index(geometries):
return ["feature_%d" % i for i in range(len(geometries.geoms))]
geoms = geometries.geoms if hasattr(geometries, "geoms") else geometries
return ["feature_%d" % i for i in range(len(geoms))]

@soxofaan soxofaan Jun 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

features_ids_from_index is already a bit obscure because of lack of type annotations. Adding this if here makes it worse I think

I would fully eliminate features_ids_from_index and just do the list comprehension inline in the if-else below. Something like

        if isinstance(self._regions, GeometryCollection):
            ...
            feature_ids = ["feature_%d" % i for i in range(len(self._regions))]
        elif isinstance(self._regions, DriverVectorCube):
            ...
            feature_ids = (list(feature_ids) if feature_ids is not None
                           else ["feature_%d" % i for i in range(self._regions.geometry_count())])
        else:
            raise ValueError(self._regions)

(Note: GeometryCollection is something we should get rid of, so this would prepare more cleanly for that)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used ai first. Could have been better. I used your suggestion now. That works fine

if not isinstance(regions, (GeometryCollection, DriverVectorCube)):
# TODO: raise exception instead of warning?
_log.warning(
raise ValueError(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@soxofaan I did not find this warning in kibana. Safe to convert it to Exception?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes makes sense

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.

2 participants