You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/10 10:01:01 UTC

[GitHub] [airflow] uranusjr commented on a diff in pull request #24368: Fix requirements.txt path in Python operator

uranusjr commented on code in PR #24368:
URL: https://github.com/apache/airflow/pull/24368#discussion_r894364794


##########
airflow/operators/python.py:
##########
@@ -408,7 +408,8 @@ def __init__(
         if not requirements:
             self.requirements: Union[List[str], str] = []
         elif isinstance(requirements, str):
-            self.requirements = requirements
+            with open(requirements, "r") as file:
+                self.requirements = file.readlines()

Review Comment:
   This does not work if the task is distributed onto a worker, which is not necessarily the same machine as the scheduler. The file should only need to exist on the worker (that only runs the task code), not the scheduler (which runs the Airflow scheduling logic).
   
   So this must continue to store only the filename in `__init__`, and reading the file can only happen in `execute`.



-- 
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