Skip to content

Commit

Permalink
feat: Add UI for custom host worker capability requirements (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: Yutong Li <[email protected]>
Co-authored-by: Yutong Li <[email protected]>
  • Loading branch information
YutongLi291 and YutongLi291 authored Mar 14, 2024
1 parent 7c2522c commit c5bbcd3
Show file tree
Hide file tree
Showing 5 changed files with 529 additions and 55 deletions.
4 changes: 4 additions & 0 deletions src/deadline/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ class CreateJobWaiterCanceled(Exception):

class UserInitiatedCancel(Exception):
"""Error for when the user requests cancelation"""


class NonValidInputError(Exception):
"""Error for when the user input is nonvalid"""
11 changes: 10 additions & 1 deletion src/deadline/client/ui/cli_job_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import os
from importlib import reload
from logging import getLogger
from typing import Any, Dict
from typing import Any, Dict, Optional
import copy

from PySide2.QtCore import Qt # pylint: disable=import-error
from PySide2.QtWidgets import ( # pylint: disable=import-error; type: ignore
Expand Down Expand Up @@ -50,6 +51,7 @@ def on_create_job_bundle_callback(
settings: CliJobSettings,
queue_parameters: list[dict[str, Any]],
asset_references: AssetReferences,
host_requirements: Optional[Dict[str, Any]] = None,
purpose: JobBundlePurpose = JobBundlePurpose.SUBMISSION,
) -> None:
"""
Expand Down Expand Up @@ -121,6 +123,12 @@ def on_create_job_bundle_callback(
]
}

# If "HostRequirements" is provided, inject it into each of the "Step"
if host_requirements:
# for each step in the template, append the same host requirements.
for step in job_template["steps"]:
step["hostRequirements"] = copy.deepcopy(host_requirements)

with open(
os.path.join(job_bundle_dir, f"template.{settings.file_format.lower()}"),
"w",
Expand Down Expand Up @@ -163,6 +171,7 @@ def on_create_job_bundle_callback(
initial_shared_parameter_values={},
auto_detected_attachments=AssetReferences(),
attachments=AssetReferences(),
show_host_requirements_tab=True,
on_create_job_bundle_callback=on_create_job_bundle_callback,
parent=parent,
f=f,
Expand Down
12 changes: 10 additions & 2 deletions src/deadline/client/ui/job_bundle_submitter.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
from __future__ import annotations

import copy
import json
import os
from logging import getLogger
from typing import Any, Optional
from typing import Any, Optional, Dict

from PySide2.QtCore import Qt # pylint: disable=import-error
from PySide2.QtWidgets import ( # pylint: disable=import-error; type: ignore
Expand Down Expand Up @@ -70,6 +70,7 @@ def on_create_job_bundle_callback(
settings: JobBundleSettings,
queue_parameters: list[JobParameter],
asset_references: AssetReferences,
host_requirements: Optional[Dict[str, Any]] = None,
purpose: JobBundlePurpose = JobBundlePurpose.SUBMISSION,
) -> None:
"""
Expand All @@ -92,6 +93,12 @@ def on_create_job_bundle_callback(
)
template["name"] = settings.name

# If "HostRequirements" is provided, inject it into each of the "Step"
if host_requirements:
# for each step in the template, append the same host requirements.
for step in template["steps"]:
step["hostRequirements"] = copy.deepcopy(host_requirements)

with open(
os.path.join(job_bundle_dir, f"template.{file_type.lower()}"), "w", encoding="utf8"
) as f:
Expand Down Expand Up @@ -165,6 +172,7 @@ def on_create_job_bundle_callback(
submitter_dialog = SubmitJobToDeadlineDialog(
job_setup_widget_type=JobBundleSettingsWidget,
initial_job_settings=initial_settings,
# show_host_requirements_tab=True, // Enable when we want to show the host requirement tab
initial_shared_parameter_values=initial_shared_parameter_values,
auto_detected_attachments=asset_references,
attachments=AssetReferences(),
Expand Down
1 change: 1 addition & 0 deletions src/deadline/client/ui/resources/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c5bbcd3

Please sign in to comment.