bugraoz93 commented on code in PR #66261:
URL: https://github.com/apache/airflow/pull/66261#discussion_r3351028213
##########
airflow-core/src/airflow/api/client/local_client.py:
##########
@@ -43,7 +75,37 @@ def trigger_dag(
logical_date=None,
triggering_user_name=None,
replace_microseconds=True,
+ api_client=None,
) -> dict | None:
+ if api_client is not None:
+ parsed_conf = conf
+ if isinstance(conf, str):
+ try:
+ parsed_conf = json.loads(conf)
+ except json.JSONDecodeError as err:
+ raise AirflowBadRequest(f"Invalid configuration JSON:
{err}") from err
+ dag_run = api_client.dags.trigger(
+ dag_id,
+ TriggerDAGRunPostBody(
+ dag_run_id=run_id,
+ conf=parsed_conf,
+ logical_date=logical_date,
+ ),
+ )
+ return {
Review Comment:
We should use again pydantic model validate here
##########
airflow-core/src/airflow/api/client/local_client.py:
##########
@@ -34,7 +42,31 @@ def __init__(self, auth=None, session: httpx.Client | None =
None):
self._session: httpx.Client = session or httpx.Client()
if auth:
self._session.auth = auth
+ self.api_token = self._create_api_token()
Review Comment:
We shpuld get rid of this class. We can have a single variable using token
we should create singleton AirflowCtlClient and all of them use it. The
decorator is for auth flow
##########
airflow-core/src/airflow/api/client/local_client.py:
##########
@@ -70,20 +132,56 @@ def trigger_dag(
}
return dag_run
- def delete_dag(self, dag_id):
+ @provide_api_client(kind=AirflowCtlClientKind.CLI)
Review Comment:
If this work we can get rid of all the code and convert usage methods to
airflowctl ideally with client. Please double validate this as we should create
singleton client and use it accross CLI, this is generator reading from
--
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]