jscheffl commented on code in PR #63498:
URL: https://github.com/apache/airflow/pull/63498#discussion_r3144899198
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
@@ -102,44 +103,73 @@ def queue_workload(
session: Session = NEW_SESSION,
) -> None:
"""Put new workload to queue. Airflow 3 entry point to execute a
task."""
- if not isinstance(workload, workloads.ExecuteTask):
- raise TypeError(f"Don't know how to queue workload of type
{type(workload).__name__}")
+ if is_callback_execute(workload):
+ from airflow.providers.edge3.utils.types import
EXECUTE_CALLBACK_TAG
+
+ existing_job = session.scalars(
+ select(EdgeJobModel).where(
+ EdgeJobModel.dag_id == EXECUTE_CALLBACK_TAG,
+ EdgeJobModel.task_id == workload.callback.key,
+ EdgeJobModel.run_id ==
f"{EXECUTE_CALLBACK_TAG}-{workload.callback.key}",
+ )
+ ).first()
+
+ if existing_job:
+ existing_job.state = TaskInstanceState.QUEUED
+ existing_job.command = workload.model_dump_json()
+ else:
+ session.add(
+ EdgeJobModel(
+ dag_id=EXECUTE_CALLBACK_TAG,
+ task_id=workload.callback.key,
+
run_id=f"{EXECUTE_CALLBACK_TAG}-{workload.callback.key}",
+ map_index=-1,
+ try_number=0,
+ queue=self.conf.get_mandatory_value("operators",
"default_queue"),
+ concurrency_slots=1,
+ state=TaskInstanceState.QUEUED,
+ command=workload.model_dump_json(),
+ )
+ )
- task_instance = workload.ti
- key = task_instance.key
-
- # Check if job already exists with same dag_id, task_id, run_id,
map_index, try_number
- existing_job = session.scalars(
- select(EdgeJobModel).where(
- EdgeJobModel.dag_id == key.dag_id,
- EdgeJobModel.task_id == key.task_id,
- EdgeJobModel.run_id == key.run_id,
- EdgeJobModel.map_index == key.map_index,
- EdgeJobModel.try_number == key.try_number,
- )
- ).first()
-
- if existing_job:
- existing_job.state = TaskInstanceState.QUEUED
- existing_job.queue = task_instance.queue
- existing_job.concurrency_slots = task_instance.pool_slots
- existing_job.command = workload.model_dump_json()
- existing_job.team_name = self.team_name
- else:
- session.add(
- EdgeJobModel(
- dag_id=key.dag_id,
- task_id=key.task_id,
- run_id=key.run_id,
- map_index=key.map_index,
- try_number=key.try_number,
- state=TaskInstanceState.QUEUED,
- queue=task_instance.queue,
- concurrency_slots=task_instance.pool_slots,
- command=workload.model_dump_json(),
- team_name=self.team_name,
+ elif isinstance(workload, workloads.ExecuteTask):
+ # TODO: to be updated
Review Comment:
Is this still WIP if there is `TODO`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]