suhail-zemoso commented on issue #53617:
URL: https://github.com/apache/airflow/issues/53617#issuecomment-3126681310

   > [@suhail-zemoso](https://github.com/suhail-zemoso) And how to modify 
`sys.path`?
   > 
   > This is IMHO regression since until 3.0.1 dags folder was in `sys.path` 
and by no announcement it was removed. It should be added back.
   > 
   > Plugins seems to have different purpose. 
https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/plugins.html#what-for
   
   
   
   **Option 1**: Modify sys.path in code
   You can dynamically add the path at runtime within your DAG Python file
   
   import sys
   import os
   
   # Add the absolute path of libs/ to sys.path
   libs_path = os.path.join(os.path.dirname(__file__), "..", "libs")
   sys.path.insert(0, os.path.abspath(libs_path))
   
   # Now you can import your custom module
   from my_module import my_function
   
   **Option 2**: Set PYTHONPATH Environment Variable 
   permanently add a folder to sys.path by setting the PYTHONPATH environment 
variable:
   
   export PYTHONPATH=/path/to/your/libs:$PYTHONPATH
   
   Agreed — plugins_folder is meant for extending Airflow (e.g., custom 
operators, hooks), not for business logic. For shared code or utilities, it's 
better to create a separate folder like libs/ and add it to the PYTHONPATH for 
clean and maintainable DAGs.
   


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

Reply via email to