Ask Inkeep
Ask Inkeep
WWindmill
Created by Ahysen on 8/20/2024 in #help
AG Grid API
Please tag me in threads that I was a part of from the start.
4 replies
WWindmill
Created by rubenf on 8/18/2024 in #general
how does one pin the python dependencies
Feel free to tag @Ask Inkeep with additional questions.
4 replies
WWindmill
Created by rubenf on 8/18/2024 in #general
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:
#requirements:
#dependency
#version_pinned_dependency==0.4
import dependency
def main(...):
...
#requirements:
#dependency
#version_pinned_dependency==0.4
import dependency
def main(...):
...
(1) 2. Using #extra_requirements:: If you want to combine Windmill's automatic inference with pinned dependencies, use the #extra_requirements: comment:
#extra_requirements:
#dependency==0.4
import pandas
import dependency
def main(...):
...
#extra_requirements:
#dependency==0.4
import pandas
import dependency
def main(...):
...
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
WWindmill
Created by rubenf on 8/18/2024 in #general
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
WWindmill
Created by rubenf on 8/18/2024 in #general
how does one pin the python dependencies
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
4 replies
WWindmill
Created by rubenf on 7/24/2024 in #general
how do I share logic between scripts
Feel free to tag @Ask Inkeep with additional questions.
5 replies
WWindmill
Created by rubenf on 7/24/2024 in #general
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
WWindmill
Created by rubenf on 7/24/2024 in #general
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:
# u/user/common_logic
def foo():
print('Common logic!')

# u/user/custom_script
from u.user.common_logic import foo

def main():
return foo()
# u/user/common_logic
def foo():
print('Common logic!')

# u/user/custom_script
from u.user.common_logic import foo

def main():
return foo()
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:
import { main as foo, util } from '../my_script_path.ts';
import { main as foo, util } from '../my_script_path.ts';
5 replies
WWindmill
Created by rubenf on 7/24/2024 in #general
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
WWindmill
Created by rubenf on 7/24/2024 in #general
how do I share logic between scripts
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
5 replies
WWindmill
Created by rubenf on 7/5/2024 in #general
how do I get and set custom flow states
Feel free to tag @Ask Inkeep with additional questions.
6 replies
WWindmill
Created by rubenf on 7/5/2024 in #general
how do I get and set custom flow states
(1) Remember that to use these functions, you need to import the wmill client library. For TypeScript, you would use import * as wmill from "windmill-client@1.297.0", and for Python, you would include #extra_requirements: #wmill==1.297.0 at the top of your script. (3) (1) Custom flow states allow you to set and retrieve values from any step of a flow, and they will be available globally within the flow. This feature was introduced in Windmill version v1.296.0. (2)
6 replies
WWindmill
Created by rubenf on 7/5/2024 in #general
how do I get and set custom flow states
Answer To get and set custom flow states in Windmill, you can use the setFlowUserState and getFlowUserState functions. These functions allow you to store and retrieve data across steps in a flow. Here's how you can use them: 1. Setting a custom flow state: You can use the setFlowUserState function to set a value for a given key. (1)
import * as wmill from "windmill-client@1.297.0"
export async function main(x: string) {
await wmill.setFlowUserState("FOO", 42)
return await wmill.getFlowUserState("FOO")
}
import * as wmill from "windmill-client@1.297.0"
export async function main(x: string) {
await wmill.setFlowUserState("FOO", 42)
return await wmill.getFlowUserState("FOO")
}
2. Getting a custom flow state: You can use the getFlowUserState function to retrieve a value for a given key. The custom flow states are stored in the flow state itself and have the same lifetime as the flow job. It's important to note that custom flow states are a powerful feature when passing data as output/input is not feasible, and using getResource/setResource might clutter the workspace or create an inconvenient user experience. These functions are supported in both TypeScript and Python. (2) Here's an example in Python:
import wmill
#extra_requirements:
#wmill==1.297.0
def main(x: str):
wmill.set_flow_user_state("foobar", 43)
return wmill.get_flow_user_state("foobar")
import wmill
#extra_requirements:
#wmill==1.297.0
def main(x: str):
wmill.set_flow_user_state("foobar", 43)
return wmill.get_flow_user_state("foobar")
6 replies
WWindmill
Created by rubenf on 7/5/2024 in #general
how do I get and set custom flow states
----------------------------- While I generate an answer, here are some sources that might be helpful: * Within Windmill: Not recommended * Architecture and Data Exchange * Resources and Resource Types * set flow user state POST /w/{workspace}/jobs/flow/user_states/{id}/{key} -----------------------------
6 replies
WWindmill
Created by rubenf on 7/5/2024 in #general
how do I get and set custom flow states
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
6 replies
WWindmill
Created by pupperino on 6/25/2024 in #help
Google Auth Tokens Exposed?
Please tag me in threads that I was a part of from the start.
20 replies
WWindmill
Created by rubenf on 5/8/2024 in #general
relative imports in python
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:
# if common_logic is a script in the same folder or user-space
from .common_logic import foo
# otherwise, if you need to access the folder 'folder'
from ..folder.common_logic import foo
# if common_logic is a script in the same folder or user-space
from .common_logic import foo
# otherwise, if you need to access the folder 'folder'
from ..folder.common_logic import foo
- 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.
3 replies
WWindmill
Created by rubenf on 5/8/2024 in #general
relative imports in python
----------------------------- 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 -----------------------------
3 replies
WWindmill
Created by rubenf on 5/8/2024 in #general
relative imports in python
Thanks for tagging me @rubenf. I'll look through relevant sources and get back to you shortly.
3 replies
WWindmill
Created by rubenf on 5/8/2024 in #general
how do you set and get flow user states
Glad I could be helpful. Feel free to create a new thread with any new questions you may have.
4 replies