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

Fix bug if string is source in fetch_dataset_filepaths #247

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

albrja
Copy link
Contributor

@albrja albrja commented Aug 10, 2023

Bugfix/mic-4364

Fixes bug in fetch_dataset_filepaths

-handles conversion of strings to path objects

Testing

I am able to run generate_XXX providing a string for the source argument.

@@ -469,7 +469,9 @@ def validate_data_path_suffix(data_paths) -> None:
return None


def get_dataset_filepaths(source: Path, dataset_name: str) -> List[Path]:
def get_dataset_filepaths(source: Union[Path, str], dataset_name: str) -> List[Path]:
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't actually need to do if type(source) == str. You can just Path(source) and even if it's already a Path it'll work.

Also, I think this is the wrong place to do this. If you follow the trail up (and the type hints), I think you should convert to Path at the start of _generate_dataset at the top of this script. In that way from there on out it's always a Path object and the type hints are all correct (including in the fetch_filepaths function which is where this get_dataset_filepaths function gets called)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating which one of these was the better way to do it.

@@ -46,6 +46,8 @@ def _generate_dataset(

if source is None:
source = paths.SAMPLE_DATA_ROOT
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't even technically need the else: but this is fine

@albrja albrja merged commit ae5fbef into develop Aug 10, 2023
@albrja albrja deleted the bugfix/file-path-source branch August 10, 2023 20:55
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