Skip to content

Commit

Permalink
✨ introducing inputs_required to workbench (#5838)
Browse files Browse the repository at this point in the history
  • Loading branch information
matusdrobuliak66 committed May 17, 2024
1 parent 2f82eb1 commit 4892c0d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, ClassVar, Literal, TypeAlias

from models_library.projects_nodes import InputsDict
from models_library.projects_nodes import InputID, InputsDict
from pydantic import Field

from ..api_schemas_directorv2.dynamic_services import RetrieveDataOut
Expand All @@ -27,11 +27,12 @@ class NodeCreate(InputSchemaWithoutCamelCase):

class NodePatch(InputSchemaWithoutCamelCase):
service_version: ServiceVersion = FieldNotRequired(alias="version")
label: str = Field(None)
inputs: InputsDict = Field(None)
label: str = FieldNotRequired()
inputs: InputsDict = FieldNotRequired()
inputs_required: list[InputID] = FieldNotRequired(alias="inputsRequired")
input_nodes: list[NodeID] = FieldNotRequired(alias="inputNodes")
progress: float | None = Field(
None, ge=0, le=100
progress: float | None = FieldNotRequired(
ge=0, le=100
) # NOTE: it is used by frontend for File Picker progress
boot_options: BootOptions = FieldNotRequired(alias="bootOptions")

Expand Down
5 changes: 5 additions & 0 deletions packages/models-library/src/models_library/projects_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ class Node(BaseModel):
inputs: InputsDict | None = Field(
default_factory=dict, description="values of input properties"
)
inputs_required: list[InputID] = Field(
default_factory=list,
description="Defines inputs that are required in order to run the service",
alias="inputsRequired",
)
inputs_units: dict[InputID, UnitStr] | None = Field(
default=None,
description="Overrides default unit (if any) defined in the service for each port",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ async def test_patch_project_node(
data=json.dumps(_patch_inputs),
)
await assert_status(resp, expected)
# inputs required
_patch_inputs_required = {
"inputsRequired": [
"input_1",
"input_3",
]
}
resp = await client.patch(
f"{base_url}",
data=json.dumps(_patch_inputs_required),
)
await assert_status(resp, expected)
# input nodes
_patch_input_nodes = {
"inputNodes": [
Expand Down Expand Up @@ -148,5 +160,6 @@ async def test_patch_project_node(
assert _tested_node["progress"] == None
assert _tested_node["version"] == _patch_version["version"]
assert _tested_node["inputs"] == _patch_inputs["inputs"]
assert _tested_node["inputsRequired"] == _patch_inputs_required["inputsRequired"]
assert _tested_node["inputNodes"] == _patch_input_nodes["inputNodes"]
assert _tested_node["bootOptions"] == _patch_boot_options["bootOptions"]

0 comments on commit 4892c0d

Please sign in to comment.