junyeong0619 commented on code in PR #66022:
URL: https://github.com/apache/airflow/pull/66022#discussion_r3215495520
##########
task-sdk/src/airflow/sdk/definitions/variable.py:
##########
@@ -67,6 +67,23 @@ def set(cls, key: str, value: Any, description: str | None =
None, serialize_jso
except AirflowRuntimeError as e:
log.exception(e)
+ @classmethod
+ def keys(cls, prefix: str | None = None) -> list[str]:
+ """
+ Return Variable keys that start with the given prefix.
+
+ The keys are fetched lazily on first access (iteration, indexing, len,
etc.)
+ and cached for subsequent access. Only keys stored in the metadata
database
+ are returned — secrets backends are not consulted.
+
+ :param prefix: Optional key prefix to filter by. If None, all keys are
returned.
+ """
+ import lazy_object_proxy
+
+ from airflow.sdk.execution_time.context import _get_variable_keys
+
+ return lazy_object_proxy.Proxy(lambda:
_get_variable_keys(prefix=prefix))
Review Comment:
The intention behind Amogh's suggestion was to maintain consistency with
Airflow's existing patterns. Since `var` and `conn` in the template context
already utilize the lazy proxy pattern, we decided to keep the lazy proxy and
type it as `Sequence[str]` to align with that design.
--
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]