guan404ming commented on code in PR #76627:
URL: https://github.com/apache/airflow/pull/76627#discussion_r4617223851
##########
ts-sdk/src/generated/dag-schema-fields.ts:
##########
@@ -212,4 +212,4 @@ export const TASK_SCHEMA_FIELDS = {
/** The `__version` the serializer stamps into a serialized Dag. The schema
* constrains it only to a positive integer, so it is pinned here and guarded
* by a test in airflow-core. */
-export const SERIALIZATION_VERSION = 3;
+export const SERIALIZATION_VERSION = 4;
Review Comment:
`tests/scripts/generate-dag-schema.test.ts` still expects
`SERIALIZATION_VERSION` to be 3, so that TS test fails here
##########
ts-sdk/scripts/generate-dag-schema.mjs:
##########
@@ -83,7 +83,7 @@ const OUT_PATH = join(ROOT,
"src/generated/dag-schema-fields.ts");
* and
`airflow-core/tests/unit/serialization/test_ts_sdk_serialization_version.py`
* fails until it is.
*/
-export const SERIALIZATION_VERSION = 3;
+export const SERIALIZATION_VERSION = 4;
Review Comment:
Would a TS bundle with `__version` 4 still load on Airflow 3.4.0, which
accepts only 1 to 3
##########
task-sdk/src/airflow/sdk/bases/operatorlink.py:
##########
@@ -55,12 +55,34 @@ def xcom_key(self) -> str:
"""
return f"_link_{self.__class__.__name__}"
- @abstractmethod
+ @property
+ def static_url(self) -> str | None:
+ """
+ Constant URL for this link, when it does not depend on the task run.
+
+ Links that override this property don't need an XCom entry: the URL is
+ carried through DAG serialization and rendered directly by the API
+ server, even for task instances that never pushed it via
``get_link()``.
+
+ Defaults to ``None``, meaning the link is resolved dynamically through
+ :meth:`get_link` and stored in XComs as before. Set it (instead of
+ overriding :meth:`get_link`) for links whose URL is always the same.
+ """
+ return None
+
def get_link(self, operator: BaseOperator, *, ti_key: TaskInstanceKey) ->
str:
"""
Link to external system.
+ Subclasses whose URL does not depend on the task run may override
+ :attr:`static_url` instead of this method and skip the XCom round-trip.
+
:param operator: The Airflow operator object this link is associated
to.
:param ti_key: TaskInstance ID to return link for.
:return: link to external system
"""
+ if self.static_url is not None:
+ return self.static_url
+ raise NotImplementedError(
Review Comment:
Dropping `@abstractmethod` moves this error from class instantiation to
`finalize`, after the task already ran
--
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]