You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "xionams (via GitHub)" <gi...@apache.org> on 2024/02/20 20:37:23 UTC
[PR] fix(main): fix ImportError on examples dags [airflow]
xionams opened a new pull request, #37571:
URL: https://github.com/apache/airflow/pull/37571
<!--
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.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
this pull request is related to: https://github.com/apache/airflow-site/issues/945
the solution of "skipped" on the dag-loading when the virtualenv is not installed
is wrap the dag loading with try-except and return None either
using this logic will guarantee the ImportError exception will not stored in the DB
and not thrown on the homepage as an error.
**so if virtualenv is not installed the examples are not loaded and the exception will not thrown**
tested on Ubuntu WSL2
<!-- Please keep an empty line above the dashes. -->
---
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #37571:
URL: https://github.com/apache/airflow/pull/37571#discussion_r1496468368
##########
airflow/example_dags/libs/helper.py:
##########
@@ -20,3 +20,11 @@
def print_stuff():
print("annotated!")
+
+def check_venv_dependency():
+ """Check if the virtualenv module is installed"""
+ try:
+ import virtualenv
+ return True
+ except ImportError:
+ return False
Review Comment:
You can use
`from airflow.operators.python import is_venv_installed`
https://github.com/apache/airflow/blob/8c0a4de66344647c759b6188cabafacf26ace9e3/airflow/operators/python.py#L66-L74
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #37571:
URL: https://github.com/apache/airflow/pull/37571#issuecomment-1960250588
Just one static check to fix
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #37571:
URL: https://github.com/apache/airflow/pull/37571#issuecomment-1955039292
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-pre-commit-hooks) will help you with that.
- In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
- Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
Apache Airflow is a community-driven project and together we are making it better 🚀.
In case of doubts contact the developers at:
Mailing List: dev@airflow.apache.org
Slack: https://s.apache.org/airflow-slack
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #37571:
URL: https://github.com/apache/airflow/pull/37571#issuecomment-1961845657
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #37571:
URL: https://github.com/apache/airflow/pull/37571
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #37571:
URL: https://github.com/apache/airflow/pull/37571#discussion_r1497926161
##########
airflow/example_dags/example_branch_operator.py:
##########
@@ -28,140 +28,147 @@
import pendulum
-from airflow.models.dag import DAG
-from airflow.operators.empty import EmptyOperator
-from airflow.operators.python import (
- BranchExternalPythonOperator,
- BranchPythonOperator,
- BranchPythonVirtualenvOperator,
- ExternalPythonOperator,
- PythonOperator,
- PythonVirtualenvOperator,
-)
-from airflow.utils.edgemodifier import Label
-from airflow.utils.trigger_rule import TriggerRule
-
-PATH_TO_PYTHON_BINARY = sys.executable
-
-with DAG(
- dag_id="example_branch_operator",
- start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
- catchup=False,
- schedule="@daily",
- tags=["example", "example2"],
- orientation="TB",
-) as dag:
- run_this_first = EmptyOperator(
- task_id="run_this_first",
+from airflow.operators.python import is_venv_installed
+
+venv_installed=is_venv_installed()
+
+if venv_installed:
Review Comment:
```suggestion
if is_venv_installed():
```
##########
airflow/example_dags/example_branch_operator_decorator.py:
##########
@@ -29,116 +29,124 @@
import pendulum
-from airflow.decorators import task
-from airflow.models.dag import DAG
-from airflow.operators.empty import EmptyOperator
-from airflow.utils.edgemodifier import Label
-from airflow.utils.trigger_rule import TriggerRule
+from airflow.operators.python import is_venv_installed
-PATH_TO_PYTHON_BINARY = sys.executable
+venv_installed=is_venv_installed()
-with DAG(
- dag_id="example_branch_python_operator_decorator",
- start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
- catchup=False,
- schedule="@daily",
- tags=["example", "example2"],
- orientation="TB",
-) as dag:
- run_this_first = EmptyOperator(task_id="run_this_first")
+if venv_installed:
+ from airflow.decorators import task
+ from airflow.models.dag import DAG
+ from airflow.operators.empty import EmptyOperator
+ from airflow.utils.edgemodifier import Label
+ from airflow.utils.trigger_rule import TriggerRule
- options = ["a", "b", "c", "d"]
+ PATH_TO_PYTHON_BINARY = sys.executable
- # Example branching on standard Python tasks
+ with DAG(
+ dag_id="example_branch_python_operator_decorator",
+ start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
+ catchup=False,
+ schedule="@daily",
+ tags=["example", "example2"],
+ orientation="TB",
+ ) as dag:
+ run_this_first = EmptyOperator(task_id="run_this_first")
- # [START howto_operator_branch_python]
- @task.branch()
- def branching(choices: list[str]) -> str:
- return f"branch_{random.choice(choices)}"
+ options = ["a", "b", "c", "d"]
- # [END howto_operator_branch_python]
+ # Example branching on standard Python tasks
- random_choice_instance = branching(choices=options)
+ # [START howto_operator_branch_python]
+ @task.branch()
+ def branching(choices: list[str]) -> str:
+ return f"branch_{random.choice(choices)}"
- run_this_first >> random_choice_instance
+ # [END howto_operator_branch_python]
- join = EmptyOperator(task_id="join", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
+ random_choice_instance = branching(choices=options)
- for option in options:
+ run_this_first >> random_choice_instance
- @task(task_id=f"branch_{option}")
- def some_task():
- print("doing something in Python")
+ join = EmptyOperator(task_id="join", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
- t = some_task()
- empty = EmptyOperator(task_id=f"follow_{option}")
+ for option in options:
- # Label is optional here, but it can help identify more complex branches
- random_choice_instance >> Label(option) >> t >> empty >> join
+ @task(task_id=f"branch_{option}")
+ def some_task():
+ print("doing something in Python")
- # Example the same with external Python calls
+ t = some_task()
+ empty = EmptyOperator(task_id=f"follow_{option}")
- # [START howto_operator_branch_ext_py]
- @task.branch_external_python(python=PATH_TO_PYTHON_BINARY)
- def branching_ext_python(choices) -> str:
- import random
+ # Label is optional here, but it can help identify more complex branches
+ random_choice_instance >> Label(option) >> t >> empty >> join
- return f"ext_py_{random.choice(choices)}"
+ # Example the same with external Python calls
- # [END howto_operator_branch_ext_py]
+ # [START howto_operator_branch_ext_py]
+ @task.branch_external_python(python=PATH_TO_PYTHON_BINARY)
+ def branching_ext_python(choices) -> str:
+ import random
- random_choice_ext_py = branching_ext_python(choices=options)
+ return f"ext_py_{random.choice(choices)}"
- join >> random_choice_ext_py
+ # [END howto_operator_branch_ext_py]
- join_ext_py = EmptyOperator(task_id="join_ext_py", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
+ random_choice_ext_py = branching_ext_python(choices=options)
- for option in options:
+ join >> random_choice_ext_py
- @task.external_python(task_id=f"ext_py_{option}", python=PATH_TO_PYTHON_BINARY)
- def some_ext_py_task():
- print("doing something in external Python")
+ join_ext_py = EmptyOperator(task_id="join_ext_py", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
- t = some_ext_py_task()
+ for option in options:
- # Label is optional here, but it can help identify more complex branches
- random_choice_ext_py >> Label(option) >> t >> join_ext_py
+ @task.external_python(task_id=f"ext_py_{option}", python=PATH_TO_PYTHON_BINARY)
+ def some_ext_py_task():
+ print("doing something in external Python")
- # Example the same with Python virtual environments
+ t = some_ext_py_task()
- # [START howto_operator_branch_virtualenv]
- # Note: Passing a caching dir allows to keep the virtual environment over multiple runs
- # Run the example a second time and see that it re-uses it and is faster.
- VENV_CACHE_PATH = tempfile.gettempdir()
+ # Label is optional here, but it can help identify more complex branches
+ random_choice_ext_py >> Label(option) >> t >> join_ext_py
- @task.branch_virtualenv(requirements=["numpy~=1.24.4"], venv_cache_path=VENV_CACHE_PATH)
- def branching_virtualenv(choices) -> str:
- import random
+ # Example the same with Python virtual environments
- import numpy as np
+ # [START howto_operator_branch_virtualenv]
+ # Note: Passing a caching dir allows to keep the virtual environment over multiple runs
+ # Run the example a second time and see that it re-uses it and is faster.
+ VENV_CACHE_PATH = tempfile.gettempdir()
- print(f"Some numpy stuff: {np.arange(6)}")
- return f"venv_{random.choice(choices)}"
+ @task.branch_virtualenv(requirements=["numpy~=1.24.4"], venv_cache_path=VENV_CACHE_PATH)
+ def branching_virtualenv(choices) -> str:
+ import random
- # [END howto_operator_branch_virtualenv]
+ import numpy as np
- random_choice_venv = branching_virtualenv(choices=options)
+ print(f"Some numpy stuff: {np.arange(6)}")
+ return f"venv_{random.choice(choices)}"
- join_ext_py >> random_choice_venv
+ # [END howto_operator_branch_virtualenv]
- join_venv = EmptyOperator(task_id="join_venv", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
+ random_choice_venv = branching_virtualenv(choices=options)
- for option in options:
+ join_ext_py >> random_choice_venv
- @task.virtualenv(
- task_id=f"venv_{option}", requirements=["numpy~=1.24.4"], venv_cache_path=VENV_CACHE_PATH
- )
- def some_venv_task():
- import numpy as np
+ join_venv = EmptyOperator(task_id="join_venv", trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS)
- print(f"Some numpy stuff: {np.arange(6)}")
+ for option in options:
+
+ @task.virtualenv(
+ task_id=f"venv_{option}", requirements=["numpy~=1.24.4"], venv_cache_path=VENV_CACHE_PATH
+ )
+ def some_venv_task():
+ import numpy as np
+
+ print(f"Some numpy stuff: {np.arange(6)}")
- t = some_venv_task()
+ t = some_venv_task()
- # Label is optional here, but it can help identify more complex branches
- random_choice_venv >> Label(option) >> t >> join_venv
+ # Label is optional here, but it can help identify more complex branches
+ random_choice_venv >> Label(option) >> t >> join_venv
+else:
+ deg = None
+
Review Comment:
```suggestion
```
##########
airflow/example_dags/example_branch_operator_decorator.py:
##########
@@ -29,116 +29,124 @@
import pendulum
-from airflow.decorators import task
-from airflow.models.dag import DAG
-from airflow.operators.empty import EmptyOperator
-from airflow.utils.edgemodifier import Label
-from airflow.utils.trigger_rule import TriggerRule
+from airflow.operators.python import is_venv_installed
-PATH_TO_PYTHON_BINARY = sys.executable
+venv_installed=is_venv_installed()
Review Comment:
```suggestion
```
##########
airflow/example_dags/example_branch_operator_decorator.py:
##########
@@ -29,116 +29,124 @@
import pendulum
-from airflow.decorators import task
-from airflow.models.dag import DAG
-from airflow.operators.empty import EmptyOperator
-from airflow.utils.edgemodifier import Label
-from airflow.utils.trigger_rule import TriggerRule
+from airflow.operators.python import is_venv_installed
-PATH_TO_PYTHON_BINARY = sys.executable
+venv_installed=is_venv_installed()
-with DAG(
- dag_id="example_branch_python_operator_decorator",
- start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
- catchup=False,
- schedule="@daily",
- tags=["example", "example2"],
- orientation="TB",
-) as dag:
- run_this_first = EmptyOperator(task_id="run_this_first")
+if venv_installed:
Review Comment:
```suggestion
if is_venv_installed():
```
##########
airflow/example_dags/example_branch_operator.py:
##########
@@ -28,140 +28,147 @@
import pendulum
-from airflow.models.dag import DAG
-from airflow.operators.empty import EmptyOperator
-from airflow.operators.python import (
- BranchExternalPythonOperator,
- BranchPythonOperator,
- BranchPythonVirtualenvOperator,
- ExternalPythonOperator,
- PythonOperator,
- PythonVirtualenvOperator,
-)
-from airflow.utils.edgemodifier import Label
-from airflow.utils.trigger_rule import TriggerRule
-
-PATH_TO_PYTHON_BINARY = sys.executable
-
-with DAG(
- dag_id="example_branch_operator",
- start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
- catchup=False,
- schedule="@daily",
- tags=["example", "example2"],
- orientation="TB",
-) as dag:
- run_this_first = EmptyOperator(
- task_id="run_this_first",
+from airflow.operators.python import is_venv_installed
+
+venv_installed=is_venv_installed()
+
+if venv_installed:
+ from airflow.models.dag import DAG
+ from airflow.operators.empty import EmptyOperator
+ from airflow.operators.python import (
+ BranchExternalPythonOperator,
+ BranchPythonOperator,
+ BranchPythonVirtualenvOperator,
+ ExternalPythonOperator,
+ PythonOperator,
+ PythonVirtualenvOperator,
)
+ from airflow.utils.edgemodifier import Label
+ from airflow.utils.trigger_rule import TriggerRule
+
+ PATH_TO_PYTHON_BINARY = sys.executable
+
+ with DAG(
+ dag_id="example_branch_operator",
+ start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
+ catchup=False,
+ schedule="@daily",
+ tags=["example", "example2"],
+ orientation="TB",
+ ) as dag:
+ run_this_first = EmptyOperator(
+ task_id="run_this_first",
+ )
- options = ["a", "b", "c", "d"]
-
- # Example branching on standard Python tasks
+ options = ["a", "b", "c", "d"]
- # [START howto_operator_branch_python]
- branching = BranchPythonOperator(
- task_id="branching",
- python_callable=lambda: f"branch_{random.choice(options)}",
- )
- # [END howto_operator_branch_python]
- run_this_first >> branching
-
- join = EmptyOperator(
- task_id="join",
- trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
- )
+ # Example branching on standard Python tasks
- for option in options:
- t = PythonOperator(
- task_id=f"branch_{option}",
- python_callable=lambda: print("Hello World"),
+ # [START howto_operator_branch_python]
+ branching = BranchPythonOperator(
+ task_id="branching",
+ python_callable=lambda: f"branch_{random.choice(options)}",
)
+ # [END howto_operator_branch_python]
+ run_this_first >> branching
- empty_follow = EmptyOperator(
- task_id="follow_" + option,
+ join = EmptyOperator(
+ task_id="join",
+ trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
)
- # Label is optional here, but it can help identify more complex branches
- branching >> Label(option) >> t >> empty_follow >> join
+ for option in options:
+ t = PythonOperator(
+ task_id=f"branch_{option}",
+ python_callable=lambda: print("Hello World"),
+ )
- # Example the same with external Python calls
+ empty_follow = EmptyOperator(
+ task_id="follow_" + option,
+ )
- # [START howto_operator_branch_ext_py]
- def branch_with_external_python(choices):
- import random
+ # Label is optional here, but it can help identify more complex branches
+ branching >> Label(option) >> t >> empty_follow >> join
- return f"ext_py_{random.choice(choices)}"
+ # Example the same with external Python calls
- branching_ext_py = BranchExternalPythonOperator(
- task_id="branching_ext_python",
- python=PATH_TO_PYTHON_BINARY,
- python_callable=branch_with_external_python,
- op_args=[options],
- )
- # [END howto_operator_branch_ext_py]
- join >> branching_ext_py
-
- join_ext_py = EmptyOperator(
- task_id="join_ext_python",
- trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
- )
+ # [START howto_operator_branch_ext_py]
+ def branch_with_external_python(choices):
+ import random
- def hello_world_with_external_python():
- print("Hello World from external Python")
+ return f"ext_py_{random.choice(choices)}"
- for option in options:
- t = ExternalPythonOperator(
- task_id=f"ext_py_{option}",
+ branching_ext_py = BranchExternalPythonOperator(
+ task_id="branching_ext_python",
python=PATH_TO_PYTHON_BINARY,
- python_callable=hello_world_with_external_python,
+ python_callable=branch_with_external_python,
+ op_args=[options],
)
+ # [END howto_operator_branch_ext_py]
+ join >> branching_ext_py
- # Label is optional here, but it can help identify more complex branches
- branching_ext_py >> Label(option) >> t >> join_ext_py
-
- # Example the same with Python virtual environments
+ join_ext_py = EmptyOperator(
+ task_id="join_ext_python",
+ trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
+ )
- # [START howto_operator_branch_virtualenv]
- # Note: Passing a caching dir allows to keep the virtual environment over multiple runs
- # Run the example a second time and see that it re-uses it and is faster.
- VENV_CACHE_PATH = Path(tempfile.gettempdir())
+ def hello_world_with_external_python():
+ print("Hello World from external Python")
- def branch_with_venv(choices):
- import random
+ for option in options:
+ t = ExternalPythonOperator(
+ task_id=f"ext_py_{option}",
+ python=PATH_TO_PYTHON_BINARY,
+ python_callable=hello_world_with_external_python,
+ )
- import numpy as np
+ # Label is optional here, but it can help identify more complex branches
+ branching_ext_py >> Label(option) >> t >> join_ext_py
- print(f"Some numpy stuff: {np.arange(6)}")
- return f"venv_{random.choice(choices)}"
+ # Example the same with Python virtual environments
- branching_venv = BranchPythonVirtualenvOperator(
- task_id="branching_venv",
- requirements=["numpy~=1.24.4"],
- venv_cache_path=VENV_CACHE_PATH,
- python_callable=branch_with_venv,
- op_args=[options],
- )
- # [END howto_operator_branch_virtualenv]
- join_ext_py >> branching_venv
+ # [START howto_operator_branch_virtualenv]
+ # Note: Passing a caching dir allows to keep the virtual environment over multiple runs
+ # Run the example a second time and see that it re-uses it and is faster.
+ VENV_CACHE_PATH = Path(tempfile.gettempdir())
- join_venv = EmptyOperator(
- task_id="join_venv",
- trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
- )
+ def branch_with_venv(choices):
+ import random
- def hello_world_with_venv():
- import numpy as np
+ import numpy as np
- print(f"Hello World with some numpy stuff: {np.arange(6)}")
+ print(f"Some numpy stuff: {np.arange(6)}")
+ return f"venv_{random.choice(choices)}"
- for option in options:
- t = PythonVirtualenvOperator(
- task_id=f"venv_{option}",
+ branching_venv = BranchPythonVirtualenvOperator(
+ task_id="branching_venv",
requirements=["numpy~=1.24.4"],
venv_cache_path=VENV_CACHE_PATH,
- python_callable=hello_world_with_venv,
+ python_callable=branch_with_venv,
+ op_args=[options],
+ )
+ # [END howto_operator_branch_virtualenv]
+ join_ext_py >> branching_venv
+
+ join_venv = EmptyOperator(
+ task_id="join_venv",
+ trigger_rule=TriggerRule.NONE_FAILED_MIN_ONE_SUCCESS,
)
- # Label is optional here, but it can help identify more complex branches
- branching_venv >> Label(option) >> t >> join_venv
+ def hello_world_with_venv():
+ import numpy as np
+
+ print(f"Hello World with some numpy stuff: {np.arange(6)}")
+
+ for option in options:
+ t = PythonVirtualenvOperator(
+ task_id=f"venv_{option}",
+ requirements=["numpy~=1.24.4"],
+ venv_cache_path=VENV_CACHE_PATH,
+ python_callable=hello_world_with_venv,
+ )
+
+ # Label is optional here, but it can help identify more complex branches
+ branching_venv >> Label(option) >> t >> join_venv
+else:
+ dag = None
Review Comment:
```suggestion
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #37571:
URL: https://github.com/apache/airflow/pull/37571#discussion_r1501027560
##########
dev/PROJECT_GUIDELINES.md:
##########
@@ -20,6 +20,7 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
+
Review Comment:
```suggestion
```
##########
tests/system/README.md:
##########
@@ -22,6 +22,7 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
+
Review Comment:
```suggestion
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(main): fix ImportError on examples dags [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #37571:
URL: https://github.com/apache/airflow/pull/37571#issuecomment-1961798021
i submitted fixes for the static checks. It should pass now
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org