-
Notifications
You must be signed in to change notification settings - Fork 13
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
Scrape geoportal for shn, add SHN flag on stops table #3529
Conversation
Warehouse report 📦 Checks/potential follow-upsChecks indicate the following action items may be necessary.
New models 🌱calitp_warehouse.staging.state_geoportal.stg_state_geoportal__state_highway_network_stops DAGLegend (in order of precedence)
|
61a59c9
to
4a914c0
Compare
6278fde
to
c7384bc
Compare
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.
Ok, I know it looks like a lot of comments, but most of it pertains to the options on the geoportal operator. Overall, I really dig this work. Also note that I did not run any of the suggested changes, so 🙏 please make sure they make sense. Happy to hop on a call tomorrow to discuss.
product: str | ||
where: str | ||
outFields: str | ||
f: str |
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.
suggestion: We probably always want the format that comes from the API to be the same (e.g. GeoJSON) if this operator is going to convert it to JSON-L, so maybe we don't include an f
option.
if self.product == "state_highway_network": | ||
# Select and rename columns | ||
columns = { | ||
"properties.Route": "Route", | ||
"properties.County": "County", | ||
"properties.District": "District", | ||
"properties.RouteType": "RouteType", | ||
"properties.Direction": "Direction", | ||
"geometry.type": "type", | ||
"geometry.coordinates": "coordinates", | ||
} | ||
df = df[list(columns.keys())].rename(columns=columns) |
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.
suggestion (non-blocking): I don't think this is something that needs to be addressed right now, but it seems like we could do this without hard-coding the product
here. We're really just cleaning up column names -- removing properties.
and geometry.
prefixes that come from the GeoJSON.
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.
yes very good point, refactored
|
||
stg_state_geoportal__state_highway_network_stops AS ( | ||
SELECT * | ||
-- FROM `cal-itp-data-infra-staging.external_state_geoportal.stg_state_geoportal__state_highway_network_stops` |
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.
-- FROM `cal-itp-data-infra-staging.external_state_geoportal.stg_state_geoportal__state_highway_network_stops` |
warehouse/models/mart/gtfs_schedule_latest/dim_stops_latest.sql
Outdated
Show resolved
Hide resolved
fd5e5d4
to
4365a6c
Compare
IF(stops_on_shn.stop_id IS NOT NULL, TRUE, FALSE) AS exists_in_dim_stops_latest | ||
FROM | ||
dim_stops_latest | ||
LEFT JOIN | ||
stops_on_shn | ||
ON | ||
dim_stops_latest.stop_id = stops_on_shn.stop_id |
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.
Is joining on stop_id
going to potentially cause some conflicts here? There may be two feeds that have the same stop_id that this could match on. Would a join on dim_stops_latest._gtfs_key
be more appropriate?
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.
Hey @evansiroky – you're completely right. I must have left this in here after some comparative testing, apologies! I just made the swap and am re-requesting your review
4365a6c
to
4e6ecbb
Compare
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.
Ok, just two more small notes from me, but otherwise I'm ready to approve! Lemme know if you have any questions.
where: "1=1" # You can change this to filter data | ||
outFields: "*" # Specify the fields to return | ||
f: "geojson" # Format of the response |
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.
suggestion: These are no longer necessary with the new defaults, right? Should probably remove them (but verify that it still works with them removed).
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.
removed and still ran successfully!
params["resultOffset"] = offset | ||
|
||
# Make the request | ||
response = requests.get(validated_url, params=params) |
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.
question: What should happen if we get a non-200 response from the server? I would think we should raise an exception so that the task fails and has to retry. Does that seem right? You could add .raise_for_status()
at the end of the line if so. See https://3.python-requests.org/user/quickstart/#response-status-codes
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.
added! great suggestion
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.
Approved pending your discussion with @mjumbewu.
f0247fe
to
ffc8e3a
Compare
Co-authored-by: Mjumbe Poe <[email protected]>
ffc8e3a
to
0ca4a89
Compare
CALITP_BUCKET__STATE_GEOPORTAL_DATA_PRODUCTS variable added to composer environment |
Description
As requested in #3397, this PR creates:
dim_stops_latest
table and a new flag column on the table to indicate whether it exists on the state highway networkResolves #3397
Type of change
How has this been tested?
locally using airflow/dbt
Post-merge follow-ups
GCS bucket needs to be added to Composer variables, new airflow operator needs to be turned on