From 66b8075264e6e963f1cd8faa80e079a0d0f707f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Vol=C3=A1k?= Date: Tue, 13 Aug 2024 14:38:50 +0200 Subject: [PATCH] [schellar] workflow_context as a json (#56) Co-authored-by: Jozef Volak --- schellar/python/CHANGELOG.md | 4 ++++ schellar/python/frinx_worker/schellar/__init__.py | 4 ++-- schellar/python/frinx_worker/schellar/workflows/schellar.py | 4 ++-- schellar/python/pyproject.toml | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/schellar/python/CHANGELOG.md b/schellar/python/CHANGELOG.md index 9fe3308..ef678e8 100644 --- a/schellar/python/CHANGELOG.md +++ b/schellar/python/CHANGELOG.md @@ -7,3 +7,7 @@ # 1.1.0 - Update dependencies - Add response handler with task Failed status + +# 1.2.0 +workflow_context as a JSON input in workflow +changes stringify on workflow_context worker input diff --git a/schellar/python/frinx_worker/schellar/__init__.py b/schellar/python/frinx_worker/schellar/__init__.py index c89f524..22f0df6 100644 --- a/schellar/python/frinx_worker/schellar/__init__.py +++ b/schellar/python/frinx_worker/schellar/__init__.py @@ -217,7 +217,7 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: ) if worker_input.workflow_context: - create_schedule.input.workflow_context = json_dumps(worker_input.workflow_context).replace('"', '\\"') + create_schedule.input.workflow_context = json_dumps(worker_input.workflow_context) mutation = create_schedule.render(form="extracted") response = execute_schellar_query(query=mutation.query, variables=mutation.variable) @@ -279,7 +279,7 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: ) if worker_input.workflow_context: - update_schedule.input.workflow_context = json_dumps(worker_input.workflow_context).replace('"', '\\"') + update_schedule.input.workflow_context = json_dumps(worker_input.workflow_context) mutation = update_schedule.render() response = execute_schellar_query(query=mutation.query, variables=mutation.variable) diff --git a/schellar/python/frinx_worker/schellar/workflows/schellar.py b/schellar/python/frinx_worker/schellar/workflows/schellar.py index e1caac6..d65725d 100644 --- a/schellar/python/frinx_worker/schellar/workflows/schellar.py +++ b/schellar/python/frinx_worker/schellar/workflows/schellar.py @@ -63,7 +63,7 @@ class WorkflowInput(WorkflowImpl.WorkflowInput): name="workflow_context", frontend_default_value="", description="Workflow input parameters in json format", - type=FrontendWFInputFieldType.STRING, + type=FrontendWFInputFieldType.JSON, ) from_date: WorkflowInputField = WorkflowInputField( @@ -159,7 +159,7 @@ class WorkflowInput(WorkflowImpl.WorkflowInput): name="workflow_context", frontend_default_value="", description="Workflow input parameters in json format", - type=FrontendWFInputFieldType.STRING, + type=FrontendWFInputFieldType.JSON, ) from_date: WorkflowInputField = WorkflowInputField( diff --git a/schellar/python/pyproject.toml b/schellar/python/pyproject.toml index 76fff25..1057330 100644 --- a/schellar/python/pyproject.toml +++ b/schellar/python/pyproject.toml @@ -19,7 +19,7 @@ packages = [{ include = "frinx_worker" }] name = "frinx-schellar-worker" description = "Conductor worker for Schellar service" authors = ["Jozef Volak "] -version = "1.1.1" +version = "1.2.0" readme = ["README.md", "CHANGELOG.md", "RELEASE.md"] keywords = ["frinx-machine", "schellar", "worker"] license = "Apache 2.0"