I’m looking for a way to programmatically supply custom context data to the QML UI before it runs collection. Preferably, this custom data would be present at every recreation of a context instance whenever the reset button is pressed.
I know there is a way to supply this through the command line interface as described in this post: $ pyblish --data key value --data key2 value2 publish
But, my current implementation does some data gathering pre-pyblish and I need to send it to be available in the context at all times, no matter the collection plugins being run. Because I’m already doing so much with python beforehand, I feel it would be cleaner to just set this data programmatically and make a call to open the GUI without having to construct a subprocess string to execute.
Just curious if there is anything similar to the command line --data flag, but in the pyblish/pyblish_qml libraries?
Hm, when you say “QML” do you mean the language or the Pyblish GUI? Assuming you mean the GUI, I’d use a collector for this. Make one specifically to fetch whatever data you require for subsequent collectors, and have it be called first and always. From there, you effectively have a Python script that’ll run before any publish to gather any kind of data you need for the context.
As for your suggestion with the collector plugins, that’s what I’m currently doing. The issue I’m facing is as follows:
I have a stand alone Pyblish tool (qml gui) that runs a collector plugin which searches for and identifies “asset root folders” and adds them as instances (each asset root folder is its own instance). The catch-22 is I don’t want to hard code into the collector plugin the starting path that the collection starts from. I want to make one “Asset Folder Collector” plugin and be able to change its ‘start folder’ variable.
How can I programmatically (not through command line) pass a ‘start folder’ variable to the context?
Whenever the qml gui starts up, it creates a new Context obj from scratch and the same for when clicking on the reset button. So with a brand new context obj, how do I pass it data to allow the collector plugin to know where to start its search from?
PS: I’m able to make some minor changes to the library to support this, but I want to make sure I’m not overengineering anything or that I’m not missing a glaringly obvious way to do this.
Hm, could you not simply have a pre-collector, something that always runs first, that looks for your asset folder and stores it in the context for subsequent collectors to look at?
Generally, the environment is good at passing things into a new process so long as what you need can be represented as strings. It doesn’t sound like you need it, but you could edit the source; the crux being that it’d be more challenging for me and others to help given we won’t know what your source would look like.