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

Houdini: Switching context doesn't update variables #4035

Closed
antirotor opened this issue Oct 27, 2022 · 7 comments · Fixed by #5651
Closed

Houdini: Switching context doesn't update variables #4035

antirotor opened this issue Oct 27, 2022 · 7 comments · Fixed by #5651
Assignees
Labels
host: Houdini type: bug Something isn't working

Comments

@antirotor
Copy link
Member

antirotor commented Oct 27, 2022

Bug

When switching context in Houdini, sometimes $HIP/$JOB are not updated.

[cuID:OP-4326]

@antirotor antirotor added type: bug Something isn't working host: Houdini labels Oct 27, 2022
@BigRoy
Copy link
Collaborator

BigRoy commented Apr 11, 2023

Could you elaborate on this issue?

  • $HIP is always the workfile path and as such, how should this update?
  • $JOB is a custom attribute definition which as far as I know OpenPype doesn't set it explicitly by default at all. In Houdini it's somewhat the equivalent to what setting workspace would be in Maya, as be seen here for how it's used to "Set project".
    • However, do note that $JOB defaults to the current working directory that Houdini launched with which this Houdini pre-launch hook ends up setting. Should we maybe make that more explicit by instead setting the JOB env var?

It's also good to note what the docs mention about $JOB:

The value of $JOB is saved with the scene (.hip) file. So once you associate a given scene file with a project using File ▸ Set Project and save it, you don’t have to use File ▸ Set Project again the next time you open the scene file.


@antirotor So is this issue about updating JOB on Task change?

@MustafaJafar
Copy link
Contributor

I think this PR is related
#5532

@MustafaJafar
Copy link
Contributor

@BigRoy
Hey, let's revisit this issue

Some Facts

HIP

I saved Houdini file to desktop and published my job and Houdini addon oddly doesn't complain ?!

image

JOB

as we discussed before, Houdini addon doesn't manage $JOB at all.
So, it's managed according to Houdini's default which is as far as I know :

  1. set $JOB to $HIP
  2. users are allowed to set $JOB manually
  3. developers cam set $JOB programmatically by using hou.hscript("set JOB=" + job)

Quick tests:

Launch Task in Houdini for the first time

Houdini addon succeed in open Houdini file in the correct directory but doesn't save the first file, so artist must use the workfile tool to save it.

Also, $HIP and $JOB both are set to working directory and no $HIPNAME yet.
image

Launch Task in Houdini

, $HIP and $JOB both are set to working directory and $HIPNAME showing the current file name
image

Switch context

From the opened Houdini session there are two possibilities

open another workfile

Python env vars may not be updated but hscript vars are there! and if I close and reopen the same file, I will find python vars values are the same as the hscript ones.

I think there should be a post open callback to sync hscript vars and their python os.environ twins

image

Save current workfile to another asset

The new workfile will hold the value of the old workfile

image


So, How should we manage HIP and JOB at these cases ?

@BigRoy
Copy link
Collaborator

BigRoy commented Sep 21, 2023

Regarding the env vars instead of the hscript vars - I didn't even know they were also env vars and I'm not sure if there's a reason I should care about their values if there's no required use for them?


I saved Houdini file to desktop and published my job and Houdini addon oddly doesn't complain ?!

Correct, no hosts do this as far as I know. It can be non-trivial to enforce saving in a certain location unless you force it to be within the workdir. This could easily be a global validation plugin if needed.

Save current workfile to another asset
The new workfile will hold the value of the old workfile

Looking at your screenshot - this seems to only be the case for $JOB.


FYI, We've managed JOB outside of OpenPype and thus it is NEVER set to the initial HIP anyways. Then looking at your examples all works as expected HIP and HIPNAME update as expected, JOB is our custom var.

If you're looking to sync JOB to HIP then I'd say you should instead just be using HIP. If you have a custom need for JOB at your studio - then set it to whatever your studio needs. I still don't see a reason for OpenPype itself to force something into JOB.

@krishnaavril
Copy link

IMO, This is more of template(folder structure related):
$JOB should indicate the task path,
Hipfiles should be saved inside a "hip" folder, so it won't look clumpsy when we open task in file explorer. its more convienient for artists to save there files either $JOB(task path) or $HIP(hipfile path(folder inside $JOB))

Also it helps when we want to share files with outsource people who are not using OP*

@MustafaJafar
Copy link
Contributor

MustafaJafar commented Sep 21, 2023

@BigRoy Thank you for helping me think differently..
The idea is not to force a certain value but to manage that value if it exists and adding an option for admins to specify the desired value and I believe there's a little space for improvement here.


Let's jump to the issue
To fix the env vars when switching context, we need to agree/specify the values of these env vars.

This how I imagine it :

Regarding $HIP

I think that we

  • don't need to set $HIP (the working directory) as it's managed by Houdini and this Houdini pre-launch hook
  • might add a validator to check if the $HIP points to a location that makes sense (e.g. not desktop in my opinion)

Regarding $JOB

It should be up to studios. however, some hints ; it can be

  • Arbitrary path
  • Project path
  • asset category path (e.g. characters, props)
  • asset path
  • task path (which may not be the working directory as you pointed out here )
  • nothing at all

And the specified value is what should be managed when switching contexts (as the path may be asset specific)
I think it would be nice to have a dedicated option for that in settings + some validator or call back that make sure that this value is maintained (as artists can choose the dumb way and set project manually 🙂)

@BigRoy
Copy link
Collaborator

BigRoy commented Sep 21, 2023

The job setting that updates per context based on Project Settings sounds fine with me if studios can enter their own template for it in settings. It could even have a checkbox whether the callback runs on Context change or not.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Houdini type: bug Something isn't working
Projects
None yet
4 participants