Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

change context variable on CLI dispatch

136 views
Skip to first unread message

William Eguienta

unread,
Jul 22, 2020, 6:18:43 AM7/22/20
to gaffer-dev
Hi,
I'm looking for a way to specify a context variable in an existing template script but I don't catch how it should be set
from what I see, with gaffer execute we have the -context option that allow that but I don't see any equivalent for dispatch
do I have to create a contextvariable node then force the dispatch to edit it's value or there is a more global way to do it ?
thanks

rupert thorpe

unread,
Jul 22, 2020, 6:31:07 AM7/22/20
to gaffe...@googlegroups.com
you could use environment variables for this I think.

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gaffer-dev/a730c7c7-d91e-4118-9e45-3298f6688758n%40googlegroups.com.

William Eguienta

unread,
Jul 23, 2020, 1:07:13 AM7/23/20
to gaffer-dev
hi, As i'm not using a global context variable, it doesn't seems to work (or I've missed something)
do you have any example of it please ?


Le mercredi 22 juillet 2020 12:31:07 UTC+2, rupert thorpe a écrit :
you could use environment variables for this I think.

On Wed, Jul 22, 2020 at 11:18 AM William Eguienta <kaiz3...@gmail.com> wrote:
Hi,
I'm looking for a way to specify a context variable in an existing template script but I don't catch how it should be set
from what I see, with gaffer execute we have the -context option that allow that but I don't see any equivalent for dispatch
do I have to create a contextvariable node then force the dispatch to edit it's value or there is a more global way to do it ?
thanks

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffe...@googlegroups.com.

William Eguienta

unread,
Jul 23, 2020, 1:42:36 AM7/23/20
to gaffer-dev
I have also tried to set variable by gaffer env :
gaffer env -arguments asset=TEST dispatch -script /mnt/out/lookdev_template_v02.gfr -tasks Render_Lightrigs -gui

that result "so such file or directory", but the same process with "gaffer" instead of "dispatch" works well (removing dispatch only options)
gaffer env -arguments asset=TEST gaffer /mnt/out/lookdev_template_v02.gfr

the dispatch works without the arguments param and outside of gaffer env
so I guess that in gaffer env, dispatch needs something more to work ( or it's a bug ? )

John Haddon

unread,
Jul 23, 2020, 2:56:42 AM7/23/20
to gaffe...@googlegroups.com
On Thu, Jul 23, 2020 at 6:42 AM William Eguienta <kaiz3...@gmail.com> wrote:
I have also tried to set variable by gaffer env :
gaffer env -arguments asset=TEST dispatch -script /mnt/out/lookdev_template_v02.gfr -tasks Render_Lightrigs -gui

that result "so such file or directory", but the same process with "gaffer" instead of "dispatch" works well (removing dispatch only options)
gaffer env -arguments asset=TEST gaffer /mnt/out/lookdev_template_v02.gfr

the dispatch works without the arguments param and outside of gaffer env
so I guess that in gaffer env, dispatch needs something more to work ( or it's a bug ? )

`gaffer env` is the same as `env` in that it can run any command line you give it. In your dispatch example, you are telling it to run a command called `dispatch`, which doesn't exist. You would need to tell it to run `gaffer dispatch` instead. Also note that you don't need the additional effects of `gaffer env` here - just `env` would be fine. So I think this should work :

`env asset=TEST gaffer dispatch -script /mnt/out/lookdev_template_v02.gfr -tasks Render_Lightrigs -gui`

William Eguienta

unread,
Jul 23, 2020, 6:44:12 AM7/23/20
to gaffer-dev
thank you John, i see my rookie mistake
cheers

William Eguienta

unread,
Jan 2, 2025, 12:03:55 PMJan 2
to gaffer-dev
Hi,
I revive this old thing as I have the same problem on windows
I'm not able to use env to dispatch with variables
i tried with gaffer env (just "env" doesn't work on windows on my side) :
set assetpath=D:\Desktop\maya_1.usda
set renderpath=D:\Desktop\output.usda
set scriptpath=W:\DOTHEFILM\Templates\Gaffer\sets_gen.gfr

gaffer env assetpath=%assetpath% renderpath=%renderpath% gaffer dispatch -script %scriptpath% -tasks LocalDispatcher1 -dispatcher Local -settings -dispatcher.frameRange '"1-1"' -dispatcher.framesMode 2
Also without substitution:
gaffer env assetpath=D:\Desktop\maya_1.usda renderpath=D:\Desktop\output.usda gaffer dispatch -script W:\...\sets_gen.gfr -tasks LocalDispatcher1 -dispatcher Local -settings -dispatcher.frameRange '"1-1"' -dispatcher.framesMode 2
gaffer env assetpath=D:\Desktop\maya_1.usda renderpath=D:\Desktop\output.usda gaffer dispatch -script W:\...\sets_gen.gfr -tasks LocalDispatcher1 -dispatcher Local -settings -dispatcher.frameRange '"1-1"' -dispatcher.framesMode 2

i have a file not found error
using the same paths with a more simple gaffer execute commands works as expected

any idea what is missing ?
thanks

Daniel Dresser

unread,
Jan 2, 2025, 7:25:35 PMJan 2
to gaffer-dev
`env` is just a default linux shell tool for running a process with env vars set ... I would assume something similar would exist in Windows, but I don't know about that.

`gaffer env` is a Gaffer tool for running a procress in Gaffer's environment, but it does happen to have an argument for setting env vars, so I guess it should work to use it this way. The syntax is different though, you need to include the "-arguments" flag:
`gaffer env -arguments assetpath=D:\...`

-Daniel

William Eguienta

unread,
Jan 4, 2025, 11:43:59 AMJan 4
to gaffer-dev
Hi Daniel,
I tried that too once without success,
with or without I have the same error feedback
the documentation says :
gaffer env [name=value ...] [utility [argument ...]]
so a was thinking the flag is not requested, I maybe miss something

Daniel Dresser

unread,
Jan 4, 2025, 1:59:05 PMJan 4
to gaffer-dev
Oh, apologies. I was just going on what had been said earlier in the thread, instead of trying it myself.

Given that your syntax seems correct then, I'm guessing that one of your paths that is being substituted in has a space in it?

For example if assetpath = "C:\Folder With Spaces\My Asset", and it gets substituted in without quoting, then I would expect:

gaffer env assetpath=%assetpath% gaffer

To get substituted like this:

gaffer env assetpath=C:\Folder With Spaces\My Asset gaffer

Resulting in an error like:

gaffer env : With Spaces\My Asset gaffer : The system cannot find the file specified

Because the spaces get interpreted as breaks between different arguments. ( You haven't mentioned if the error you're seeing reports which file isn't found? )

I don't know what the conventions are for handling command line arguments with spaces on Windows.

-Daniel

William Eguienta

unread,
Jan 6, 2025, 4:47:27 AMJan 6
to gaffer-dev
Hey Daniel, 
my path is without any spaces, i posted the exact one used for testing
sadly, interpreter don't point any specific path, just returns that file not found without anything more
the thing is that using gaffer dispatch without 'gaffer env', it's works as expected, with the exact same argument so i guess it's not the issue
so i don't see what the problem can be
thanks

Daniel Dresser

unread,
Jan 6, 2025, 1:50:44 PMJan 6
to gaffer-dev
Sorry I haven't been more helpful ... this feels like it's less of a Gaffer problem, and more of just a Windows shell scripting problem ... I don't know that much about shell scripting on Windows.

If those are your literal command lines, then the file name you're trying to load is "W:\...\sets_gen.gfr"? That syntax looks very odd to me, combining a drive name with a relative path, but I guess that's probably just Windows syntax? Actually, thinking about it, it's plausible that using "gaffer env" could impact the current directory - have you tried with an absolute path for your Gaffer script?

-Daniel

William Eguienta

unread,
Jan 9, 2025, 3:24:20 AMJan 9
to gaffer-dev
hey, 
oh sorry, forgot this one :  W:\...\sets_gen.gfr is shorten by me in my email, because the path is quite long...

eric...@gmail.com

unread,
Jan 10, 2025, 5:44:26 PMJan 10
to gaffer-dev
Do you definitely need your variables to be environment variables? If you can instead use context variables, something like this should work with the `dispatch` app rather than the `env` app :

gaffer dispatch -script  W:\...\sets_gen.gfr -tasks LocalDispatcher1 -dispatcher Local -settings -"dispatcher.frameRange" '"1-1"' -"dispatcher.framesMode" 2 -"context.renderPath" "'C:/Users/eric.HYPOTHETICAL/Desktop/cube_scaled.usda'"

Be very careful about the quotes with the `-settings` argument. The key (dispatcher:framesMode, etc.) needs to be in double quotes, after the `-`. So `-"dispatcher.framesMode"`. The value, for strings at least, needs to be in single quotes within double quotes. So `"'value'"`.

eric...@gmail.com

unread,
Jan 10, 2025, 5:45:58 PMJan 10
to gaffer-dev
And those examples of quoting are enclosed in backticks, I thought Google Groups would translate that.

Should be -"dispatcher.framesMode" and "'value'" when leaving out the backticks.

William Eguienta

unread,
Jan 18, 2025, 12:25:00 AMJan 18
to gaffe...@googlegroups.com
Hey Eric, 
that's a good idea for a simple value, but how would you set a wedge with stringdata ? having -Wedge.strings '"Cube"'
for example will result  an error as it's not a StringVectorDataPlug

about quotes, sure, I will add them when it will be called from python, for now I test directly in cmd
thanks

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.

eric...@gmail.com

unread,
Jan 22, 2025, 2:49:24 PMJan 22
to gaffer-dev
The values for the variables are translated into Python values by using Python's `eval`, (which explains why strings need to be in quotes, otherwise they are interpreted as variable names). So to pass a vector of strings to your wedge, use -"Wedge.strings" 'IECore.StringVectorData( [ \"string1\", \"string2\" ] )'

That works for me in Powershell. I think the escape character in the regular command line on Windows is ^ instead of \?
Reply all
Reply to author
Forward
0 new messages