Conversation
Title20250312 2 Description
Changes walkthrough 📝
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
The defaults allow blocking for up to 6 hours (60s * 360) inside a synchronous download method, which can be problematic for CLI/CI usage and services (long-running requests, worker timeouts). Consider using a single timeout_seconds parameter (derived internally), lowering the defaults, and/or documenting prominently that this call may block for a long time by default.
There was a problem hiding this comment.
After waiting, the second get_annotation_archive(project_id) call is not protected by the same 409/WORKER_ALREADY_INVOKED handling. If the worker is still running (or a new run starts), this will raise HTTPError and bypass the intended wait/retry behavior. Consider wrapping the retry in the same handling (or using a small bounded loop that retries on 409/WORKER_ALREADY_INVOKED until the polling budget is exhausted).
| max_retry_on_conflict = 2 | |
| retry_count = 0 | |
| while True: | |
| try: | |
| _, response = self.api.get_annotation_archive(project_id) | |
| break | |
| except requests.exceptions.HTTPError as e: | |
| if e.response is not None and e.response.status_code == requests.codes.conflict: | |
| try: | |
| error_codes = [err["error_code"] for err in e.response.json()["errors"]] | |
| except (ValueError, KeyError, TypeError): | |
| error_codes = [] | |
| if "WORKER_ALREADY_INVOKED" in error_codes and retry_count < max_retry_on_conflict: | |
| logger.info( | |
| "project_id='%s' :: アノテーションZIPの更新中のため、更新ジョブ(gen-annotation)が完了するまで待ちます。", | |
| project_id, | |
| ) | |
| self.wait_until_job_finished( | |
| project_id, | |
| ProjectJobType.GEN_ANNOTATION, | |
| job_access_interval=job_access_interval, | |
| max_job_access=max_job_access, | |
| ) | |
| retry_count += 1 | |
| continue |
There was a problem hiding this comment.
Accessing response.headers[\"Location\"] will raise a raw KeyError if the header is missing, which is hard to diagnose. Consider using an explicit check (e.g., get) and raising a clearer exception that includes project_id, status code, and available headers (or a short subset) to aid debugging.
No description provided.