-
Notifications
You must be signed in to change notification settings - Fork 34
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
[Draft] Changes needed to add TTC #577
base: master
Are you sure you want to change the base?
Changes from all commits
a3c65ef
05b9410
db6509e
3d5101c
81a7385
da8ab11
c7b7ab8
a1ada04
bb398b2
9d7a9d3
a0f1f7a
eab45e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,7 +287,12 @@ def get_state_raw(agency_id, start_time, end_time, route_ids): | |
print(params) | ||
|
||
query_url = f"{trynapi_url}/graphql?query={query}" | ||
r = requests.get(query_url) | ||
try: | ||
r = requests.get(query_url) | ||
except Exception as exc: | ||
print(exc) | ||
print('Ensure tryn-api is running and that you set the TRYNAPI_URL environment variable') | ||
exit(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Library functions like this should raise exceptions when errors occur, so that the caller can handle them as needed. Calls to exit() should be in the top-level scripts like compute_new.py . If the top-level script only should exit in certain cases, you could raise a particular class of exception here and catch that type in the top-level script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, normally it shouldn't be necessary to set TRYNAPI_URL, since docker-compose.yml sets TRYNAPI_URL to http://tryn-api.opentransit.city . This also applies when running scripts from the command line via docker-shell.sh or docker-shell.bat. |
||
|
||
print(f" response length = {len(r.text)}") | ||
|
||
|
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.
I don't think this should raise an exception -- if the offset is ever greater than the threshold, it's not clear what to do to fix it, other than by continuing to increase the threshold until the exception stops being raised. At that point, what is the purpose of having this check at all?
I think it would be better to keep the original behavior and then fix the exception that is being thrown by GraphQL API when stop geometry is not available.