-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add exception handling for recent data scraping airflow operators #3607
base: main
Are you sure you want to change the base?
Conversation
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.
Great to have these exception handling!
I added some comments about nested exceptions. I just think it would be easier to read, but let me know what do you think.
req = requests.get(url) | ||
soup = BeautifulSoup(req.text, "html.parser") | ||
for key, url in xlsx_urls.items(): | ||
try: |
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.
Since there are others exception handling on line 44 and 55, could those line be unnested and this other "try" moved to line 60?
except Exception as e: | ||
logging.error(f"Error in XLSX operator execution: {e}") | ||
raise AirflowException(f"XLSX operator execution failed: {e}") |
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.
For the nested exceptions here, this last one is handling just lines 138 to 154? Maybe could be moved up?
except Exception as e: | ||
logging.error(f"Error in geoportal data fetch: {e}") | ||
raise AirflowException(f"Failed to fetch geoportal data: {e}") |
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.
Same here?
except Exception as e: | ||
logging.error(f"Error in geoportal operator execution: {e}") | ||
raise AirflowException(f"Geoportal operator execution failed: {e}") |
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.
Same here?
Description
We recently introduced MVP data syncs of the DOT NTD data portal and the state geodata portal. This PR goes back and introduces the appropriate exception handling to catch unwanted behavior.
Operators impacted:
Type of change
How has this been tested?
Post-merge follow-ups
ensure these operators run as expected