You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "dstandish (via GitHub)" <gi...@apache.org> on 2024/03/19 19:30:15 UTC
[PR] Implement set_state on TaskInstancePydantic [airflow]
dstandish opened a new pull request, #38297:
URL: https://github.com/apache/airflow/pull/38297
Small part towards AIP-44.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1530998648
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
> Should not we just pass task_id, dag_id, run_id and map_index as parameters?
ok sure
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1531020312
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
And if AIP-44 is enabled, what is sent through the wire? `TaskInstancePydantic` I guess, which is serializable. Makes sense to me
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1531000894
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
wait...
no so the reason for this is, if we already have a TI object there is no need to go fetch it from the DB.
wdyt?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1530971750
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
I dont know if it is really worth creating a variable for that
```suggestion
TI = TaskInstance
if not isinstance(ti, TaskInstance):
ti = (
session.query(TaskInstance)
```
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
If `not isinstance(ti, TaskInstance)` is `True` then what is the type of `ti`? Should not we just pass `task_id`, `dag_id`, `run_id` and `map_index` as parameters? I think the goal is that all AIP-44 related APIs have primary keys as parameter which we then use to fetch the entity (task instance, dag_run, ...)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1531035446
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
ok
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1531029060
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,35 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ def _set_state(ti: TaskInstance | TaskInstancePydantic, state, session: Session) -> bool:
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
[Query API](https://docs.sqlalchemy.org/en/20/orm/queryguide/query.html) is deprecated in SQLAlchemy, could we use [session.execute](https://docs.sqlalchemy.org/en/14/orm/session_api.html#sqlalchemy.orm.Session.execute) here ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement set_state on TaskInstancePydantic [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish commented on code in PR #38297:
URL: https://github.com/apache/airflow/pull/38297#discussion_r1530996794
##########
airflow/models/taskinstance.py:
##########
@@ -1839,6 +1839,36 @@ def key(self) -> TaskInstanceKey:
"""Returns a tuple that identifies the task instance uniquely."""
return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
+ @staticmethod
+ @internal_api_call
+ @provide_session
+ def _set_state(ti, state, session=NEW_SESSION):
+ TI = TaskInstance
+ if not isinstance(ti, TaskInstance):
+ ti = (
+ session.query(TI)
Review Comment:
TaskInstancePydantic in that case
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Implement `set_state` on `TaskInstancePydantic` [airflow]
Posted by "dstandish (via GitHub)" <gi...@apache.org>.
dstandish merged PR #38297:
URL: https://github.com/apache/airflow/pull/38297
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org