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

Exit with better error if no files found #43

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Jan 17, 2024

I accidentally ran this and forgot the * to match all filenames beginning with 2023, activities/2023 instead of activities/2023*, and got an ugly error:

❯ stravavis --activities_path . "activities/2023"
Processing data...
Processing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.12/bin/stravavis", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/hugo/github/strava_py/src/stravavis/cli.py", line 111, in main
    df = process_data(args.path)
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hugo/github/strava_py/src/stravavis/process_data.py", line 117, in process_data
    df = pd.concat(processed)
         ^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/core/reshape/concat.py", line 380, in concat
    op = _Concatenator(
         ^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/core/reshape/concat.py", line 443, in __init__
    objs, keys = self._clean_keys_and_objs(objs, keys)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pandas/core/reshape/concat.py", line 505, in _clean_keys_and_objs
    raise ValueError("No objects to concatenate")
ValueError: No objects to concatenate

Let's handle that in a better way:

stravavis --activities_path . "activities/2023"
No files found matching activities/2023

@hugovk hugovk merged commit 3f05e06 into marcusvolz:main Feb 9, 2024
19 checks passed
@hugovk hugovk deleted the exit-zero-filenames branch February 9, 2024 16:41
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.

1 participant