Skip to content

Commit b8ec65b

Browse files
authored
Merge pull request #1952 from kili-technology/feature/lab-3897-aau-i-can-update-project-workflow-using-the-sdk
feat(lab-3897): add default return when using update project workflow
2 parents 91063bc + 1c0edfa commit b8ec65b

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/kili/adapters/kili_api_gateway/project_workflow/mappers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from typing import Dict, Union
44

5+
from cuid import cuid
6+
57
from kili.domain.project import WorkflowStepCreate, WorkflowStepUpdate
68

79
from .types import ProjectWorkflowDataKiliAPIGatewayInput
@@ -26,7 +28,7 @@ def project_input_mapper(data: ProjectWorkflowDataKiliAPIGatewayInput) -> Dict:
2628
def update_step_mapper(data: Union[WorkflowStepCreate, WorkflowStepUpdate]) -> Dict:
2729
"""Build the GraphQL create StepData variable to be sent in an operation."""
2830
step = {
29-
"id": data["id"] if "id" in data else None,
31+
"id": data["id"] if "id" in data else cuid(),
3032
"name": data["name"] if "name" in data else None,
3133
"consensusCoverage": data["consensus_coverage"] if "consensus_coverage" in data else None,
3234
"numberOfExpectedLabelsForConsensus": data["number_of_expected_labels_for_consensus"]

src/kili/adapters/kili_api_gateway/project_workflow/operations_mixin.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ def update_project_workflow(
2828
"""Update properties in a project workflow."""
2929
project_workflow_input = project_input_mapper(data=project_workflow_data)
3030

31-
fields = tuple(
32-
name
33-
for name, val in project_workflow_input.items()
34-
if val is not None and name != "steps"
35-
)
31+
fields = ["enforceStepSeparation", "steps{id}"]
3632
fragment = fragment_builder(fields)
3733
mutation = get_update_project_workflow_mutation(fragment)
3834

tests/integration/presentation/test_project_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_when_updating_project_workflow_then_it_returns_updated_project_workflow
2323

2424
# Then
2525
kili.kili_api_gateway.graphql_client.execute.assert_called_once_with(
26-
get_update_project_workflow_mutation(" enforceStepSeparation"),
26+
get_update_project_workflow_mutation(" enforceStepSeparation steps{id}"),
2727
{
2828
"input": {
2929
"projectId": "fake_proj_id",

0 commit comments

Comments
 (0)