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

upgrade database libraries #62

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
# Local config files
.env*
*.cfg

.env*
/data/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.py[cod]
__pycache__/

# C extensions
*.so

# Distribution / packaging
*.egg
*.egg-info/
.Python
env/
.eggs/
.installed.cfg
.venv/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
venv/
wheels/
*.egg-info/
.installed.cfg
*.egg

5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BUILD
# =====

FROM ubuntu:22.04 as buildstep

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
LABEL maintainer="Richard Bullington-McGuire <richard@obscure.org>"

RUN apt-get update \
Expand All @@ -21,7 +21,7 @@
# DEPLOY
# =====

FROM ubuntu:22.04 as deploystep

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
LABEL maintainer="Richard Bullington-McGuire <richard@obscure.org>"

RUN apt-get update \
Expand All @@ -41,4 +41,9 @@

RUN pip3 install /tmp/wheels/*

RUN mkdir /app
ADD alembic.ini /app

WORKDIR /app

CMD freezing-sync

Check warning on line 49 in Dockerfile

View workflow job for this annotation

GitHub Actions / build / docker

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
56 changes: 56 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = freezing.model:migrations

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# max length of characters to apply to the
# "slug" field
#truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# This is read from Flask config instead,
# or set the SQLALCHEMY_URL environment variable
# sqlalchemy.url = driver://user:pass@localhost/dbname


# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
61 changes: 30 additions & 31 deletions example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,48 @@

DEBUG=true

# The URL to the database. Note that the pymysql driver must be explicitly specified.
SQLALCHEMY_URL=mysql+pymysql://freezing:freezing@127.0.0.1/freezing?charset=utf8mb4&binary_prefix=true

# Configuration for the Strava client. These settings come from your App setup.
STRAVA_CLIENT_ID=?
STRAVA_CLIENT_SECRET=?
STRAVA_ACTIVITY_CACHE_DIR=/path/to/cache/activities
BEANSTALKD_HOST=127.0.0.1
BEANSTALKD_PORT=11300

# Visit https://www.visualcrossing.com/ for your own
VISUAL_CROSSING_API_KEY=?
VISUAL_CROSSING_CACHE_DIR=/path/to/cache/visualcrossing
DATADOG_API_KEY=?
DATADOG_APP_KEY=?
DATADOG_HOST=127.0.0.1
DATADOG_PORT=8125

# Comma-separated list of Strava Clubs that are the participating teams.
TEAMS=1234,1235
ENVIRONMENT=localdev

# Comma-separated list of teams that should be included for overall stats but are not "playing the game"
OBSERVER_TEAMS=324147
# Any keywords to match on to exclude rides (default: "#NoBAFS"). Note: these are not case-sensitive.
EXCLUDE_KEYWORDS='#NoBAFS'

# The main team id. If people join this before they join the competition teams, they will get on the leaderboards.
MAIN_TEAM=324147
MAIN_TEAM=1
# Comma-separated list of teams that should be included for overall stats but are not "playing the game"
OBSERVER_TEAMS=2
# Comma-separated list of Strava Clubs that are the participating teams.
TEAMS=3,4

# The competition title
COMPETITION_TITLE=BikeArlington Freezing Saddles 2019
# The URL to the database. Note that the pymysql driver must be explicitly specified.
SQLALCHEMY_URL='mysql+pymysql://freezing:please-change-me-as-this-is-a-default@127.0.0.1/freezing?charset=utf8mb4&binary_prefix=true'

# The start date of the competition -- WITH TIME ZONE
START_DATE=2020-01-01T00:00:00-05:00

START_DATE=2025-01-01T00:00:00-05:00
# The end date of the competition -- WITH TIME ZONE.
# The sync will stop fetching rides after this date (plus grace period)
END_DATE=2020-03-19T23:59:59-04:00

# The hostname for a beanstalkd server.
BEANSTALKD_HOST=localhost

# The port for beanstalkd server (default 11300)
BEANSTALKD_PORT=11300
END_DATE=2025-03-19T23:59:59-04:00

# How long (days) can people upload rides after competition>
UPLOAD_GRACE_PERIOD=
STRAVA_ACTIVITY_CACHE_DIR=data/cache/activities

# Any keywords to match on to exclude rides (default: "#NoBAFS"). Note: these are not case-sensitive.
EXCLUDE_KEYWORDS=#NoBAFS
# Configuration for the Strava client. These settings come from your App setup.
STRAVA_CLIENT_ID=STRAVA_CLIENT_ID
STRAVA_CLIENT_SECRET=STRAVA_CLIENT_SECRET

# Python Time zone for competition days.
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIMEZONE=America/New_York
TIMEZONE=TIMEZONE:-America/New_York

# How long (days) can people upload rides after competition?
UPLOAD_GRACE_PERIOD=7

# Visit https://www.visualcrossing.com/ for your own API key
VISUAL_CROSSING_API_KEY=?
VISUAL_CROSSING_CACHE_DIR=data/cache/weather
6 changes: 3 additions & 3 deletions freezing/sync/data/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import arrow
from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideEffort, RideError, RideGeo, RidePhoto
from geoalchemy import WKTSpatialElement
from geoalchemy2.elements import WKTElement
from sqlalchemy import and_, func
from sqlalchemy.orm import joinedload
from stravalib import unithelper
Expand Down Expand Up @@ -571,7 +571,7 @@ def write_ride(self, activity: Activity) -> Ride:
"""
session = meta.scoped_session()
if activity.start_latlng:
start_geo = WKTSpatialElement(
start_geo = WKTElement(
"POINT({lon} {lat})".format(
lat=activity.start_latlng.lat, lon=activity.start_latlng.lon
)
Expand All @@ -580,7 +580,7 @@ def write_ride(self, activity: Activity) -> Ride:
start_geo = None

if activity.end_latlng:
end_geo = WKTSpatialElement(
end_geo = WKTElement(
"POINT({lon} {lat})".format(
lat=activity.end_latlng.lat, lon=activity.end_latlng.lon
)
Expand Down
2 changes: 1 addition & 1 deletion freezing/sync/data/athlete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RidePhoto,
Team,
)
from geoalchemy import WKTSpatialElement
from geoalchemy2.elements import WKTElement
from sqlalchemy import and_
from sqlalchemy.orm import joinedload
from stravalib import model as sm
Expand Down
4 changes: 2 additions & 2 deletions freezing/sync/data/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from freezing.model import meta
from freezing.model.orm import Athlete, Ride, RideTrack
from geoalchemy import WKTSpatialElement
from geoalchemy2.elements import WKTElement
from polyline.codec import PolylineCodec
from sqlalchemy import and_, or_, update
from sqlalchemy.orm import joinedload
Expand Down Expand Up @@ -151,7 +151,7 @@ def write_ride_streams(self, streams: List[Stream], ride: Ride):
RideTrack.__table__.delete().where(RideTrack.ride_id == ride.id)
)

gps_track = WKTSpatialElement(wktutils.linestring_wkt(lonlat_points))
gps_track = WKTElement(wktutils.linestring_wkt(lonlat_points))

ride_track = RideTrack()
ride_track.gps_track = gps_track
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
APScheduler==3.10.4
GeoAlchemy @ https://github.com/hozn/GeoAlchemy/archive/0.7.3dev1.tar.gz
GeoAlchemy2==0.16.0
PyMySQL==1.1.1
colorlog==4.1.0
datadog==0.33.0
envparse==0.2.0
freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.8.6.tar.gz
freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.4.tar.gz
greenstalk==1.0.1
polyline==1.4.0
pytz==2024.2
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# -*- coding: utf-8 -*-
import os.path

from setuptools import setup

version = "1.4.7"
version = "1.5.2"

long_description = """
freezing-sync is the component responsible for fetching activities, weather data, etc.
"""

install_requires = [
"APScheduler",
"GeoAlchemy",
"GeoAlchemy2",
"PyMySQL",
"SQLAlchemy",
"colorlog",
"datadog",
"envparse",
Expand Down
Loading