Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
python 3.13.2
poetry 2.1.2
poetry 2.2.1
nodejs 22.14.0
499 changes: 268 additions & 231 deletions kuflow-rest/poetry.lock

Large diffs are not rendered by default.

491 changes: 250 additions & 241 deletions kuflow-robotframework/poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async def create_process_item(
owner_email=request.owner_email,
process_item_definition_code=request.process_item_definition_code,
task=request.task,
metadata=request.message,
message=request.message,
)

process_item = self._kuflow_client.process_item.create_process_item(process_item_create_params=params)
Expand Down
657 changes: 356 additions & 301 deletions kuflow-temporal-activity-kuflow/poetry.lock

Large diffs are not rendered by default.

521 changes: 264 additions & 257 deletions kuflow-temporal-activity-robotframework/poetry.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion kuflow-temporal-common/kuflow_temporal_common/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#

from enum import Enum
from typing import Any, Optional, Union

from temporalio.converter import (
Expand Down Expand Up @@ -51,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None:
self._serialize = Serializer(client_models)

def default(self, value: Any) -> Any:

if isinstance(value, Model):
return self._serialize.body(value, value.__class__.__name__)

Expand All @@ -63,7 +65,9 @@ def __init__(self) -> None:
self._deserialize = Deserializer(client_models)

def to_typed_value(self, hint: type, value: Any) -> Union[Optional[Any], _JSONTypeConverterUnhandled]:
if issubclass(hint, Model):
if isinstance(hint, type) and issubclass(hint, Model):
return self._deserialize(hint.__name__, value)


# Means: continue with defaults one. See: temporalio#converter.py#value_to_type
return JSONTypeConverter.Unhandled
529 changes: 282 additions & 247 deletions kuflow-temporal-common/poetry.lock

Large diffs are not rendered by default.

142 changes: 142 additions & 0 deletions kuflow-temporal-common/test/test_converter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#
# MIT License
#
# Copyright (c) 2022 KuFlow
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

import json
from datetime import datetime
from enum import StrEnum
from typing import Optional
from uuid import UUID

import pytest
from temporalio.converter import JSONPlainPayloadConverter

from kuflow_temporal_common._converter import KuFlowModelJSONEncoder, KuFlowModelJSONTypeConverter


class SampleEnum(StrEnum):
VALUE_ONE = "value_one"
VALUE_TWO = "value_two"


class TestConverterRoundTrip:
"""Test encoding and decoding round-trip using JSONPlainPayloadConverter"""

@pytest.fixture
def converter(self):
return JSONPlainPayloadConverter(
encoder=KuFlowModelJSONEncoder,
custom_type_converters=[KuFlowModelJSONTypeConverter()],
)

def test_uuid_roundtrip(self, converter):
"""Test UUID serialization and deserialization"""
original = UUID("12345678-1234-5678-1234-567812345678")

payload = converter.to_payload(original)
result = converter.from_payload(payload, UUID)

assert result == original

def test_bytes_roundtrip(self, converter):
"""Test bytes serialization and deserialization"""
original = b"Hello, World!"

payload = converter.to_payload(original)
result = converter.from_payload(payload, bytes)

assert result == original

def test_enum_roundtrip(self, converter):
"""Test Enum serialization and deserialization"""
original = SampleEnum.VALUE_ONE

payload = converter.to_payload(original)
result = converter.from_payload(payload, SampleEnum)

assert result == original

def test_none_roundtrip(self, converter):
"""Test None serialization and deserialization"""
original = None

payload = converter.to_payload(original)
result = converter.from_payload(payload, Optional[str])

assert result is None

def test_list_of_uuid_roundtrip(self, converter):
"""Test list[UUID] serialization and deserialization"""
original = [
UUID("12345678-1234-5678-1234-567812345678"),
UUID("87654321-4321-8765-4321-876543218765"),
]

payload = converter.to_payload(original)
result = converter.from_payload(payload, list[UUID])

assert result == original

def test_dict_of_str_to_uuid_roundtrip(self, converter):
"""Test dict[str, UUID] serialization and deserialization"""
original = {
"id1": UUID("12345678-1234-5678-1234-567812345678"),
"id2": UUID("87654321-4321-8765-4321-876543218765"),
}

payload = converter.to_payload(original)
result = converter.from_payload(payload, dict[str, UUID])

assert result == original

def test_optional_datetime_with_none_roundtrip(self, converter):
"""Test Optional[datetime] with None serialization and deserialization"""
original = None

payload = converter.to_payload(original)
result = converter.from_payload(payload, Optional[datetime])

assert result is None


class TestEncoderOnly:
"""Test encoder-specific functionality"""

def test_encoder_uuid(self):
"""Test UUID encoding to string"""
uuid_obj = UUID("12345678-1234-5678-1234-567812345678")

result = json.dumps(uuid_obj, cls=KuFlowModelJSONEncoder)

assert result == f'"{str(uuid_obj)}"'

def test_encoder_enum(self):
"""Test Enum encoding to value"""
enum_val = SampleEnum.VALUE_ONE

result = json.dumps(enum_val, cls=KuFlowModelJSONEncoder)

assert result == f'"{enum_val.value}"'

pass # Keep class with at least one statement

Loading