Skip to content

remove#2105

Open
shvngisingh wants to merge 1 commit into
datacommonsorg:masterfrom
shvngisingh:fao_goldens
Open

remove#2105
shvngisingh wants to merge 1 commit into
datacommonsorg:masterfrom
shvngisingh:fao_goldens

Conversation

@shvngisingh

Copy link
Copy Markdown
Contributor

Adding golden files for fao_currency_statvar

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the US HUD income script to support processing data up to the current year and introduces validation configurations along with golden datasets for both the US HUD income and FAO currency statvar imports. A review comment points out that using requests.get with stream=True to check the availability of the current year's HUD data can cause connection leaks and is inefficient, suggesting the use of requests.head instead.

Comment thread scripts/us_hud/income/process.py Outdated
Comment on lines +153 to +165
if year == today.year:
try:
headers = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
resp = requests.get(url, headers=headers, timeout=10, stream=True)
if resp.status_code != 200:
logging.warning(f"HUD income limits for {year} are not yet available. Skipping.")
continue
except Exception as e:
logging.warning(f"Could not check availability for {year}: {e}. Skipping.")
continue

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using requests.get with stream=True without closing the response or reading its content causes a connection leak because the connection is not released back to the pool. Additionally, downloading the entire response body just to check the status code is inefficient. Using a HEAD request via requests.head is much more efficient and avoids connection leaks as it only retrieves the headers.

Suggested change
if year == today.year:
try:
headers = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
resp = requests.get(url, headers=headers, timeout=10, stream=True)
if resp.status_code != 200:
logging.warning(f"HUD income limits for {year} are not yet available. Skipping.")
continue
except Exception as e:
logging.warning(f"Could not check availability for {year}: {e}. Skipping.")
continue
if year == today.year:
try:
headers = {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
resp = requests.head(url, headers=headers, timeout=10)
if resp.status_code != 200:
logging.warning(f'HUD income limits for {year} are not yet available. Skipping.')
continue
except Exception as e:
logging.warning(f'Could not check availability for {year}: {e}. Skipping.')
continue

@shvngisingh shvngisingh changed the title Fao goldens Added remove Jul 21, 2026
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