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

Segment Trip Metrics #122

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Segment Trip Metrics #122

wants to merge 2 commits into from

Conversation

devinmatte
Copy link
Member

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

@devinmatte devinmatte requested review from austinjpaul, idreyn and a team as code owners March 4, 2025 02:00
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

Choose a reason for hiding this comment

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

Code Quality Violation

Suggested change
# 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.

View in Datadog  Leave us feedback  Documentation

tts.set_index("date", inplace=True)

tts = (tts["50%"]).dropna()
tts = tts.rename("travel_time")

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation


tts = (tts["50%"]).dropna()
tts = tts.rename("travel_time")
tts = tts.to_frame()

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

return tts

tts.columns = tts.columns.str.strip()
tts = tts.rename(columns={"service_date": "date"})

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

tts["date"] = pd.to_datetime(tts["date"]).dt.date
tts.set_index("date", inplace=True)

tts = (tts["50%"]).dropna()

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation



def download(key: str | pathlib.Path):
key = str(key) # in case it's a pathlib.Path

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

variable name is the same as a function parameter (...read more)

A function parameter should only be read and not be modified. If your intent is to modify the value of the parameter, return the value in the function and handle the new value in the caller of the function.

View in Datadog  Leave us feedback  Documentation

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)

Choose a reason for hiding this comment

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

🔴 Code Vulnerability

Suggested change
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.

Learn More

View in Datadog  Leave us feedback  Documentation

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