Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Houdini: Submit houdini patch version to deadline#5384

Closed
MustafaJafar wants to merge 11 commits intodevelopfrom
enhancement/OP-6381_submit-houdini-patch-version-to-Deadline
Closed

Houdini: Submit houdini patch version to deadline#5384
MustafaJafar wants to merge 11 commits intodevelopfrom
enhancement/OP-6381_submit-houdini-patch-version-to-Deadline

Conversation

@MustafaJafar
Copy link
Copy Markdown
Member

@MustafaJafar MustafaJafar commented Aug 2, 2023

Changelog Description

By default houdini deadline submission includes major.minor version numbers only

As requested, to include patch version as follows major.minor.patch
image

Additional Info

This modifications require to update houdini deadline plugin param file.
I have added a mini guide in docs

Testing notes:

  1. modify DeadlineRepo\plugins\Houdini\Houdini.param as suggested
  2. submit deadline jobs from OP

@ynbot
Copy link
Copy Markdown
Contributor

ynbot commented Aug 2, 2023

@ynbot ynbot added size/XL Denotes a PR changes 1500-2499 lines, ignoring general files type: enhancement Enhancements to existing functionality host: Houdini module: Deadline AWS Deadline related features labels Aug 2, 2023
@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Aug 2, 2023

I'm not a fan of including our own custom full Houdini plug-in for Deadline. It can easily get outdated compared to Deadline updates and I suspect it'll be hard to keep track of what changes were made for OpenPype and which were made due to being outdated - especially if currently all that's changed is the .param file, right? It feels quite bloated.


I'd say instead of this, couldn't we instead just rely on AVALON_APP_NAME environment value. That would actually result in a local executable to run, right - and would then actually also be using the one defined by OpenPype? Would it be possible instead to write logic that just replaces the Houdini executable that will get triggered to begin with with the one from solely that variable?

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Aug 2, 2023

couldn't we instead just rely on AVALON_APP_NAME environment value.

I'm not sure how to tell deadline to resolve AVALON_APP_NAME to get the right executable.
may it can call OP wrapper like OCIO functions.

replaces the Houdini executable that will get triggered to begin with with the one from solely that variable?

I think this will require modifing plugins\Houdini\Houdini.py _which will require copying Houdini plugin without asking users to add any modifications because they were made once in OP settings _

HythonExecutable

    def RenderExecutable( self ):
        version = self.GetPluginInfoEntryWithDefault( "Version", "18.5" ).replace( ".", "_" )
        return self.GetRenderExecutable( "Houdini" + version + "_Hython_Executable", "Houdini " + version)

SimTracker

    version = self.GetPluginInfoEntryWithDefault( "Version", "18.5" ).replace( ".", "_" )
    # Retrieve houdini simtracker executable
    simTracker = self.GetRenderExecutable( "Houdini" + version + "_SimTracker", "Houdini " + version + " SimTracker")

Maybe we can just send the executable path and tell RenderExecutable to use it if exists
with a BIG NOTE that paths in deadline Configure Plugins UI will be ignored in favor of paths set in OP system settings.

    def RenderExecutable( self ):
        hou_exe = self.GetPluginInfoEntryWithDefault( "Houdini_exe", "" )
        if not hou_exe:
            version = self.GetPluginInfoEntryWithDefault( "Version", "18.5" ).replace( ".", "_" )
            hou_exe = self.GetRenderExecutable( "Houdini" + version + "_Hython_Executable", "Houdini " + version)
        return hou_exe 

same for SimTracker

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Aug 2, 2023

Ah, yes. That doesn't help too much then either. It's too bad we need this much 'changing' of Deadline native functionality. It basically means we'll now also start maintaining Deadline's Houdini plug-in with OpenPype which is not a nice thing to have added on our to-do lists. 🗡️

@mkolar mkolar added the sponsored Client endorsed or requested label Aug 2, 2023
@mkolar
Copy link
Copy Markdown
Member

mkolar commented Aug 2, 2023

Man I don't like any of this to be honest, but it is actual scenario. I haven't tried myself, but @mustafa-zarkash can we make it so it's backwards compatible with default houdini deadline plugin? The point is that for majority of studios major.minor is probably enough, considering we've only had one request for this and I'm no too keen on maintaining the full plulgin all the time. We could possibly just make sure we're able to send the patch version and give studio the option to maintain their own deadline plugin. It might accidentally creep the scope of houdini deadline maintenance for us.

@MustafaJafar
Copy link
Copy Markdown
Member Author

@mkolar I agree.

I think adding a toggle some where in settings so that admins can tell deadline publisher to send patch version or not with a big note that enabling this requirs modifying houdini.param with a mini guide about how to do so.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Aug 3, 2023

