Hannah#6
Conversation
📝 HackYourFuture auto gradeAssignment Score: 85 / 100 ✅Status: ✅ Passed Test Details |
|
Nice work on the Python pipeline, this is the hardest part of the assignment and you got it working end-to-end. What’s missing: Task 7 (Azure) was not submitted. You need output/azure_resource_groups.json and a filled-in output/azure_compare.md. Your AI_DEBUG.md documents an Azure login problem, which suggests you started Task 7 but didn’t finish the deliverables. Before merge / resubmit: Complete Task 7 (see AZURE_LOGIN.md in the repo) |
| for attempt in range(1, 4): | ||
| try: | ||
| data = fetch_with_retry(API_URL, params) | ||
| hourly = data.get("hourly", {}) | ||
| times = hourly.get("time", []) | ||
| temps = hourly.get("temperature_2m", []) | ||
| hums = hourly.get("relative_humidity_2m", []) | ||
| records = [] | ||
| for time_str, temp, hum in zip(times, temps, hums): | ||
| records.append({ | ||
| "station": "Open-Meteo Copenhagen", | ||
| "timestamp": time_str, | ||
| "temperature_c": temp, | ||
| "humidity_pct": hum, | ||
| }) | ||
| return records | ||
| except Exception as e: | ||
| logger.error(f"Failed to fetch API records: {e}") | ||
| return [] | ||
| raise RuntimeError("Exceeded maximum retry attempts") |
There was a problem hiding this comment.
fetch_with_retry() already retries with exponential backoff. Wrapping it in another for attempt in range(1, 4) loop is unnecessary.
Also, the except Exception block returns [] on the first failure, which skips retries entirely. If the API is temporarily down, you silently get zero records instead of retrying.
Suggested shape:
data = fetch_with_retry(API_URL, params)
hourly = data.get("hourly", {})
# ... flatten and return recordsOnly return [] when the API response has no hourly data, not when a network error occurs.
| try: | ||
| response = requests.get(url, params=params, timeout=timeout) | ||
| if response.status_code >= 500: | ||
| raise requests.HTTPError(f"Server error: {response.status_code}") |
There was a problem hiding this comment.
raise requests.HTTPError(f"Server error: {response.status_code}") creates an error without a .response object. Your retry check on line 31 (e.response.status_code) can crash if that path is hit.
Prefer:
response.raise_for_status() # after checking it's not 4xxor attach the response: response.raise_for_status() already handles this correctly for 5xx.
| def validate_readings(raw_records: list[dict]) -> tuple[list[WeatherReading], list[dict]]: | ||
| """Validate a list of raw records, returning valid records and errors.""" | ||
| valid = [] | ||
| errors = [] | ||
|
|
||
| for i, record in enumerate(raw_records): | ||
| try: | ||
| reading = WeatherReading(**record) | ||
| valid.append(reading) | ||
| except ValidationError as e: | ||
| errors.append({ | ||
| "index": i, | ||
| "record": record, | ||
| "errors": e.errors(), | ||
| }) | ||
|
|
||
| return valid, errors No newline at end of file |
There was a problem hiding this comment.
You implemented validation twice: here in validate_readings() and correctly in validate.py as validate_records(). You can remove this as pipeline only uses validate.py.
| # Records in database: 169 | ||
| # Error report: output/error_report.json | ||
|
|
||
| raise NotImplementedError |
There was a problem hiding this comment.
You can remove the TODO blocks after implementing
No description provided.