aws-deadline / deadline-cloud-for-maya

AWS Deadline Cloud for Maya
Apache License 2.0
11 stars 15 forks source link

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

Closed epmog closed 8 months ago

epmog commented 8 months ago

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 :)