Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly fill out allowed values for camera job parameter #103

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

epmog
Copy link
Contributor

@epmog epmog commented Feb 27, 2024

What was the problem/requirement? (What/Why)

If you select a specific camera, the job would fail to create:

// Error: deadline.client.ui.dialogs.submit_job_to_deadline_dialog : error submitting job
// Traceback (most recent call last):
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/ui/dialogs/submit_job_to_deadline_dialog.py", line 461, in on_submit
//     self.create_job_response = job_progress_dialog.start_submission(
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/ui/dialogs/submit_job_progress_dialog.py", line 126, in start_submission
//     self._start_submission()
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/ui/dialogs/submit_job_progress_dialog.py", line 193, in _start_submission
//     job_bundle_parameters = read_job_bundle_parameters(self._job_bundle_dir)
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/job_bundle/parameters.py", line 706, in read_job_bundle_parameters
//     return [
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/job_bundle/parameters.py", line 707, in <listcomp>
//     validate_job_parameter({"name": name, **values})
//   File "/Users/morgane/dev/github/deadline-cloud-for-maya/plugin_env/scripts/deadline/client/job_bundle/parameters.py", line 168, in validate_job_parameter
//     raise TypeError(
// TypeError: Job parameter "Camera" got set for "allowedValues" but expected list

and if you exported the job bundle, you'd end up with:

- name: Camera
  type: STRING
  userInterface:
    control: DROPDOWN_LIST
    groupLabel: Maya Settings
  description: Select which camera to render.
  allowedValues: !!set
    persp: null

So something is turning the renderable cameras into a set instead of a list.

I was actually able to reproduce this just by type hinting the _get_job_template function and running hatch run lint

src/deadline/maya_submitter/maya_render_submitter.py:601: error: Argument 5 to "_get_job_template" has incompatible type "set[str]";
expected "list[str]"  [arg-type]
                all_layer_selectable_cameras,

Problem 2
Also looks like the job bundle tests are now breaking on my machine since the populated value for including the RenderSetupIncludeLights is being set to False in all the job bundles. This appears to be a machine level setting which isn't all that nice since it'll break for users depending if they have a different set-up. Need to make it consistent for all users so that tests are repeatable

What was the solution? (How)

I added some type hints, and cleaned up how we were handling all_layer_selectable_cameras which fixed the issue.

For the second issue I added a context manager to set machine level options on test start, and re-apply the old settings when they finish (regardless of success/fail)

What is the impact of this change?

Users can now select a camera to submit a job!

How was this change tested?

hatch run fmt
hatch run lint
hatch build
hatch run test

the linting now passed. I then ran hatch run install from a WIP branch and verified that I could submit jobs by selecting a camera.

Did you run the "Job Bundle Output Tests"? If not, why not? If so, paste the test results here.


Timestamp: 2024-02-26T21:48:55.448429-06:00
Running job bundle output test: /Users/morgane/dev/github/deadline-cloud-for-maya/job_bundle_output_tests/layers

layers
Test succeeded

Timestamp: 2024-02-26T21:48:56.080044-06:00
Running job bundle output test: /Users/morgane/dev/github/deadline-cloud-for-maya/job_bundle_output_tests/cube

cube
Test succeeded

Timestamp: 2024-02-26T21:48:56.385134-06:00
Running job bundle output test: /Users/morgane/dev/github/deadline-cloud-for-maya/job_bundle_output_tests/layers_no_variation

layers_no_variation
Test succeeded

All tests passed, ran 3 total.
Timestamp: 2024-02-26T21:48:58.872040-06:00

Was this change documented?

N/A

Is this a breaking change?

fixing :)

@epmog epmog requested a review from a team as a code owner February 27, 2024 03:36
@epmog epmog force-pushed the fix_camera_selection_allowed_values branch from 445517a to 8601e31 Compare February 27, 2024 03:51
mwiebe
mwiebe previously approved these changes Feb 27, 2024
old_render_setup_include_all_lights: int = maya.mel.eval(
"optionVar -q renderSetup_includeAllLights"
)
maya.cmds.optionVar(intValue=("renderSetup_includeAllLights", int(True)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a future rev, I imagine we'd want to make this a parameter of the context manager so we can test both settings.

Copy link
Contributor Author

@epmog epmog Feb 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I think there's room for either parameterizing here, or applying machine level options to specific tests after making them consistent

@epmog epmog force-pushed the fix_camera_selection_allowed_values branch from 34d2d85 to 46ef651 Compare February 27, 2024 21:32
@epmog epmog merged commit 3c2d42f into mainline Feb 27, 2024
6 checks passed
@epmog epmog deleted the fix_camera_selection_allowed_values branch February 27, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants