-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Migrate public endpoint Set Task Instances State to FastAPI #44246
base: main
Are you sure you want to change the base?
Conversation
tags=["Task Instance"], prefix="/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances" | ||
) | ||
task_instances_router = AirflowRouter(tags=["Task Instance"], prefix="/dags/{dag_id}") | ||
task_instances_prefix = "/dagRuns/{dag_run_id}/taskInstances" |
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.
should we make task_instances_prefix
all capitals to indicate constant?
"task_instances": [ | ||
{ | ||
"dag_id": "example_python_operator", | ||
"dag_run_id": "TEST_DAG_RUN_ID", |
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.
"dag_run_id": "TEST_DAG_RUN_ID", | |
"dag_run_id": run_id, |
@mock.patch("airflow.models.dag.DAG.set_task_instance_state") | ||
def test_should_assert_call_mocked_api(self, mock_set_task_instance_state, test_client, session): | ||
self.create_task_instances(session) | ||
run_id = "TEST_DAG_RUN_ID" |
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.
run_id = "TEST_DAG_RUN_ID" | |
run_id = "TEST_DAG_RUN_ID" | |
task_id = "print_the_context" |
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.
also,we denote them in capital letters to indicate that they are constants.
session.query(TaskInstance) | ||
.join(TaskInstance.dag_run) | ||
.options(contains_eager(TaskInstance.dag_run)) | ||
.filter(TaskInstance.task_id == "print_the_context") |
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.
.filter(TaskInstance.task_id == "print_the_context") | |
.filter(TaskInstance.task_id == task_id) |
"/public/dags/example_python_operator/updateTaskInstancesState", | ||
json={ | ||
"dry_run": True, | ||
"task_id": "print_the_context", |
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.
"task_id": "print_the_context", | |
"task_id": task_id", |
"dag_id": "example_python_operator", | ||
"dag_run_id": "TEST_DAG_RUN_ID", | ||
"logical_date": "2020-01-01T00:00:00Z", | ||
"task_id": "print_the_context", |
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.
"task_id": "print_the_context", | |
"task_id": task_id, |
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'm not sure we need that anymore. Isn't it already handled by the more generic PATCH
task instance now ?
"/updateTaskInstancesState", | ||
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND, status.HTTP_400_BAD_REQUEST]), | ||
) | ||
def set_task_instances_state( |
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 consistency, I think it should be transformed as for dag_run into patch_dag_run
.
A PATCH that can take only a state for now, but it will be easier to extend. It should also allow PATCHING the note.
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.
Just noticed you already have a PR opened for that.
include_downstream: bool | ||
include_future: bool | ||
include_past: bool | ||
new_state: str |
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.
It would be great to include editing the Task Instance note at the same time like we do for changing a dag run.
task_id: str | ||
dag_run_id: str = Field(validation_alias="run_id") | ||
dag_id: str | ||
logical_date: datetime |
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.
logical_date is no longer unique. Is it still necessary for serializing? @dstandish
include_upstream: bool | ||
include_downstream: bool | ||
include_future: bool | ||
include_past: bool |
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.
We can make all of these False
by default
I think we should only merge one of this and #44223 and include setting a note and all the |
closes: #43752
related: #42370
This migrates the Set Task Instances State API from
api_connexion
toapi_fastapi
.