potiuk commented on code in PR #25780: URL: https://github.com/apache/airflow/pull/25780#discussion_r961984441
########## airflow/example_dags/example_python_operator.py: ########## @@ -32,6 +36,20 @@ log = logging.getLogger(__name__) +PYTHON = sys.executable + +BASE_DIR = tempfile.gettempdir() +EXTERNAL_PYTHON_ENV = Path(BASE_DIR, "venv-for-system-tests") + +# [START howto_initial_operator_external_python] + +EXTERNAL_PYTHON_PATH = EXTERNAL_PYTHON_ENV / "bin" / "python" + +# [END howto_initial_operator_external_python] + +if not EXTERNAL_PYTHON_PATH.exists(): + venv.create(EXTERNAL_PYTHON_ENV) Review Comment: Actually - that was a very good call @mik-laj . During testing it, I found that the operator expected the venv during parsing - which was completely unnnecessary. I changed it slightly after your comment: * I am using `sys.executable` in the example as external Python. Not really the "venv" case but since we changed it to ExternalPythonOperator, it's actuallly a valid case now :D * the 'check if venv exist is moved to "execute" - which will make it possible to not have the venv defined during parsing -- 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]
