Ask Inkeep
how does one pin the python dependencies
Answer
To pin Python dependencies in Windmill, you can use the
#requirements:
or #extra_requirements:
comments at the top of your script. Here's how you can do it:
1. Using #requirements:
:
If you want to override the inferred imports or pin specific versions, you can use the #requirements:
comment. Here's an example:
(1)
2. Using #extra_requirements:
:
If you want to combine Windmill's automatic inference with pinned dependencies, use the #extra_requirements:
comment:
These methods allow you to specify exact versions of dependencies or add extra dependencies that might not be automatically inferred by Windmill.
It's worth noting that Windmill automatically manages dependencies for you in standard mode. When you import libraries in your Python script, Windmill parses these imports upon saving the script and automatically generates a list of dependencies. (2)
If you need to use a specific version of a library that's different from what Windmill infers, or if you're encountering conflicts between dependencies, these pinning methods can be particularly useful. (3)4 replies
how does one pin the python dependencies
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Dependencies in Python
* Jobs
* Python Quickstart
* python dependencies version
-----------------------------
4 replies
how do I share logic between scripts
You can use both relative and absolute imports, but relative imports are preferred for compatibility with local editors.
Important Considerations
1. In both the web editor and CLI, scripts don't necessarily need a main function. If they don't have one, they're assumed to be shared logic and not runnable scripts. (1)
2. When using relative imports, make sure you have view rights on the scripts you're importing at the time of execution. (2)
3. The folder layout for sharing logic is identical to the one used with the CLI for syncing scripts locally and on Windmill.
4. For TypeScript, path depths can vary, and relative imports will work at any level, ensuring consistency between local and Windmill environments. (3)
By using these methods, you can effectively share common logic between your scripts in Windmill, improving code reusability and maintainability. (1) (2) (3)
5 replies
how do I share logic between scripts
Answer
Windmill allows you to share common logic between your scripts using relative imports in both Python and TypeScript. (1) This feature works well with local development and can be easily synced using the CLI.
Python Relative Imports
For Python scripts, you can import directly from other scripts by following the path layout. (2) Here's an example:
You can use relative imports for scripts in the same folder or user-space, or access scripts in different folders.
TypeScript Relative Imports
For TypeScript scripts using Deno or Bun, you can similarly import from other scripts. (3) Here's an example:
5 replies
how do I share logic between scripts
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Sharing Common Logic
* Dependency Management & Imports
* Dependencies in Python
* Dependencies in TypeScript
-----------------------------
5 replies