potiuk commented on code in PR #25780:
URL: https://github.com/apache/airflow/pull/25780#discussion_r950703427
##########
airflow/example_dags/example_python_operator.py:
##########
@@ -93,3 +93,28 @@ def callable_virtualenv():
virtualenv_task = callable_virtualenv()
# [END howto_operator_python_venv]
+
+ # [START howto_operator_external_python]
+ @task.external_python(task_id="virtualenv_python",
python="/ven/bin/python")
+ def callable_external_python():
+ """
+ Example function that will be performed in a virtual environment.
+
+ Importing at the module level ensures that it will not attempt to
import the
+ library before it is installed.
+ """
+ from time import sleep
+
+ from colorama import Back, Fore, Style
+
+ print(Fore.RED + 'some red text')
+ print(Back.GREEN + 'and with a green background')
+ print(Style.DIM + 'and in dim text')
+ print(Style.RESET_ALL)
+ for _ in range(10):
+ print(Style.DIM + 'Please wait...', flush=True)
+ sleep(10)
Review Comment:
Yeah. Can be shorter decreased it . But Actually those are part of the docs
and they are displayed there ar, so extracting common util with cloud their
role as an example. In this case DAMP is better than DRY and for a good reason.
--
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]