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

GeoDataset: allow a mix of str and pathlib paths #2270

Merged
merged 3 commits into from
Sep 3, 2024

Conversation

adamjstewart
Copy link
Collaborator

Currently, if a user passes in both str and pathlib.Path paths, GeoDataset crashes:

        # Sort the output to enforce deterministic behavior.
>       return sorted(files)
E       TypeError: '<' not supported between instances of 'PosixPath' and 'str'

The easiest solution is to convert all values to the same type for easy comparison. This also prevents duplicates, since:

>>> import os
>>> import pathlib
>>> x = "foo/bar"
>>> y = pathlib.Path("foo/bar")
>>> x == y
False

FYI @pioneerHitesh @adriantre

@adamjstewart adamjstewart added this to the 0.6.1 milestone Sep 1, 2024
@github-actions github-actions bot added datasets Geospatial or benchmark datasets testing Continuous integration testing labels Sep 1, 2024
Copy link
Contributor

@adriantre adriantre left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

@adamjstewart adamjstewart merged commit 6576b40 into microsoft:main Sep 3, 2024
19 checks passed
@adamjstewart adamjstewart deleted the datasets/str-pathlib branch September 3, 2024 14:36
adamjstewart added a commit that referenced this pull request Oct 10, 2024
* GeoDataset: allow a mix of str and pathlib paths

* Update type hints

* Simpler str conversion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants