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

Calendar #10

Merged
merged 6 commits into from
Feb 10, 2022
Merged

Calendar #10

merged 6 commits into from
Feb 10, 2022

Conversation

marcusvolz
Copy link
Owner

Added a calendar heatmap using the calmap package. Will look at tweaking the aesthetics (e.g. color) later.

@marcusvolz marcusvolz requested a review from hugovk February 9, 2022 12:50
@marcusvolz
Copy link
Owner Author

Checks have failed - will look into it later.

@hugovk
Copy link
Collaborator

hugovk commented Feb 9, 2022

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\Scripts\stravavis.exe\__main__.py", line 7, in <module>
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\site-packages\stravavis\cli.py", line 37, in main
    from stravavis.plot_calendar import plot_calendar
  File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\site-packages\stravavis\plot_calendar.py", line 1, in <module>
    import calmap
ModuleNotFoundError: No module named 'calmap'
Error: Process completed with exit code 1.

Add calmap to setup.cfg so it also gets installed:

install_requires =
    calmap
    fit2gpx
    gpxpy
    matplotlib
    pandas
    rich
    seaborn

Copy link
Collaborator

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Something else, --activities_path is an optional parameter with no default so this would fail:

$ stravavis tests/gpx
Processing data...
Processing ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processing activities...
Traceback (most recent call last):
...
ValueError: Invalid file path or buffer object type: <class 'NoneType'>

Some options:

  1. make it a required, positional argument, like "path". But maybe people want to run on GPX only and have no activities.csv.

  2. Add a default or calculate one. Current directory? Same as args.path? Hard to know.

  3. My preference: if the argument is given, skip the relevant bits. For example:

diff --git a/src/stravavis/cli.py b/src/stravavis/cli.py
index c84dc2c..f7fd3f0 100644
--- a/src/stravavis/cli.py
+++ b/src/stravavis/cli.py
@@ -45,8 +45,10 @@ def main():
     print("Processing data...")
     df = process_data(args.path)
 
-    print("Processing activities...")
-    activities = process_activities(activities_path)
+    activities = None
+    if args.activities_path:
+        print("Processing activities...")
+        activities = process_activities(args.activities_path)
 
     print("Plotting facets...")
     outfile = f"{args.output_prefix}-facets.png"
@@ -68,10 +70,11 @@ def main():
     plot_landscape(df, output_file=outfile)
     print(f"Saved to {outfile}")
 
-    print("Plotting calendar...")
-    outfile = f"{args.output_prefix}-calendar.png"
-    plot_calendar(activities, output_file=outfile)
-    print(f"Saved to {outfile}")
+    if activities:
+        print("Plotting calendar...")
+        outfile = f"{args.output_prefix}-calendar.png"
+        plot_calendar(activities, output_file=outfile)
+        print(f"Saved to {outfile}")
 
 
 if __name__ == "__main__":

@marcusvolz marcusvolz merged commit 997e352 into main Feb 10, 2022
@marcusvolz marcusvolz deleted the calendar branch February 10, 2022 06:37
@marcusvolz
Copy link
Owner Author

Many thanks Hugo, if I missed anything let me know!

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