jason810496 commented on code in PR #60826: URL: https://github.com/apache/airflow/pull/60826#discussion_r2708775000
########## shared/logging/src/airflow_shared/logging/remote.py: ########## @@ -0,0 +1,95 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import os +from collections.abc import Callable +from importlib import import_module +from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable + +import structlog + +if TYPE_CHECKING: + # Use Any for forward references to avoid importing concrete types + RuntimeTI = Any # Type alias for RuntimeTaskInstance protocol + LogResponse = tuple[Any, Any] # Type alias for (messages, logs) + StreamingLogResponse = tuple[Any, Any] # Type alias for streaming response Review Comment: We could directly copy from https://github.com/apache/airflow/blob/cd0cb083a191967e788388ab4faddbd0cbcfe14d/airflow-core/src/airflow/utils/log/file_task_handler.py#L69-L84 ########## task-sdk/src/airflow/sdk/log.py: ########## @@ -33,13 +33,21 @@ if TYPE_CHECKING: from structlog.typing import EventDict, FilteringBoundLogger, Processor - from airflow.logging_config import RemoteLogIO + from airflow.sdk._shared.logging.remote import RemoteLogIO from airflow.sdk.types import Logger, RuntimeTaskInstanceProtocol as RuntimeTI from airflow.sdk._shared.secrets_masker import redact +class _ActiveLoggingConfig: + """Internal class to track active logging configuration.""" + + logging_config_loaded = False + remote_task_log: RemoteLogIO | None = None + default_remote_conn_id: str | None = None + Review Comment: It’s not necessary, but we could add a setter method for this class. ########## shared/logging/src/airflow_shared/logging/remote.py: ########## @@ -0,0 +1,95 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from __future__ import annotations + +import os +from collections.abc import Callable +from importlib import import_module +from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable + +import structlog + +if TYPE_CHECKING: + # Use Any for forward references to avoid importing concrete types + RuntimeTI = Any # Type alias for RuntimeTaskInstance protocol + LogResponse = tuple[Any, Any] # Type alias for (messages, logs) + StreamingLogResponse = tuple[Any, Any] # Type alias for streaming response + +log = structlog.getLogger(__name__) + + Review Comment: How about moving `class _ActiveLoggingConfig` and `def get_remote_task_log` to shared module as well? -- 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]
