Skip to content

Commit

Permalink
Merge pull request #1 from hugovk/cli
Browse files Browse the repository at this point in the history
Add CLI as strava_py
  • Loading branch information
marcusvolz authored Feb 5, 2022
2 parents f491f20 + 63ef645 commit 1de8b22
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The process for downloading data is described on the Strava website here: [https

### Process the data

The main function for importing and processing activity files expects a path to a directory of unzipped GPX and / or FIT files. If required, the [fit2gpx](https://github.com/dodo-saba/fit2gpx) package provides useful tools for pre-processing bulk files exported from Stava, e.g. unzipping activity files (see Use Case 3: Strava Bulk Export Tools).
The main function for importing and processing activity files expects a path to a directory of unzipped GPX and / or FIT files. If required, the [fit2gpx](https://github.com/dodo-saba/fit2gpx) package provides useful tools for pre-processing bulk files exported from Strava, e.g. unzipping activity files (see Use Case 3: Strava Bulk Export Tools).

```python
df = process_data(<path to folder with GPX and / or FIT files>)
Expand Down
50 changes: 50 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[metadata]
name = strava_py
version = 0.0.1
description = Create artistic visualisations with your exercise data
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/marcusvolz/strava_py
author = Marcus Volz
license = MIT
license_file = LICENSE
classifiers =
Development Status :: 3 - Alpha
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Artistic Software
Topic :: Multimedia :: Graphics
Topic :: Scientific/Engineering :: Visualization
keywords =
strava
artistic visualisations
artistic
visualisation
exercise data
exercise
project_urls =
Source=https://github.com/marcusvolz/strava_py

[options]
packages = find:
install_requires =
fit2gpx
gpxpy
matplotlib
pandas
seaborn
python_requires = >=3.7
package_dir = =src
zip_safe = True

[options.packages.find]
where = src

[options.entry_points]
console_scripts =
strava_py = strava_py.cli:main
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
Empty file added src/strava_py/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions src/strava_py/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from strava_py import cli

if __name__ == "__main__":
cli.main()
28 changes: 28 additions & 0 deletions src/strava_py/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import argparse


def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument("path", help="Input path to folder with GPX and / or FIT files")
parser.add_argument(
"-o", "--output_file", default="plot.png", help="Output PNG file"
)
args = parser.parse_args()

# Normally imports go at the top, but scientific libraries can be slow to import
# so let's validate arguments first
from strava_py.plot_facets import plot_facets
from strava_py.process_data import process_data

print("Processing data...")
df = process_data(args.path)

print("Plotting facets...")
plot_facets(df, output_file=args.output_file)
print(f"Saved to {args.output_file}")


if __name__ == "__main__":
main()
File renamed without changes.
File renamed without changes.

0 comments on commit 1de8b22

Please sign in to comment.