Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard provider bash operator #42252

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0b7d02b
move bash operator to standard provider
romsharon98 Aug 18, 2024
df90b96
add source-date-epoch
romsharon98 Aug 19, 2024
4ca5cf8
change core to essentials
romsharon98 Aug 19, 2024
934a281
revert external task sensor location
romsharon98 Aug 19, 2024
b5e52b5
add provider to airflow_providers_bug_report list
romsharon98 Aug 21, 2024
489f945
change new provider name to standard
romsharon98 Aug 25, 2024
6f59563
add integration
romsharon98 Aug 25, 2024
fc21101
add standard provider to pre-install list
romsharon98 Aug 25, 2024
be78084
revert hatch_build
romsharon98 Aug 25, 2024
772e785
move examples back to airflow core
romsharon98 Aug 25, 2024
609374a
change sensors example dags paths
romsharon98 Aug 26, 2024
50bbe59
remove init
romsharon98 Aug 26, 2024
269fc18
revert howto docs
romsharon98 Aug 26, 2024
fa10504
change provider as not-ready
romsharon98 Sep 7, 2024
b8c1d1c
add changelog
romsharon98 Sep 15, 2024
7ee4d3b
move bash operator and sensor to standard provider
gopidesupavan Sep 16, 2024
980de79
updated airflow version and resolved rebasing failures
gopidesupavan Sep 18, 2024
fd39777
fix selective check tests for bash
gopidesupavan Sep 18, 2024
55a1487
Added BashOperator in compat.py to work with old imports
gopidesupavan Sep 19, 2024
858f6fe
import bash operator with old module
gopidesupavan Sep 19, 2024
de6de90
update selective checks and imports in test_utils
gopidesupavan Sep 19, 2024
a0eedd6
fix 2.8.4 compat tests
gopidesupavan Sep 19, 2024
fa824a8
add bashoperator import from compat to miscellaneous_test_dag
gopidesupavan Sep 19, 2024
c45316a
fix openlineage test utils test
gopidesupavan Sep 19, 2024
c966be9
revert pre-commit removed imports
gopidesupavan Sep 19, 2024
08b6d0c
remove example_branch_datetime_operator from exclusions in pre-commit…
gopidesupavan Sep 19, 2024
baf7573
import bashoperator using test utils compat in views/utils
gopidesupavan Sep 19, 2024
a85ed27
fix openlineage tests for compat and selective checks
gopidesupavan Sep 20, 2024
92aac90
add standard provider package build in basic-tests.yml to test python…
gopidesupavan Sep 20, 2024
bd53af0
copy the standard provider package into the k8s image build to enable…
gopidesupavan Sep 20, 2024
9905f25
remove standard provider copy command from kubernetes commands
gopidesupavan Sep 21, 2024
d77375d
remove core folder from standard provider
gopidesupavan Sep 21, 2024
c6443ee
add standard provider to prod_image_install_providers
gopidesupavan Sep 21, 2024
600d689
remove core folder from standard provider tests
gopidesupavan Sep 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ jobs:
breeze release-management prepare-provider-packages fab --package-format wheel --skip-tag-check
- name: "Install Airflow with fab for webserver tests"
run: pip install . dist/apache_airflow_providers_fab-*.whl
- name: "Prepare Standard provider packages: wheel"
run: >
breeze release-management prepare-provider-packages standard --package-format wheel --skip-tag-check
- name: "Install Airflow with standard provider for webserver tests"
run: pip install . dist/apache_airflow_providers_standard-*.whl
- name: "Install Python client"
run: pip install ./dist/apache_airflow_client-*.whl
- name: "Initialize Airflow DB and start webserver"
Expand Down
16 changes: 14 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,19 @@ repos:
^airflow/example_dags/example_sensors.py|
^airflow/example_dags/example_sensors.py|
^airflow/example_dags/example_sensors.py|
^airflow/example_dags/example_time_delta_sensor_async.py
^airflow/example_dags/example_time_delta_sensor_async.py|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this change - if we basically add all example DAGs into the exclude list - the check has almost no effect.

Can you re-work the check such that no provider except standard provider dependencies are accepted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, agree. will check.

^airflow/example_dags/example_bash_operator.py|
^airflow/example_dags/example_complex.py|
^airflow/example_dags/example_datasets.py|
^airflow/example_dags/example_inlet_event_extra.py|
^airflow/example_dags/example_outlet_event_extra.py|
^airflow/example_dags/example_passing_params_via_test_command.py|
^airflow/example_dags/example_setup_teardown.py|
^airflow/example_dags/example_task_group.py|
^airflow/example_dags/example_trigger_target_dag.py|
^airflow/example_dags/example_xcom.py|
^airflow/example_dags/example_xcomargs.py|
^airflow/example_dags/tutorial.py
files: ^airflow/example_dags/.*\.py$
- id: check-no-airflow-deprecation-in-providers
language: pygrep
Expand Down Expand Up @@ -717,7 +729,7 @@ repos:
files: >
(?x)
^airflow/providers/.*\.py$
exclude: ^.*/.*_vendor/
exclude: ^.*/.*_vendor/|airflow/providers/standard/operators/bash.py
- id: check-get-lineage-collector-providers
language: python
name: Check providers import hook lineage code from compat
Expand Down
2 changes: 1 addition & 1 deletion airflow/decorators/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Any, Callable, Collection, Mapping, Sequence

