amoghrajesh commented on issue #54714:
URL: https://github.com/apache/airflow/issues/54714#issuecomment-3741920944

   @sjyangkevin Thanks for working on this PR! Here's clarification on the 
imports:
   
   ### General Guidelines to follow
   
   1. For `_internal` modules: These should issue a warning that users are 
accessing internal APIs that can change at any time without notice. So if 
import `A` is used, issue a warning `B`
   
   2. For public SDK imports: Where possible, use the **public API path** 
(`from airflow.sdk import X`) instead of full module paths if the item is 
exported in 
[`airflow.sdk.__init__.py`](https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/__init__.py).
   
   ## Clarification on specific pointers
   
   1. Moved Functions - Remove from AIR321
   
   `airflow.utils.task_group.get_task_group_children_getter`
   `airflow.utils.task_group.task_group_to_dict`
   
   Remove these from AIR321 - they are now internal API service functions, not 
part of the public SDK. Users should not directly import these.
   
   2. poke_mode_only - Fix Import Path
   
   airflow.sensors.base.poke_mode_only → airflow.sdk.bases.sensor.poke_mode_only
   
   3. SecretCache - Move from AIR301 to AIR321
   
   airflow.secrets.cache.SecretCache → from airflow.sdk import SecretCache and 
use lazy import
   
   4. AbstractOperator - Keep in AIR321 with warning i think
   
   Keep in AIR321, but since these target `_internal` modules, add a warning 
message that users are accessing internal APIs subject to change without notice.
   
   
   ### So if I had to summarise:
   
   #### These need to issue warning because its internal module:
   
   ```python
   # airflow.utils.setup_teardown
   airflow.utils.setup_teardown.BaseSetupTeardownContext → 
airflow.sdk.definitions._internal.setup_teardown.BaseSetupTeardownContext
   airflow.utils.setup_teardown.SetupTeardownContext → 
airflow.sdk.definitions._internal.setup_teardown.SetupTeardownContext
   
   # airflow.utils.decorators
   airflow.utils.decorators.remove_task_decorator → 
airflow.sdk.definitions._internal.decorators.remove_task_decorator
   airflow.utils.decorators.fixup_decorator_warning_stack → 
airflow.sdk.definitions._internal.decorators.fixup_decorator_warning_stack
   
   # airflow.models.abstractoperator
   airflow.models.abstractoperator.AbstractOperator → 
airflow.sdk.definitions._internal.abstractoperator.AbstractOperator
   airflow.models.abstractoperator.NotMapped → 
airflow.sdk.definitions._internal.abstractoperator.NotMapped
   airflow.models.abstractoperator.TaskStateChangeCallback → 
airflow.sdk.definitions._internal.abstractoperator.TaskStateChangeCallback
   ```
   
   #### Keep these as-is
   
   ```python
   # airflow.utils.xcom
   airflow.utils.xcom.XCOM_RETURN_KEY → airflow.models.xcom.XCOM_RETURN_KEY
   
   # airflow.utils.timezone
   airflow.utils.timezone.coerce_datetime → airflow.sdk.timezone.coerce_datetime
   airflow.utils.timezone.convert_to_utc → airflow.sdk.timezone.convert_to_utc
   airflow.utils.timezone.datetime → airflow.sdk.timezone.datetime
   airflow.utils.timezone.make_naive → airflow.sdk.timezone.make_naive
   airflow.utils.timezone.parse → airflow.sdk.timezone.parse
   airflow.utils.timezone.utc → airflow.sdk.timezone.utc
   airflow.utils.timezone.utcnow → airflow.sdk.timezone.utcnow
   
   # airflow.macros
   airflow.macros.ds_add → airflow.sdk.execution_time.macros.ds_add
   airflow.macros.ds_format → airflow.sdk.execution_time.macros.ds_format
   airflow.macros.datetime_diff_for_humans → 
airflow.sdk.execution_time.macros.datetime_diff_for_humans
   airflow.macros.ds_format_locale → 
airflow.sdk.execution_time.macros.ds_format_locale
   
   # airflow.io
   airflow.io.get_fs → airflow.sdk.io.get_fs
   airflow.io.has_fs → airflow.sdk.io.has_fs
   airflow.io.Properties → airflow.sdk.io.Properties
   ```
   
   #### Update these to use public API (airflow.sdk)]
   
   ```python
   # airflow.utils.task_group
   airflow.utils.task_group.TaskGroup → from airflow.sdk import TaskGroup
   
   # airflow.models.baseoperator
   airflow.models.baseoperator.BaseOperator → from airflow.sdk import 
BaseOperator
   ```
   


-- 
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]

Reply via email to