-
Notifications
You must be signed in to change notification settings - Fork 3
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
Segment Trip Metrics #122
base: main
Are you sure you want to change the base?
Segment Trip Metrics #122
Conversation
FullStopPair = namedtuple("FullStopPair", ["fr", "to", "fr_order", "to_order", "direction"]) | ||
|
||
|
||
# TODO: We're using SlowZones data for now, we may want our own dataset or to rename the SlowZones dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚪ Code Quality Violation
# TODO: We're using SlowZones data for now, we may want our own dataset or to rename the SlowZones dataset | |
# TODO(<owner>): We're using SlowZones data for now, we may want our own dataset or to rename the SlowZones dataset |
comments must have ownership (...read more)
When using TODO
or FIXME
, specify who write the annotation. It's a best practice to remind you who created the annotation and have potential context and information about this issue.
tts.set_index("date", inplace=True) | ||
|
||
tts = (tts["50%"]).dropna() | ||
tts = tts.rename("travel_time") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
tts = (tts["50%"]).dropna() | ||
tts = tts.rename("travel_time") | ||
tts = tts.to_frame() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return tts | ||
|
||
tts.columns = tts.columns.str.strip() | ||
tts = tts.rename(columns={"service_date": "date"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tts["date"] = pd.to_datetime(tts["date"]).dt.date | ||
tts.set_index("date", inplace=True) | ||
|
||
tts = (tts["50%"]).dropna() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def download(key: str | pathlib.Path): | ||
key = str(key) # in case it's a pathlib.Path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url = f"https://dashboard-api.labs.transitmatters.org/api/aggregate/traveltimes?from_stop={fr}&to_stop={to}&start_date={ago}&end_date={today}" | ||
if verbose: | ||
print(url) | ||
resp = requests.get(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Code Vulnerability
resp = requests.get(url) | |
resp = requests.get(url, timeout=5) |
timeout not defined (...read more)
Access to remote resources should always use a timeout and appropriately handle the timeout and recovery. When using requests.get
, requests.put
, requests.patch
, etc. - we should always use a timeout
as an argument.
In order to build up transitmatters/t-performance-dash#1045, we need a median travel time for each station pair for the map
This stores the median travel time per day per time in DynamoDB