So I just learned that Deadline has a "Rez" plugin apparently, here are Deadline + Rez plugin. It uses the On Job Submitted event just to insert some Rez things to 'configure' things alright for the to be launched application. I suspect since Rez basically also builds up an environment that could supply e.g. a Houdini version that it might've tried to solve a similar issue? Maybe it's a decent reference at least as to what we can do without touching the Houdini plugin itself.

I would expect to be able to do something similar where we can e.g. in GlobalJobPreLoad or whatever initialize the relevant Application environment (or make the executable accessible in a way for example add the executable's folder to start of PATH env var) and have the Houdini plugin in Deadline settings just refer to houdini.exe instead of a full executable path.

That way we can influence how Deadline launches houdini, but don't need to modify Houdini plugin itself.

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Aug 3, 2023

@mkolar @BigRoy
So, your comments inspired me.
I have added Houdini deadline project settings with a little toggle to switch between major.minor and major.minor.patch
and it's False by default so everyone will act as usual.
whomever want enable it will be required to update only DeadlineRepo\plugins\Houdini\Houdini.param, I created a mini guide about how to do that but I don't know where to add it maybe to docs whenever I know how to do that!


I don't know what optional and active will do but I think they will be used by OptionalPyblishPluginMixin which is not used currently.

image

@moonyuet
Copy link
Copy Markdown
Member

moonyuet commented Aug 7, 2023

i tested with the 19.5.435 version of Houdini It doesn't work and gives the error below. (I guess this one is still in draft, right?)

=======================================================
Error
=======================================================
Error: RenderPluginException : GetConfigEntry: Attempted to access non-existent config key: Houdini19_5_435_Hython_Executable
   at Deadline.Plugins.DeadlinePlugin.GetConfigEntry(String key) (Python.Runtime.PythonException)
  File "C:\ProgramData\Thinkbox\Deadline10\workers\desktop-1u8vp0c\plugins\64d0ceedb225af410c82de6e\Houdini.py", line 78, in RenderExecutable
    houdiniExeList = self.GetConfigEntry( "Houdini" + version + "_Hython_Executable" )
   at Python.Runtime.Dispatcher.Dispatch(ArrayList args)
   at __FranticX_GenericDelegate0`1\[\[System_String\, System_Private_CoreLib\, Version=4_0_0_0\, Culture=neutral\, PublicKeyToken=7cec85d7bea7798e\]\]Dispatcher.Invoke()
   at FranticX.Processes.ManagedProcess.RenderExecutable()
   at Deadline.Plugins.DeadlinePlugin.RenderExecutable()
   at FranticX.Processes.ManagedProcess.Execute(Boolean waitForExit)
   at Deadline.Plugins.PluginWrapper.RenderTasks(Task task, String& outMessage, AbortLevel& abortLevel)

=======================================================
Type
=======================================================
RenderPluginException

=======================================================
Stack Trace
=======================================================
   at Deadline.Plugins.SandboxedPlugin.d(DeadlineMessage bgj, CancellationToken bgk)
   at Deadline.Plugins.SandboxedPlugin.RenderTask(Task task, CancellationToken cancellationToken)
   at Deadline.Slaves.SlaveRenderThread.c(TaskLogWriter ajq, CancellationToken ajr)

=======================================================
Log
=======================================================
2023-08-07 19:01:23:  0: Render Thread - Render State transition from = 'ReceivedTask' to = 'Other'
2023-08-07 19:01:23:  0: Loading Job's Plugin timeout is Disabled
2023-08-07 19:01:23:  0: SandboxedPlugin: Render Job As User disabled, running as current user 'Kayla'
2023-08-07 19:01:25:  0: Loaded plugin Houdini
2023-08-07 19:01:25:  0: Executing plugin command of type 'Initialize Plugin'
2023-08-07 19:01:25:  0: INFO: Executing plugin script 'C:\ProgramData\Thinkbox\Deadline10\workers\desktop-1u8vp0c\plugins\64d0ceedb225af410c82de6e\Houdini.py'
2023-08-07 19:01:25:  0: INFO: Plugin execution sandbox using Python version 3
2023-08-07 19:01:25:  0: INFO: About: Houdini Plugin for Deadline
2023-08-07 19:01:25:  0: INFO: The job's environment will be merged with the current environment before rendering
2023-08-07 19:01:25:  0: Done executing plugin command of type 'Initialize Plugin'
2023-08-07 19:01:25:  0: Start Job timeout is disabled.
2023-08-07 19:01:25:  0: Task timeout is disabled.
2023-08-07 19:01:25:  0: Loaded job: new_project_ep_asset_v214.hiplc - redshift_ropMain (64d0ceedb225af410c82de6e)
2023-08-07 19:01:25:  0: Executing plugin command of type 'Start Job'
2023-08-07 19:01:25:  0: DEBUG: S3BackedCache Client is not installed.
2023-08-07 19:01:25:  0: INFO: Executing global asset transfer preload script 'C:\ProgramData\Thinkbox\Deadline10\workers\desktop-1u8vp0c\plugins\64d0ceedb225af410c82de6e\GlobalAssetTransferPreLoad.py'
2023-08-07 19:01:25:  0: INFO: Looking for legacy (pre-10.0.26) AWS Portal File Transfer...
2023-08-07 19:01:25:  0: INFO: Looking for legacy (pre-10.0.26) File Transfer controller in C:/Program Files/Thinkbox/S3BackedCache/bin/task.py...
2023-08-07 19:01:25:  0: INFO: Could not find legacy (pre-10.0.26) AWS Portal File Transfer.
2023-08-07 19:01:25:  0: INFO: Legacy (pre-10.0.26) AWS Portal File Transfer is not installed on the system.
2023-08-07 19:01:25:  0: Done executing plugin command of type 'Start Job'
2023-08-07 19:01:25:  0: Plugin rendering frame(s): 21-24
2023-08-07 19:01:25:  0: Render Thread - Render State transition from = 'Other' to = 'Rendering'
2023-08-07 19:01:25:  0: Executing plugin command of type 'Render Task'
2023-08-07 19:01:25:  0: INFO: Starting Houdini Job
2023-08-07 19:01:25:  0: INFO: Stdout Redirection Enabled: True
2023-08-07 19:01:25:  0: INFO: Stdout Handling Enabled: True
2023-08-07 19:01:25:  0: INFO: Popup Handling Enabled: True
2023-08-07 19:01:25:  0: INFO: QT Popup Handling Enabled: False
2023-08-07 19:01:25:  0: INFO: WindowsForms10.Window.8.app.* Popup Handling Enabled: False
2023-08-07 19:01:25:  0: INFO: Using Process Tree: True
2023-08-07 19:01:25:  0: INFO: Hiding DOS Window: True
2023-08-07 19:01:25:  0: INFO: Creating New Console: False
2023-08-07 19:01:25:  0: INFO: Running as user: Kayla
2023-08-07 19:01:25:  0: Done executing plugin command of type 'Render Task'

=======================================================
Details
=======================================================
Date: 08/07/2023 19:01:29
Frames: 21-24
Elapsed Time: 00:00:00:06
Job Submit Date: 08/07/2023 19:01:01
Job User: kayla
Average RAM Usage: 16114520064 (48%)
Peak RAM Usage: 16114520064 (48%)
Average CPU Usage: 1%
Peak CPU Usage: 2%
Used CPU Clocks (x10^6 cycles): 1057
Total CPU Clocks (x10^6 cycles): 105649

=======================================================
Worker Information
=======================================================
Worker Name: DESKTOP-1U8VP0C
Version: v10.1.22.5 Release (919d43564)
Operating System: Windows 11 Pro
Running As Service: No
Machine User: Kayla
IP Address: 192.168.50.249
MAC Address: 48:E7:DA:F4:8E:23
CPU Architecture: x64
CPUs: 16
CPU Usage: 6%
Memory Usage: 15.0 GB / 31.8 GB (47%)
Free Disk Space: 1.866 TB (460.553 GB on C:\, 1.416 TB on D:\)
Video Card: NVIDIA GeForce RTX 3070

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Aug 7, 2023

i tested with the 19.5.435 version of Houdini It doesn't work

To check if this PR is working we need to check the job parameters.
for example

image


Error: RenderPluginException : GetConfigEntry: Attempted to access non-existent config key: Houdini19_5_435_Hython_Executable

The thing is: by default deadline will complain about it can't find the houdin exe
so that admins have to update DeadlineRepo\plugins\Houdini\Houdini.param
I made a mini guide about it and I'm going to update the docs shortly (I didn't do so earlier because I didn't know where should I add this mini guide. )

In short: these blocks should added to houdini.param and replace <major>, <minor> and <patch> with the desired numbers

Hython Executable block

[Houdini<major>_<minor>_<patch>_Hython_Executable]
Label=Houdini <major>.<minor>.<patch> Hython Executable
Category=Render Executables
CategoryOrder=0
Type=multilinemultifilename
Index=14
Default=C:\Program Files\Side Effects Software\Houdini 19.0.000\bin\hython.exe;/Applications/Houdini/Houdini19.0.000/Frameworks/Houdini.framework/Versions/19.0.000/Resources/bin/hython;/opt/hfs19.0/bin/hython
Description=The path to the hython executable. It can be found in the Houdini bin folder.

Sim Tracker block

[Houdini<major>_<minor>_<patch>_SimTracker]
Label=Houdini <major>.<minor>.<patch> Sim Tracker File
Category=HQueue Simulation Job Options
CategoryOrder=1
Type=multilinemultifilename
Index=10
Default=C:\Program Files\Side Effects Software\Houdini 19.0.000\houdini\python3.7libs\simtracker.py;/Applications/Houdini/Houdini19.0.000/Frameworks/Houdini.framework/Versions/19.0.000/Resources/houdini/python3.7libs/simtracker.py;/opt/hfs19.0/houdini/python3.7libs/simtracker.py
Description=The path to the simtracker.py file that is used when distributing HQueue sim jobs. This file can be found in the Houdini install.

After Updating that file, you will find new entries to add houdini exe
image

@moonyuet
Copy link
Copy Markdown
Member

moonyuet commented Aug 7, 2023

i tested with the 19.5.435 version of Houdini It doesn't work

To check if this PR is working we need to check the job parameters. for example

image

Error: RenderPluginException : GetConfigEntry: Attempted to access non-existent config key: Houdini19_5_435_Hython_Executable

The thing is: by default deadline will complain about it can't find the houdin exe so that admins have to update DeadlineRepo\plugins\Houdini\Houdini.param I made a mini guide about it and I'm going to update the docs shortly (I didn't do so earlier because I didn't know where should I add this mini guide. )

In short: these blocks should added to houdini.param and replace <major>, <minor> and <patch> with the desired numbers

Hython Executable block

[Houdini<major>_<minor>_<patch>_Hython_Executable]
Label=Houdini <major>.<minor>.<patch> Hython Executable
Category=Render Executables
CategoryOrder=0
Type=multilinemultifilename
Index=14
Default=C:\Program Files\Side Effects Software\Houdini 19.0.000\bin\hython.exe;/Applications/Houdini/Houdini19.0.000/Frameworks/Houdini.framework/Versions/19.0.000/Resources/bin/hython;/opt/hfs19.0/bin/hython
Description=The path to the hython executable. It can be found in the Houdini bin folder.

Sim Tracker block

[Houdini<major>_<minor>_<patch>_SimTracker]
Label=Houdini <major>.<minor>.<patch> Sim Tracker File
Category=HQueue Simulation Job Options
CategoryOrder=1
Type=multilinemultifilename
Index=10
Default=C:\Program Files\Side Effects Software\Houdini 19.0.000\houdini\python3.7libs\simtracker.py;/Applications/Houdini/Houdini19.0.000/Frameworks/Houdini.framework/Versions/19.0.000/Resources/houdini/python3.7libs/simtracker.py;/opt/hfs19.0/houdini/python3.7libs/simtracker.py
Description=The path to the simtracker.py file that is used when distributing HQueue sim jobs. This file can be found in the Houdini install.

After Updating that file, you will find new entries to add houdini exe image

Would be great if you can have a doc to tell the 19.5 users how to add the params into the Houdini (which file to edited etc.) so that it would update the plugin configuration.

@MustafaJafar
Copy link
Copy Markdown
Member Author

@moonyuet I have updated the docs.

@moonyuet
Copy link
Copy Markdown
Member

moonyuet commented Aug 7, 2023

So I just learned that Deadline has a "Rez" plugin apparently, here are Deadline + Rez plugin. It uses the On Job Submitted event just to insert some Rez things to 'configure' things alright for the to be launched application. I suspect since Rez basically also builds up an environment that could supply e.g. a Houdini version that it might've tried to solve a similar issue? Maybe it's a decent reference at least as to what we can do without touching the Houdini plugin itself.

I would expect to be able to do something similar where we can e.g. in GlobalJobPreLoad or whatever initialize the relevant Application environment (or make the executable accessible in a way for example add the executable's folder to start of PATH env var) and have the Houdini plugin in Deadline settings just refer to houdini.exe instead of a full executable path.

That way we can influence how Deadline launches houdini, but don't need to modify Houdini plugin itself.

I just saw your comment now. Adding param can be messy if the users modify Houdini plugin especially when switching from different projects with different Houdini versions(some renderers such as Arnold and Redshift can only be used in certain patch versions). I need to download two different versions of Houdini to test things and I have to make sure to download the right minor version.
After looking at the Rez link, I am thinking if we can make a customized plugin or edit the current one we have to find the executable plugin by patch version and use it for rendering. This is not only for Houdini but for other dccs. (Could be a later talk if it is too time-consuming)

@MustafaJafar
Copy link
Copy Markdown
Member Author

I'm wondering now

  1. Does this mean that any application environment variables (like mine above) won't be set in the deadline job ?
  2. Will your proposed solution work with other software e.g. maya or nuke ?

With that - I suspect it'll launch houdini's hython by just the hython name from the Houdini plugin in deadline.

  1. Does the GlobalJobPreLoad.py run before GetRenderExecutable in houdini plugin ?
    I think the execution order is like this:
    1. GetRenderExecutable which I think returns the full path of the executable not just hython
    2. Run GlobalJobPreLoad which update PATH after few modifications
    3. Run Executable returned by GetRenderExecutable

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Aug 11, 2023

More details here.

  1. Does this mean that any application environment variables (like mine above) won't be set in the deadline job ?

Hmm, not really. Sort of. Usually a process started from the plugin might inherit the environment from the Deadline plugin too - but it's not ALWAYS the case because a plugin can disable that behavior for processes it executes, see IncludeEnvironment and UseJobEnvironmentOnly. That's why if you basically want Hython to start with the env vars the DeadlinePlugin.SetProcessEnvironmentVariable is the recommended approach because it's about explicitly passing it to the processes run from that Deadline plugin.

That's why I recommended the approach to keep the original behavior (still use DeadlinePlugin.SetProcessEnvironmentVariable) but only add the call to also set PATH for the deadline job plug-in so it can find the executables as we need by adding:

        if "PATH" in contents:
            deadlinePlugin.SetEnvironmentVariable("PATH", contents["PATH"])

Which I believe is quite similar to:

        if "PATH" in contents:
            os.environ["PATH"] = contents["PATH"]

Except that deadlinePlugin.SetEnvironmentVariable might not change the environment for the global job pre load script's environment.

Actually with that said, if deadlinePlugin.SetEnvironmentVariable still doesn't work to find the houdini executable I'm pretty sure that os.environ["PATH"] = contents["PATH"] then will.

  1. Will your proposed solution work with other software e.g. maya or nuke ?

Yes, I'm quite certain it will.

  1. Does the GlobalJobPreLoad.py run before GetRenderExecutable in houdini plugin ?

Yes, GlobalJobPreLoad runs before the render plugin for the job starts.

GetRenderExecutable which I think returns the full path of the executable not just hython

It does return the full path to hython, but because it searches in PATH for that executable - and we've prepended it to PATH it should be the first entry it finds and thus return the one we want.

@moonyuet
Copy link
Copy Markdown
Member

moonyuet commented Aug 11, 2023

@BigRoy , I did a check for the env by adding the test script(the script I used for checking the remote_publish but it still checks the sys.path) into openpype/scripts and add the script into the preJobScripts as job info parameter in Houdini deadline submission script.
It seems that it doesn't include any houdini environment variable in {PATH}

2023-08-11 22:18:29,584 - Deadline_Feedback_Log - DEBUG - (<class 'ModuleNotFoundError'>, ModuleNotFoundError("No module named 'remote_publish'"), <traceback object at 0x00000224C88FA308>)
2023-08-11 22:18:29,584 - Deadline_Feedback_Log - DEBUG - ['C:\\Users\\Kayla\\AppData\\Local\\Thinkbox\\Deadline10\\pythonAPIs\\2022-07-12T182241.0000000Z', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\lib', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\lib\\site-packages', 'C:\\Users\\Kayla\\Texture_Importer\\04_ui', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\python37.zip', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\Lib', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\DLLs', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\DLLs\\Release', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\Lib\\plat-win32', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\python3\\Lib\\lib-tk', 'C:\\Program Files\\Thinkbox\\Deadline10\\bin\\']

The script I used.

try:
    import remote_publish
    remote_publish.remote_publish()

except Exception:
    import sys

    import logging
    import logging.handlers

    filename = "D:/deadline.log"

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")

    handler = logging.handlers.RotatingFileHandler(filename, mode = 'w', backupCount = 5)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter)
    logger.addHandler(ch)
    exc_info = sys.exc_info()

    logger = logging.getLogger('Deadline_Feedback_Log')
    logger.debug(exc_info)
    logger.debug(sys.path)

    sys.exit(1)

Maybe the env can be set up by adding the script which sets up the environment variable for {PATH} as PreJobScript in Houdini deadline submission. It will do the job right before all the rendering actions.
image
If it still doesn't work, we need to adopt the original plan first and create the issue to discuss the way to enhance the workflow.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Aug 11, 2023

It seems that it doesn't include any houdini environment variable in {PATH}

Note that sys.path != os.environ["PATH"]. It's closer to os.environ["PYTHONPATH"] but even that isn't entirely true; it's just that on Python launch I believe it adds PYTHONPATH to sys.path but changing os.environ["PYTHONPATH"] during the current session doesn't change what's available on sys.path.

Anyway, we're not looking to adjust sys.path but os.environ["PATH"] as that defines where executables are being searched.
In short, you're logging the wrong value.


Other than that I have no idea what you're trying to do with the running it as pre job script.

@moonyuet
Copy link
Copy Markdown
Member

moonyuet commented Aug 11, 2023

It seems that it doesn't include any houdini environment variable in {PATH}

Note that sys.path != os.environ["PATH"]. It's closer to os.environ["PYTHONPATH"] but even that isn't entirely true; it's just that on Python launch I believe it adds PYTHONPATH to sys.path but changing os.environ["PYTHONPATH"] during the current session doesn't change what's available on sys.path.

i dont mean they are the same. maybe i should explain better, what i mean is like it seems that both sys path and os.getenv("path") (see mustafa's comment) dont store the hython directory coming from the related environment set in the OP settings.
i dont think we can use it to access the destined hython executable.

Anyway, we're not looking to adjust sys.path but os.environ["PATH"] as that defines where executables are being searched. In short, you're logging the wrong value.

I can check with logging but i dont really think it is there.

For prejob script, I mean we can use the prejobscript to set up the environment for setting up the path for hython exeuctable

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Aug 12, 2023

2. Will your proposed solution work with other software e.g. maya or nuke ?

Yes, I'm quite certain it will.

As long as this proposed solution will work with other DCCs, then we should discuss it a in different place like Enhancement Request in issues or ideas section in forums

This feature request is Houdini specific, and I really don't know if it's needed to have a general solution that works with other DCCs

If it still doesn't work, we need to adopt the original plan first and create the issue to discuss the way to enhance the workflow.

I agree with Kayla we need to find a solution that works in the first place to satisfy the current need
then we can discuss how to enhance it.

I'd say that if this works - then this PR should be closed because that means you can do the exact same thing without the need of this PR. Less code and tweaks to maintain and it's a sensible approach from an admin perspective and could eventually work the same way using e.g. Rez.

I think having the two options will be nice, which adds some flexibility as admins would be able to choose from two solutions

  • one is very smart "Updating PATH" (it also works for all DCCs)
  • other one is very clear (from my perspective as a beginner) "Updating param file and toggling a setting in UI" (it only works in Houdini)

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 11, 2023

i dont mean they are the same. maybe i should explain better, what i mean is like it seems that both sys path and os.getenv("path") (see mustafa's comment) dont store the hython directory coming from the related environment set in the OP settings.
i dont think we can use it to access the destined hython executable.

Have you tried changing the OpenPype GlobalJobPreLoad to use DeadlinePlugin.SetEnvironmentVariable as opposed to DeadlinePlugin.SetProcessEnvironmentVariable for the PATH environment variables supplied by OpenPype.

If that works for you it's really the simplest use case.

  1. Set the application's root PATH in applications env settings.
  2. In Deadline set the executable to just the executable name instead of full path.
  3. Profit 💲

  • other one is very clear (from my perspective as a beginner) "Updating param file and toggling a setting in UI" (it only works in Houdini)

I've seen many beginners trip over the Deadline Param files (and even breaking them hehe). We'd need to clearly document how to do it, but I'd say if we need to do that anyway the other more generalized way I described is just as clear and doesn't require us to maintain a custom Houdini params/plugin, etc.

@MustafaJafar
Copy link
Copy Markdown
Member Author

Have you tried changing the OpenPype GlobalJobPreLoad to use DeadlinePlugin.SetEnvironmentVariable as opposed to DeadlinePlugin.SetProcessEnvironmentVariable for the PATH environment variables supplied by OpenPype.

I'm going to try this.

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Sep 12, 2023

Hey, @BigRoy
I came back.

Setting PATH in OP settings

Here are my Openpype settings.
image

I printed PATH inside Houdini console and PATH was passed correctly.

>>> pprint(os.getenv("PATH").split(";"))
['C:\\PROGRA~1\\SIDEEF~1\\HOUDIN~1.403\\python39\\lib\\site-packages-forced\\PySide2',
 'C:/PROGRA~1/SIDEEF~1/HOUDIN~1.403/python39',
 'C:/Users/MUSTAF~1/DOCUME~1/houdini19.5/packages/HoudiniSubmitter/otls',
 '&',
 '&',
 'C:/PROGRA~1/SIDEEF~1/HOUDIN~1.403/bin',
 'C:/PROGRA~1/SIDEEF~1/HOUDIN~1.403/toolkit/bin',
 'C:/Program Files/Side Effects Software/Houdini 19.5.403/bin',
 'E:/Ynput/OpenPype/vendor/python/PySide2',
 'E:/Ynput/OpenPype/.venv/Scripts',
 'C:/Program Files (x86)/Common Files/Oracle/Java/javapath',
 'C:/ProgramData/Oracle/Java/javapath',
 'C:/Python27/Scripts',
 'C:/Python27',
 'C:/Program Files (x86)/Common Files/Intel/Shared '
 'Libraries/redist/intel64_win/compiler',
 'C:/Program Files (x86)/Common Files/Intel/Shared Files/cpp/bin/Intel64',
 'C:/WINDOWS/system32',
 'C:/WINDOWS',
 'C:/WINDOWS/System32/Wbem',
 'C:/WINDOWS/System32/WindowsPowerShell/v1.0',
 'C:/WINDOWS/System32/OpenSSH',
 'C:/Program Files/NVIDIA Corporation/NVIDIA NvDLISR',
 'C:/Program Files/Common Files/Autodesk Shared',
 'C:/Program Files/Microsoft SQL Server/120/Tools/Binn',
 'C:/WINDOWS/system32',
 'C:/WINDOWS',
 'C:/WINDOWS/System32/Wbem',
 'C:/WINDOWS/System32/WindowsPowerShell/v1.0',
 'C:/WINDOWS/System32/OpenSSH',
 'C:/Program Files/PuTTY',
 'C:/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit',
 'C:/Program Files (x86)/IVI Foundation/VISA/WinNT/Bin',
 'C:/Program Files (x86)/NVIDIA Corporation/PhysX/Common',
 'C:/Program Files/Git/cmd',
 'C:/Program Files/CodeBlocks/MinGW/bin',
 'C:/Program Files/Graphviz/bin',
 'C:/Users/Mustafa Taher/AppData/Local/Programs/Python/Python39/Scripts',
 'C:/Users/Mustafa Taher/AppData/Local/Programs/Python/Python39',
 'C:/Users/Mustafa Taher/AppData/Local/Programs/Python/Python37/Scripts',
 'C:/Users/Mustafa Taher/AppData/Local/Programs/Python/Python37',
 'C:/Users/Mustafa Taher/AppData/Local/Microsoft/WindowsApps',
 'C:/Users/Mustafa Taher/AppData/Local/GitHubDesktop/bin',
 'C:/Users/Mustafa Taher/AppData/Local/Microsoft/WindowsApps',
 'C:/Program Files/SDCC/bin',
 'C:/Program Files/Adobe/Adobe After Effects CC 2017/Support Files',
 'C:/Users/Mustafa Taher/AppData/Local/Programs/Microsoft VS Code/bin',
 'C:/Program Files (x86)/Inno Setup 6',
 'E:/Ynput/OpenPype/.poetry/bin']

Setting Deadline param file

image

Modifying GlobalJobPreLoad.py

I added these lines just after these other line

if "PATH" in contents:
      PATH = contents["PATH"]
      print(f">>> Contents of 'PATH': {PATH}")
      deadlinePlugin.SetEnvironmentVariable("PATH", contents["PATH"])

Job Results

Error: FailRenderException : Deadline was unable to find Houdini 19_5 on the machine xxxx .

It tried and failed to find the render executable at these configured locations:
hython.exe
hython
.
.
.
2023-09-12 11:05:20:  0: PYTHON: >>> Contents of 'PATH': 
C:\Program Files (x86)\OpenPype\3.16.0\lib;
C:\Program Files\Thinkbox\Deadline10\bin\python3\Library\bin;
C:\Program Files\Thinkbox\Deadline10\bin\python3\Library\bin;
C:\Program Files\Thinkbox\Deadline10\bin\;
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\ProgramData\Oracle\Java\javapath;
C:\Python27\Scripts;
C:\Python27;
C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64_win\compiler;
C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;
C:\Program Files\Common Files\Autodesk Shared\;
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\PuTTY\;
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Program Files\Git\cmd;
C:\Program Files\CodeBlocks\MinGW\bin;
C:\Program Files\Graphviz\bin;
;
C:\Users\Mustafa Taher\AppData\Local\Programs\Python\Python39\Scripts\;
C:\Users\Mustafa Taher\AppData\Local\Programs\Python\Python39\;
C:\Users\Mustafa Taher\AppData\Local\Programs\Python\Python37\Scripts\;
C:\Users\Mustafa Taher\AppData\Local\Programs\Python\Python37\;
C:\Users\Mustafa Taher\AppData\Local\Microsoft\WindowsApps;
C:\Users\Mustafa Taher\AppData\Local\GitHubDesktop\bin;
C:\Users\Mustafa Taher\AppData\Local\Microsoft\WindowsApps;
C:\Program Files\SDCC\bin;
C:\Program Files\Adobe\Adobe After Effects CC 2017\Support Files;
C:\Users\Mustafa Taher\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Program Files (x86)\Inno Setup 6

Conclusion

  1. Injection has no effect because it happens after resolving executable path by deadline.
  2. Environment variables defined in OP System Settings/Applications/Houdini are not included in Job!

    Check Deadline log doesn't include PATH value that was previously defined in OP settings

For this to work I think we'd need to:

  1. Inject PATH before resolving executable path by deadline.
  2. Include OP Applications Environment variables before submission.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 12, 2023

Your second printed log shows the issue. The environment you have there in content does not seem to include the app environment (or I am blind?).

I don't see the Houdini folder there?

Include OP Applications Environment variables before submission.

No. These must be computed at runtime on the farm machine to be cross os compatible, etc.

Inject PATH before resolving executable path by deadline.

GlobalJobPreLoad runs before the render plugin so should be on time.

@MustafaJafar
Copy link
Copy Markdown
Member Author

Your second printed log shows the issue. The environment you have there in content does not seem to include the app environment

yes it does not include the app environment
any ideas about how to include app environment in content ?
I'll try to dig in the code.

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 12, 2023

yes it does not include the app environment
any ideas about how to include app environment in content ?

That'd mean the extractenvironments cli command doesn't return it - why it doesn't I'm not sure.
It does use envgroup "farm" but what that means I have no idea ;)

Probably @iLLiCiTiT knows why it might exclude the Application Settings' "environment"?

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Sep 14, 2023

That'd mean the extractenvironments cli command doesn't return it - why it doesn't I'm not sure.

I followed that thread and found that it eventually calls get_app_environments_for_context

so I gave it a test in houdini

import os 
from openpype.lib.applications import (
    get_app_environments_for_context,
    LaunchTypes,
)
        
project = os.getenv("AVALON_PROJECT")
asset = os.getenv("AVALON_ASSET")
task = os.getenv("AVALON_TASK")
app = os.getenv("AVALON_APP_NAME")
env_group = "farm" # "standard" 

env = get_app_environments_for_context(
    project,
    asset,
    task,
    app,
    env_group=env_group,
    launch_type=LaunchTypes.farm_render
)
print(env)

and I could find in the results

 'PATH': 'C:/Program Files/Side Effects Software/Houdini 19.5.403/bin;......

Also, I print content in deadline log and content hasn't the same size as the above env (although I'm calling the same function. maybe I'm missing something)
image

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 14, 2023

I believe the function also returns your local environment (it includes it) and thus if you already run it within Houdini it'd include any env vars already set there - that's also why you're seeing the _HOUDINI_... variables.

You should really be running this from say the Console in the OpenPype launcher (but since that doesn't have the asset env vars, etc. pass it actual names you know exist)

@MustafaJafar
Copy link
Copy Markdown
Member Author

You should really be running this from say the Console in the OpenPype launcher

I can find it in OP Console too!
image

image

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 14, 2023

I suspect this will be a question for @iLLiCiTiT

@MustafaJafar
Copy link
Copy Markdown
Member Author

I suspect this will be a question for @iLLiCiTiT

@BigRoy
we just figured it out :)
deadline was running another openpype version that doesn't have the path settings.
image

and after fixing that, PATH was updated successfully!

Then, I added these lines just after these other line

if "PATH" in contents: # 
    PATH = contents["PATH"]
    print(f">>> Contents of 'PATH': {PATH}")
    deadlinePlugin.SetEnvironmentVariable("PATH", contents["PATH"])

which prints fine!
image

but deadline still fails
image

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 14, 2023

@MustafaJafar This is perfect - so close.

I've decided to do a test run on my end.

This I how I set the Houdini plugin settings in Deadline:
image

hython.exe
hython

Then I skipped OpenPype completely and just did a 'deadline test' and submitted a Houdini scene through the Deadline Monitor for that Houdini version. Next this is what I tried in GlobalJobPreLoad.py:

import os
HOUDINI_LOCATION = r"C:\Program Files\Side Effects Software\Houdini 19.5.435\bin"
path = os.pathsep.join([HOUDINI_LOCATION, os.environ["PATH"]])

print(f"Testing deadlinePlugin.SetEnvironmentVariable: {path}")
deadlinePlugin.SetEnvironmentVariable("PATH", path)

Which failed.

Then I tried:

print(f"Testing deadlinePlugin.SetProcessEnvironmentVariable: {path}")
deadlinePlugin.SetProcessEnvironmentVariable("PATH", path)

Which failed.

Then I tried:

print(f"Setting os.environ['PATH']: {path}")
os.environ["PATH"] = path

Which worked. ✅

So the solution is to just add it to os.environ["PATH"] in the GlobalJobPreLoad.

The logs showed:

2023-09-14 20:13:45:  0: PYTHON: Setting os.environ['PATH']: C:\Program Files\Side Effects Software\Houdini 19.5.435\bin;...
...
...
2023-09-14 20:13:45:  0: INFO: Executable: "C:\Program Files\Side Effects Software\Houdini 19.5.435\bin\hython.exe"

Could you try that @MustafaJafar

@BigRoy
Copy link
Copy Markdown
Collaborator

BigRoy commented Sep 14, 2023

It's good to note that Deadline has quite a few settings involving "environments" of the jobs. I'm not sure how any of these influence the behavior:

Sandbox Plugins - it might be that this alters the behavior when disabled?
image

Render as user - I'm not sure if that user would then similarly inherit the environment. I suspect it should and that it runs even the deadline plugin and globaljobpreload as that user from the get go so then works fine. It's quite an advanced feature though - we don't use it.
image

@MustafaJafar
Copy link
Copy Markdown
Member Author

MustafaJafar commented Sep 14, 2023

@BigRoy
MAN! you are a genius! it worked!
I will make another PR and will consider take this PR down!

I'm not sure how any of these influence the behavior

We can test that in the other PR

image

@MustafaJafar
Copy link
Copy Markdown
Member Author

This PR is closed in favor of #5622

@ynbot ynbot added this to the next-patch milestone Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

host: Houdini module: Deadline AWS Deadline related features size/XL Denotes a PR changes 1500-2499 lines, ignoring general files sponsored Client endorsed or requested type: documentation type: enhancement Enhancements to existing functionality

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants