potiuk commented on code in PR #28300: URL: https://github.com/apache/airflow/pull/28300#discussion_r1058843112
########## docs/apache-airflow/administration-and-deployment/public-airflow-interface.rst: ########## @@ -0,0 +1,87 @@ + .. 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. + +Public Interface of Airflow +=========================== + +The Public Interface of Apache Airflow is a set of programmatic interfaces that allow developers to interact +with and access certain features of the Apache Airflow system. This includes operations such as +creating and managing DAGs (directed acyclic graphs), managing tasks and their dependencies, +and extending Airflow capabilities by writing new executors, plugins, operators and providers. The +Public Interface can be useful for building custom tools and integrations with other systems, +and for automating certain aspects of the Airflow workflow. + +You can extend Airflow in three ways: + +* By writing new custom Python code (via Operators, Plugins, Provider) +* By using the `Stable REST API <stable-rest-api-ref>`_ (based on the OpenAPI specification) +* By using the `Airflow Command Line Interface (CLI) <cli-and-env-variables-ref.rst>`_ + +How can you extend Apache Airflow with custom Python Code? +========================================================== + +The Public Interface of Airflow consists of a number of different classes and packages that provide access +to the core features and functionality of the system. + +The classes and packages that may be considered as the Public Interface include: + +* The :class:`~airflow.DAG`, which provides a way to define and manage DAGs in Airflow. +* The :class:`~airflow.models.baseoperator.BaseOperator`, which provides a way write custom operators. +* The :class:`~airflow.hooks.base.BaseHook`, which provides a way write custom hooks. +* The :class:`~airflow.models.connection.Connection`, which provides access to external service credentials and configuration. +* The :class:`~airflow.models.variable.Variable`, which provides access to Airflow configuration variables. +* The :class:`~airflow.models.xcom.XCom` which are used to access to inter-task communication data. +* The :class:`~airflow.secrets.BaseSecretsBackend` which are used to define custom secret managers. +* The :class:`~airflow.plugins_manager.AirflowPlugin` which are used to define custom plugins. +* The :class:`~airflow.triggers.base.BaseTrigger`, which are used to implement custom Custom Deferrable Operators (based on ``asyncio``). +* The :class:`~airflow.decorators.base.TaskDecorator`, which provides a way write custom decorators. +* The :class:`~airflow.listeners.listener.ListenerManager` class which provides hooks that can be implemented to respond to DAG/Task lifecycle events. + +.. versionadded:: 2.5 + + Listener public interface has been added in version 2.5. + +* The :class:`~airflow.executors.base_executor.BaseExecutor` - the Executors are the components of Airflow + that are responsible for executing tasks. + +.. versionadded:: 2.6 + + There are a number of different executor implementations built-in Airflow, each with its own unique + characteristics and capabilities. Executor interface was available in earlier version of Airflow but + only as of version 2.6 executors are fully decoupled and Airflow does not rely on built-in set of executors. + You could have implemented (and succeeded) with implementing Executors before Airflow 2.6 and a number + of people succeeded in doing so, but there were some hard-coded behaviours that preferred in-built + executors, and custom executors could not provide full functionality that built-in executors had. + + +What is not part of the Public Interface of Apache Airflow? +=========================================================== + +Everything not mentioned in this document should be considered as non-Public Interface. Review Comment: That's a good point. I think K8S is pretty special case because it is both used internally by K8S executor as well as it is exposed externally. And I think there we **could** treat it in a special way and just there make sure that we explicitly decide on which parts of the pod manager or KPO is bound to change. We could indeed decide that the _ (or :private:) is actually something that you SHOULD NOT use because it MIGHT change. And I think in most cases we follow that convention actually - I see tht in KPO we have a number of classes that are `_` and yes - that's ok for those methods to change their signatures in whatever way. User got enough signal (and we should be explicit about it too) that this method is more volatile than the others (by sheer _ in front). And to be honest - this is already supported by our documentation: https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes/stable/_api/airflow/providers/cncf/kubernetes/index.html - does not contain any _* methods because they are excluded by our Sphinx autoapi settings. I will add some description about that to cover general approach for that (also covering providers). Also I have found one thing. We actually have **almost** what I created here available (but no-one commenting here realized that so I consider that as something that we can easily merge. We have this page in our docs: https://airflow.apache.org/docs/apache-airflow/stable/python-api-ref.html - and besides being out-dated and having some buggy entries (empty "utils" ?) it was an attempt to do very similar as part of my doc - expose some of the classes that we think are "public". And besides being unmaintained (no triggers for example) It had no explicit mentioning that this is "public interface" and all the rest is not and it was only about "Python API", but Airflow public interface is a little more than that (DB/REST Api and explicit exclusion of the UI and possibly other components are more general than just Python API). I will remove that page and add redirection and merge these two. -- 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]