from airflow.decorators.base import DecoratedOperator, TaskDecorator, task_decorator_factory
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.utils.context import Context, context_merge
from airflow.utils.operator_helpers import determine_kwargs
from airflow.utils.types import NOTSET
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_bash_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import pendulum

from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.operators.bash import BashOperator

with DAG(
dag_id="example_bash_operator",
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from airflow.models.baseoperator import chain
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

with DAG(
dag_id="example_complex",
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

from airflow.datasets import Dataset
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.timetables.datasets import DatasetOrTimeSchedule
from airflow.timetables.trigger import CronTriggerTimetable

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_inlet_event_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from airflow.datasets import Dataset
from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

ds = Dataset("s3://output/1.txt")

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_outlet_event_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from airflow.datasets.metadata import Metadata
from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

ds = Dataset("s3://output/1.txt")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator


@task(task_id="run_this")
Expand Down
4 changes: 2 additions & 2 deletions airflow/example_dags/example_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
import pendulum

from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.standard.sensors.bash import BashSensor
from airflow.providers.standard.sensors.time import TimeSensor, TimeSensorAsync
from airflow.providers.standard.sensors.time_delta import TimeDeltaSensor, TimeDeltaSensorAsync
from airflow.providers.standard.sensors.weekday import DayOfWeekSensor
from airflow.sensors.bash import BashSensor
from airflow.sensors.filesystem import FileSensor
from airflow.sensors.python import PythonSensor
from airflow.utils.trigger_rule import TriggerRule
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_setup_teardown.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import pendulum

from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.utils.task_group import TaskGroup

with DAG(
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import pendulum

from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.operators.empty import EmptyOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.utils.task_group import TaskGroup

# [START howto_task_group]
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_trigger_target_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator


@task(task_id="run_this")
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_xcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.models.xcom_arg import XComArg
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

value_1 = [1, 2, 3]
value_2 = {"a": "b"}
Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/example_xcomargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from airflow.decorators import task
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion airflow/example_dags/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from airflow.models.dag import DAG

# Operators; we need this to operate!
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

# [END import_module]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ def on_celery_import_modules(*args, **kwargs):
"""
import jinja2.ext # noqa: F401

import airflow.jobs.local_task_job_runner
import airflow.macros
import airflow.operators.bash
import airflow.operators.python # noqa: F401
import airflow.providers.standard.operators.bash # noqa: F401

with contextlib.suppress(ImportError):
import numpy # noqa: F401
Expand Down
6 changes: 5 additions & 1 deletion airflow/providers/edge/example_dags/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@
from airflow.models.dag import DAG
from airflow.models.param import Param
from airflow.models.variable import Variable
from airflow.operators.bash import BashOperator
from airflow.operators.empty import EmptyOperator
from airflow.operators.python import PythonOperator

try:
from airflow.providers.standard.operators.bash import BashOperator
except ImportError:
from airflow.operators.bash import BashOperator # type: ignore[no-redef,attr-defined]

with DAG(
dag_id="integration_test",
dag_display_name="Integration Test",
Expand Down
3 changes: 2 additions & 1 deletion airflow/providers/openlineage/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ config:
Exclude some Operators from emitting OpenLineage events by passing a string of semicolon separated
full import paths of Operators to disable.
type: string
example: "airflow.operators.bash.BashOperator;airflow.operators.python.PythonOperator"
example: "airflow.providers.standard.operators.bash.BashOperator;
airflow.operators.python.PythonOperator"
default: ""
version_added: 1.1.0
selective_enable:
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions airflow/providers/standard/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ operators:
python-modules:
- airflow.providers.standard.operators.datetime
- airflow.providers.standard.operators.weekday
- airflow.providers.standard.operators.bash

sensors:
- integration-name: Standard
Expand All @@ -50,3 +51,4 @@ sensors:
- airflow.providers.standard.sensors.time_delta
- airflow.providers.standard.sensors.time
- airflow.providers.standard.sensors.weekday
- airflow.providers.standard.sensors.bash
File renamed without changes.
14 changes: 7 additions & 7 deletions dev/breeze/tests/test_selective_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,9 @@ def assert_outputs_are_printed(expected_outputs: dict[str, str], stderr: str):
id="Only Always and common providers tests should run when only common.io and tests/always changed",
),
pytest.param(
("airflow/operators/bash.py",),
("airflow/providers/standard/operators/bash.py",),
{
"affected-providers-list-as-string": None,
"affected-providers-list-as-string": "celery edge standard",
"all-python-versions": "['3.8']",
"all-python-versions-list-as-string": "3.8",
"python-versions": "['3.8']",
Expand All @@ -718,14 +718,14 @@ def assert_outputs_are_printed(expected_outputs: dict[str, str], stderr: str):
"run-amazon-tests": "false",
"docs-build": "true",
"run-kubernetes-tests": "false",
"skip-pre-commits": "check-provider-yaml-valid,identity,lint-helm-chart,mypy-airflow,mypy-dev,mypy-docs,mypy-providers,"
"skip-pre-commits": "identity,lint-helm-chart,mypy-airflow,mypy-dev,mypy-docs,mypy-providers,"
"ts-compile-format-lint-ui,ts-compile-format-lint-www",
"upgrade-to-newer-dependencies": "false",
"parallel-test-types-list-as-string": "Always Core Operators Serialization",
"parallel-test-types-list-as-string": "Always Core Providers[celery,edge,standard] Serialization",
"needs-mypy": "true",
"mypy-folders": "['airflow']",
"mypy-folders": "['providers']",
},
id="Force Core and Serialization tests to run when airflow bash.py changed",
id="Providers standard tests and Serialization tests to run when airflow bash.py changed",
),
pytest.param(
("tests/operators/bash.py",),
Expand Down Expand Up @@ -1723,7 +1723,7 @@ def test_upgrade_to_newer_dependencies(
),
pytest.param(
("airflow/providers/celery/file.py",),
{"docs-list-as-string": "apache-airflow celery cncf.kubernetes"},
{"docs-list-as-string": "apache-airflow celery cncf.kubernetes standard"},
id="Celery python files changed",
),
pytest.param(
Expand Down
2 changes: 1 addition & 1 deletion dev/perf/dags/elastic_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from airflow.models.baseoperator import chain
from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

# DAG File used in performance tests. Its shape can be configured by environment variables.
RE_TIME_DELTA = re.compile(
Expand Down
2 changes: 1 addition & 1 deletion dev/perf/dags/perf_dag_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import datetime

from airflow.models.dag import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator

args = {
"owner": "airflow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Example Code:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.amazon.aws.notifications.chime import send_chime_notification

with DAG(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Example Code:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.amazon.aws.notifications.sns import send_sns_notification

dag_failure_sns_notification = send_sns_notification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Example Code:

from datetime import datetime, timezone
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.amazon.aws.notifications.sqs import send_sqs_notification

dag_failure_sqs_notification = send_sqs_notification(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Example Code:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.apprise.notifications.apprise import send_apprise_notification
from apprise import NotifyType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Example Code

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.atlassian.jira.notifications.jira import send_jira_notification

with DAG(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ instead.
You can use :ref:`Jinja templating <concepts:jinja-templating>` with the ``project_id`` and ``model``
fields to dynamically determine their values. The result are saved to :ref:`XCom <concepts:xcom>`,
allowing them to be used by other operators. In this case, the
:class:`~airflow.operators.bash.BashOperator` is used to print the model information.
:class:`~airflow.providers.standard.operators.bash.BashOperator` is used to print the model information.

.. exampleinclude:: /../../tests/system/providers/google/cloud/ml_engine/example_mlengine.py
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Also for this action you can use sensor in the deferrable mode:
:start-after: [START howto_operator_gcp_pubsub_pull_message_with_operator]
:end-before: [END howto_operator_gcp_pubsub_pull_message_with_operator]

To pull messages from XCom use the :class:`~airflow.operators.bash.BashOperator`.
To pull messages from XCom use the :class:`~airflow.providers.standard.operators.bash.BashOperator`.

.. exampleinclude:: /../../tests/system/providers/google/cloud/pubsub/example_pubsub.py
:language: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ An Operator inside the Airflow DAG can be annotated with inlets and outlets like
import pendulum

from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.lineage.entities import Table, File, Column, User


Expand Down
4 changes: 2 additions & 2 deletions docs/apache-airflow-providers-openlineage/guides/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ full import paths of Airflow Operators to disable as ``disabled_for_operators``

[openlineage]
transport = {"type": "http", "url": "http://example.com:5000", "endpoint": "api/v1/lineage"}
disabled_for_operators = 'airflow.operators.bash.BashOperator;airflow.operators.python.PythonOperator'
disabled_for_operators = 'airflow.providers.standard.operators.bash.BashOperator;airflow.operators.python.PythonOperator'

``AIRFLOW__OPENLINEAGE__DISABLED_FOR_OPERATORS`` environment variable is an equivalent.

.. code-block:: ini

AIRFLOW__OPENLINEAGE__DISABLED_FOR_OPERATORS='airflow.operators.bash.BashOperator;airflow.operators.python.PythonOperator'
AIRFLOW__OPENLINEAGE__DISABLED_FOR_OPERATORS='airflow.providers.standard.operators.bash.BashOperator;airflow.operators.python.PythonOperator'

Full Task Info
^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Example Code:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.pagerduty.notifications.pagerduty import send_pagerduty_notification

with DAG(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Example Code:

from datetime import datetime
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.slack.notifications.slack import send_slack_notification

with DAG(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Example Code:

from datetime import datetime, timezone
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.slack.notifications.slack_webhook import send_slack_webhook_notification

dag_failure_slack_webhook_notification = send_slack_webhook_notification(
Expand Down
Loading
Loading