-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enhance HexRunProjectOperator and HexHook #21
base: main
Are you sure you want to change the base?
Enhance HexRunProjectOperator and HexHook #21
Conversation
fc65f1e
to
7e2a80b
Compare
- Remove deprecated "apply_default" decorator from HexRunProjectOperator - Implement retry mechanism for API polling in HexHook - Decouple polling logic from run_and_poll method - Add max_poll_retries and poll_retry_delay parameters - Update flake8 pre-commit hook to use GitHub repository - Update pre-commit hooks to latest versions
7e2a80b
to
853e83b
Compare
if project_status not in VALID_STATUSES: | ||
raise AirflowException(f"Unhandled status: {project_status}") |
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.
I don't think we want to remove this exception
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.
I will add this back
json=mock_run, | ||
json={"projectId": "abc-123", "runId": "1"}, |
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.
Use defined mock_run
object
endpoint = f"api/v1/project/{project_id}/run/{run_id}" | ||
method = "DELETE" | ||
|
||
self.run(method=method, endpoint=endpoint) | ||
return run_id | ||
|
||
def run_and_poll( | ||
def run_status_with_retries( | ||
self, project_id: str, run_id: str, max_retries: int = 3, retry_delay: int = 1 |
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.
A retry limit should be enforced server-side to prevent the caller from specifying an excessive number of retries for project runs, which could lead to resource exhaustion or unintended behavior.
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.
Is implementing a server-side retry limit currently prioritized? As this PR focuses on client-side Airflow hooks, I can hardcode a conservative number of retries and delay to prevent configurability. This would address immediate concerns while keeping the implementation on the client side. Let me know if you'd like me to proceed with this approach.
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.
Sorry for the delay here! (Also this is a product-manager translation from an engineer, so apologies if I lose something in translation!)
We rate limit requests, so at this time don't intend to implement a server-side retry limit. Also, our API is fairly non-flakey, so we don't think users will need to retry that often.
That being said, it would still be great to hardcode a conservative number of retries juuuust in case — 3
seems like a good spot!
Enhance HexRunProjectOperator and HexHook
This PR addresses issues #19 and #20, significantly improving the functionality and reliability of the HexRunProjectOperator and HexHook. Most importantly, it mitigates the issue where jobs were incorrectly marked as failed due to Hex API failures, not actual job failures.
Key Improvements
apply_default
decorator from HexRunProjectOperator (Fixes Remove deprecated apply_default decorator from HexOperator #19)make init
commandDetailed Changes
1. Prevent false job failures
2. Remove deprecated
apply_default
decorator@apply_default
decorator from the HexRunProjectOperator class3. Implement retry mechanism for API polling
max_poll_retries
andpoll_retry_delay
control retry behavior4. Decouple polling logic
5. New parameters
max_poll_retries
: Maximum number of retries for a failed poll (default: 3)poll_retry_delay
: Delay between retries in seconds (default: 5)6. Update pre-commit hooks
https://github.com/pycqa/flake8
instead of the GitLab repositoryTesting
Checklist
This update significantly improves the reliability of the Hex Airflow provider by ensuring that jobs are not incorrectly marked as failed due to API communication issues. Users will now have a more accurate representation of their job statuses, reducing false alarms and improving overall system dependability.