2 Replies
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Sharing Common Logic
* Dependency Management & Imports
* Python Quickstart
* bug: Scheduled script with relative import fails when import added to upstream
-----------------------------
Answer
In Windmill, when working with Python scripts, you can share common logic between your scripts using relative imports. This feature allows you to easily reuse code across different scripts in your project. Here's how you can do it:
- To import directly from another Python script, you can follow the path layout. For instance, to import a function
foo
from a script called common_logic
located in the same user space, you would use the following syntax:
- It works with scripts contained in folders and for scripts contained in user spaces, such as f.<foldername>.script_path
or u.<username>.script_path
.
- Keep in mind that you can only import scripts that you have view rights on at the time of execution. This ensures that your code respects the necessary access controls (1) .
Remember, this flexibility in sharing common logic enhances your ability to maintain and organize your code efficiently, making your development process with Windmill more streamlined and effective.