gslone
gslone•9mo ago

Script to hub: How to pass in Ressources?

Hey, I was thinking about publishing a python script to Hub. My scripts need a config in the form of a ressource (for authentication etc.). I've seen how python scripts do this on the hub - they pass in a dict and the metadata states that this dict is of format "resource-<resource_type>" (also documented here: https://www.windmill.dev/docs/core_concepts/json_schema_and_parsing#script-parameters-to-json-schema). I can't get it to work. In my Script, I go to "Settings" -> Autogenerated UI -> "Customize" my parameter, and choose a ressource type. When I save this, it reverts back to just being an object. All other changes (like parameter descriptions etc.) persist. Could this be a bug or am I doing it wrong?
JSON Schema and Parsing | Windmill
JSON Schema is a key component in Windmill for defining the structure and validation rules of JSON data. Windmill uses the JSON Schema standard (2020-12 version) for specifying the schema.
8 Replies
rubenf
rubenf•9mo ago
You need to use a type alias MyType = dict def main(foo: MyType)
gslone
gsloneOP•9mo ago
Got it to work now. My ressource type is called "c_ldap". I have now found out that it works if I name my type alias exactly like my ressource type, it works. Is this intended?
rubenf
rubenf•9mo ago
yes
gslone
gsloneOP•9mo ago
Alright, thanks! During the submission process, I guess ressource type names have to be shuffled around, since they would become an "official" ressource type without the c_ prefix. This will be done by you guys?
rubenf
rubenf•9mo ago
you can also submit the resource type for approval and you can have a resource type without a c_ during the resource type creation process
gslone
gsloneOP•9mo ago
done 🙂
rubenf
rubenf•9mo ago
thanks, approved both
gslone
gsloneOP•9mo ago
Thanks for the help! Submitted the other script I already had.

Did you find this page helpful?