Skip to content

Commit 5e10e2c

Browse files
authored
fix: make userInterface control field optional for all parameter types (#278)
Make userInterface control field optional for all parameter types Fixes: aws-deadline/deadline-cloud#1109 Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>
1 parent 3e36fcd commit 5e10e2c

2 files changed

Lines changed: 52 additions & 8 deletions

File tree

‎src/openjd/model/v2023_09/_model.py‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,14 +1301,15 @@ class JobStringParameterDefinitionUserInterface(OpenJDModel_v2023_09):
13011301
"""User interface attributes for a job string parameter.
13021302
13031303
Attributes:
1304-
control (StringUserInterfaceControl): The user interface control to use when editing this parameter.
1304+
control (Optional[StringUserInterfaceControl]): The user interface control to use when editing this parameter.
1305+
Default is LINE_EDIT when allowedValues is not provided, DROPDOWN_LIST when it is.
13051306
label (Optional[UserInterfaceLabelStringValue]): The label to display for the user interface control. Defaults
13061307
to the `name` of the parameter.
13071308
groupLabel (Optional[UserInterfaceLabelStringValue]): The label of the group box to place the user interface
13081309
control in.
13091310
"""
13101311

1311-
control: StringUserInterfaceControl
1312+
control: Optional[StringUserInterfaceControl] = None
13121313
label: Optional[UserInterfaceLabelStringValue] = None
13131314
groupLabel: Optional[UserInterfaceLabelStringValue] = None
13141315

@@ -1447,6 +1448,8 @@ def _validate_user_interface_compatibility(self) -> Self:
14471448
# validate that the user interface control is compatible with the value constraints
14481449
if self.userInterface:
14491450
user_interface_control = self.userInterface.control
1451+
if user_interface_control is None:
1452+
return self
14501453
if self.allowedValues and user_interface_control in (
14511454
StringUserInterfaceControl.LINE_EDIT,
14521455
StringUserInterfaceControl.MULTILINE_EDIT,
@@ -1530,7 +1533,8 @@ class JobPathParameterDefinitionUserInterface(OpenJDModel_v2023_09):
15301533
"""User interface attributes for a job path parameter.
15311534
15321535
Attributes:
1533-
control (PathUserInterfaceControl): The user interface control to use when editing this parameter.
1536+
control (Optional[PathUserInterfaceControl]): The user interface control to use when editing this parameter.
1537+
Default depends on objectType, dataFlow, and allowedValues.
15341538
label (Optional[UserInterfaceLabelStringValue]): The label to display for the user interface control. Defaults
15351539
to the `name` of the parameter.
15361540
groupLabel (Optional[UserInterfaceLabelStringValue]): The label of the group box to place the user interface
@@ -1542,7 +1546,7 @@ class JobPathParameterDefinitionUserInterface(OpenJDModel_v2023_09):
15421546
“CHOOSE_OUTPUT_FILE”. The default file filter that’s shown in the file choice dialog.
15431547
"""
15441548

1545-
control: PathUserInterfaceControl
1549+
control: Optional[PathUserInterfaceControl] = None
15461550
label: Optional[UserInterfaceLabelStringValue] = None
15471551
groupLabel: Optional[UserInterfaceLabelStringValue] = None
15481552
fileFilters: Optional[JobPathParameterDefinitionFileFilterList] = None
@@ -1691,6 +1695,8 @@ def _validate_user_interface_compatibility(self) -> Self:
16911695
# validate that the user interface control is compatible with the value constraints
16921696
if self.userInterface:
16931697
user_interface_control = self.userInterface.control
1698+
if user_interface_control is None:
1699+
return self
16941700
if self.allowedValues and user_interface_control in (
16951701
PathUserInterfaceControl.CHOOSE_INPUT_FILE,
16961702
PathUserInterfaceControl.CHOOSE_OUTPUT_FILE,
@@ -1765,7 +1771,8 @@ class JobIntParameterDefinitionUserInterface(OpenJDModel_v2023_09):
17651771
"""User interface attributes for a job int parameter.
17661772
17671773
Attributes:
1768-
control (IntUserInterfaceControl): The user interface control to use when editing this parameter.
1774+
control (Optional[IntUserInterfaceControl]): The user interface control to use when editing this parameter.
1775+
Default is SPIN_BOX when allowedValues is not provided, DROPDOWN_LIST when it is.
17691776
label (Optional[UserInterfaceLabelStringValue]): The label to display for the user interface control. Defaults
17701777
to the `name` of the parameter.
17711778
groupLabel (Optional[UserInterfaceLabelStringValue]): The label of the group box to place the user interface
@@ -1774,7 +1781,7 @@ class JobIntParameterDefinitionUserInterface(OpenJDModel_v2023_09):
17741781
as selecting an up or down arrow in the user interface control.
17751782
"""
17761783

1777-
control: IntUserInterfaceControl
1784+
control: Optional[IntUserInterfaceControl] = None
17781785
label: Optional[UserInterfaceLabelStringValue] = None
17791786
groupLabel: Optional[UserInterfaceLabelStringValue] = None
17801787
singleStepDelta: Optional[PositiveInt] = None
@@ -1958,6 +1965,8 @@ def _validate_user_interface_compatibility(self) -> Self:
19581965
# validate that the user interface control is compatible with the value constraints
19591966
if self.userInterface:
19601967
user_interface_control = self.userInterface.control
1968+
if user_interface_control is None:
1969+
return self
19611970
if self.allowedValues and user_interface_control == IntUserInterfaceControl.SPIN_BOX:
19621971
raise ValueError(
19631972
f"User interface control {user_interface_control.name} cannot be used when 'allowedValues' is provided"
@@ -2016,7 +2025,8 @@ class JobFloatParameterDefinitionUserInterface(OpenJDModel_v2023_09):
20162025
"""User interface attributes for a job float parameter.
20172026
20182027
Attributes:
2019-
control (FloatUserInterfaceControl): The user interface control to use when editing this parameter.
2028+
control (Optional[FloatUserInterfaceControl]): The user interface control to use when editing this parameter.
2029+
Default is SPIN_BOX when allowedValues is not provided, DROPDOWN_LIST when it is.
20202030
label (Optional[UserInterfaceLabelStringValue]): The label to display for the user interface control. Defaults
20212031
to the `name` of the parameter.
20222032
groupLabel (Optional[UserInterfaceLabelStringValue]): The label of the group box to place the user interface
@@ -2028,7 +2038,7 @@ class JobFloatParameterDefinitionUserInterface(OpenJDModel_v2023_09):
20282038
absolute value, otherwise it is the fraction of the current value to use as an adaptive step.
20292039
"""
20302040

2031-
control: FloatUserInterfaceControl
2041+
control: Optional[FloatUserInterfaceControl] = None
20322042
label: Optional[UserInterfaceLabelStringValue] = None
20332043
groupLabel: Optional[UserInterfaceLabelStringValue] = None
20342044
decimals: Optional[PositiveInt] = None
@@ -2158,6 +2168,8 @@ def _validate_user_interface_compatibility(self) -> Self:
21582168
# validate that the user interface control is compatible with the value constraints
21592169
if self.userInterface:
21602170
user_interface_control = self.userInterface.control
2171+
if user_interface_control is None:
2172+
return self
21612173
if self.allowedValues and user_interface_control == FloatUserInterfaceControl.SPIN_BOX:
21622174
raise ValueError(
21632175
f"User interface control {user_interface_control.name} cannot be used when 'allowedValues' is provided"

‎test/openjd/model/v2023_09/test_job_parameters.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ class TestJobStringParameterDefinition:
6767
id="description with newlines and tabs",
6868
),
6969
#
70+
pytest.param(
71+
{"name": "Foo", "type": "STRING", "userInterface": {"label": "My Label"}},
72+
id="user interface label only no control",
73+
),
74+
pytest.param(
75+
{"name": "Foo", "type": "STRING", "userInterface": {"groupLabel": "My Group"}},
76+
id="user interface groupLabel only no control",
77+
),
7078
pytest.param(
7179
{"name": "Foo", "type": "STRING", "userInterface": {"control": "LINE_EDIT"}},
7280
id="user interface LINE_EDIT",
@@ -534,6 +542,14 @@ class TestJobPathParameterDefinition:
534542
id="description with newlines and tabs",
535543
),
536544
#
545+
pytest.param(
546+
{"name": "Foo", "type": "PATH", "userInterface": {"label": "My Label"}},
547+
id="user interface label only no control",
548+
),
549+
pytest.param(
550+
{"name": "Foo", "type": "PATH", "userInterface": {"groupLabel": "My Group"}},
551+
id="user interface groupLabel only no control",
552+
),
537553
pytest.param(
538554
{"name": "Foo", "type": "PATH", "userInterface": {"control": "CHOOSE_INPUT_FILE"}},
539555
id="user interface CHOOSE_INPUT_FILE",
@@ -1189,6 +1205,14 @@ class TestJobIntParameterDefinition:
11891205
id="default is allowed",
11901206
),
11911207
#
1208+
pytest.param(
1209+
{"name": "Foo", "type": "INT", "userInterface": {"label": "My Label"}},
1210+
id="user interface label only no control",
1211+
),
1212+
pytest.param(
1213+
{"name": "Foo", "type": "INT", "userInterface": {"groupLabel": "My Group"}},
1214+
id="user interface groupLabel only no control",
1215+
),
11921216
pytest.param(
11931217
{"name": "Foo", "type": "INT", "userInterface": {"control": "SPIN_BOX"}},
11941218
id="user interface SPIN_BOX",
@@ -1647,6 +1671,14 @@ class TestJobFloatParameterDefinition:
16471671
id="default is allowed",
16481672
),
16491673
#
1674+
pytest.param(
1675+
{"name": "Foo", "type": "FLOAT", "userInterface": {"label": "My Label"}},
1676+
id="user interface label only no control",
1677+
),
1678+
pytest.param(
1679+
{"name": "Foo", "type": "FLOAT", "userInterface": {"groupLabel": "My Group"}},
1680+
id="user interface groupLabel only no control",
1681+
),
16501682
pytest.param(
16511683
{"name": "Foo", "type": "FLOAT", "userInterface": {"control": "SPIN_BOX"}},
16521684
id="user interface SPIN_BOX",

0 commit comments

Comments
 (0)