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

629 organize the daily wys dag #1037

Merged
merged 23 commits into from
Aug 26, 2024
Merged

Conversation

gabrielwol
Copy link
Collaborator

@gabrielwol gabrielwol commented Aug 9, 2024

What this pull request accomplishes:

Issue(s) this solves:

What, in particular, needs to reviewed:

  • wys_api.py: the changes are pretty significant so may want to review without looking at diff.

What needs to be done by a sysadmin after this PR is merged

  • Update data_script links

@gabrielwol gabrielwol added enhancement WYS Watch Your Speed Sign Airflow labels Aug 9, 2024
@gabrielwol gabrielwol self-assigned this Aug 9, 2024
@gabrielwol gabrielwol linked an issue Aug 9, 2024 that may be closed by this pull request
@gabrielwol gabrielwol linked an issue Aug 20, 2024 that may be closed by this pull request
Copy link
Collaborator

@chmnata chmnata left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks for speeding this chonk task up. Only have one minor comment on sql.literal.


## `api_main` Process

The main function in the puller script `api_main` performs the following steps:

1. Parse the `config.cfg` file (for API key and database credentials) and any input parameters.
2. Retrieve the list of all signs from the `signs` endpoint by calling `location_id()` function, if `location_flag` is `0`. Insert/update into `wys.locations` using `wys.daily_intersections` as a staging table to identify new and updated signs.
1. Retrive API key and database credentials from Airflow variables (must be run in `airflow_venv`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

retrieve typo and a missing )

DELETE FROM wys.raw_data
WHERE datetime_bin >= {}::timestamp AND datetime_bin < {}::timestamp + interval '1 day';
""")
delete_sql = delete_sql.format(sql.Literal(str(start_date)), sql.Literal(str(start_date)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should try not to use sql.Literal as much as we can and use %s as the placeholder instead.

Copy link
Collaborator

@chmnata chmnata left a comment

Choose a reason for hiding this comment

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

:gabe-approved:

@gabrielwol gabrielwol merged commit 5b250c6 into master Aug 26, 2024
5 of 6 checks passed
@gabrielwol gabrielwol deleted the 629-organize-the-daily-wys-dag branch August 26, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Airflow enhancement WYS Watch Your Speed Sign
Projects
None yet
2 participants