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/07/26 05:03:25 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_r929526526


##########
airflow/operators/python.py:
##########
@@ -433,7 +433,8 @@ def execute_callable(self):
             if not isinstance(self.requirements, str):
                 requirements_file_contents = "\n".join(str(dependency) for dependency in self.requirements)
             else:
-                requirements_file_contents = self.requirements
+                with open(self.requirements, "r") as file:
+                    requirements_file_contents = "\n".join(file.readlines())

Review Comment:
   Perhaps we can do this:
   
   ```python
   if not isinstance(self.requirements, str):
       ...
   elif os.path.exists(self.requirements):
       with open(self.requirements, "r") as f:
           ...
   else:
       requirements_file_contents = self.requirements
   ```
   
   This helps keep compatibility to the “incorrect” use of providing one single requirement as the argument.



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