darabos commited on
Commit
db7a533
·
1 Parent(s): 7f31eb6

Ensure enums can be serialized.

Browse files
lynxkite-app/tests/test_crdt.py CHANGED
@@ -18,7 +18,7 @@ def empty_list_workspace():
18
  yield ws
19
 
20
 
21
- class MyEnum(Enum):
22
  VALUE = 1
23
 
24
 
 
18
  yield ws
19
 
20
 
21
+ class MyEnum(int, Enum):
22
  VALUE = 1
23
 
24
 
lynxkite-core/src/lynxkite/core/ops.py CHANGED
@@ -95,7 +95,7 @@ class ParameterGroup(BaseConfig):
95
  type: str = "group"
96
 
97
 
98
- class Position(enum.Enum):
99
  """Defines the position of an input or output in the UI."""
100
 
101
  LEFT = "left"
 
95
  type: str = "group"
96
 
97
 
98
+ class Position(str, enum.Enum):
99
  """Defines the position of an input or output in the UI."""
100
 
101
  LEFT = "left"
lynxkite-core/src/lynxkite/core/workspace.py CHANGED
@@ -175,8 +175,7 @@ class Workspace(BaseConfig):
175
  data.meta = op
176
  # If the node is connected to a CRDT, update that too.
177
  if hasattr(node, "_crdt"):
178
- # Go through JSON to simplify the types. CRDT can't handle enums.
179
- node._crdt["data"]["meta"] = json.loads(op.model_dump_json())
180
  print("set metadata to", op)
181
  if node.type != op.type:
182
  node.type = op.type
 
175
  data.meta = op
176
  # If the node is connected to a CRDT, update that too.
177
  if hasattr(node, "_crdt"):
178
+ node._crdt["data"]["meta"] = op.model_dump()
 
179
  print("set metadata to", op)
180
  if node.type != op.type:
181
  node.type = op.type
lynxkite-core/tests/test_ops.py CHANGED
@@ -54,7 +54,7 @@ def test_op_decorator_with_params_and_types_():
54
 
55
 
56
  def test_op_decorator_with_complex_types():
57
- class Color(enum.Enum):
58
  RED = 1
59
  GREEN = 2
60
  BLUE = 3
 
54
 
55
 
56
  def test_op_decorator_with_complex_types():
57
+ class Color(int, enum.Enum):
58
  RED = 1
59
  GREEN = 2
60
  BLUE = 3
lynxkite-graph-analytics/src/lynxkite_graph_analytics/ml_ops.py CHANGED
@@ -148,7 +148,7 @@ VIRIDIS = [
148
  ]
149
 
150
 
151
- class UMAPMetric(enum.Enum):
152
  l1 = "l1"
153
  cityblock = "cityblock"
154
  taxicab = "taxicab"
 
148
  ]
149
 
150
 
151
+ class UMAPMetric(str, enum.Enum):
152
  l1 = "l1"
153
  cityblock = "cityblock"
154
  taxicab = "taxicab"
lynxkite-graph-analytics/src/lynxkite_graph_analytics/pytorch/pytorch_ops.py CHANGED
@@ -65,7 +65,7 @@ def linear(x, *, output_dim=1024):
65
  return pyg_nn.Linear(-1, output_dim)
66
 
67
 
68
- class ActivationTypes(enum.Enum):
69
  ReLU = "ReLU"
70
  Leaky_ReLU = "Leaky ReLU"
71
  Tanh = "Tanh"
 
65
  return pyg_nn.Linear(-1, output_dim)
66
 
67
 
68
+ class ActivationTypes(str, enum.Enum):
69
  ReLU = "ReLU"
70
  Leaky_ReLU = "Leaky ReLU"
71
  Tanh = "Tanh"
lynxkite-lynxscribe/src/lynxkite_lynxscribe/llm_ops.py CHANGED
@@ -179,7 +179,7 @@ def branch(input, *, expression: str):
179
  return one_by_one.Output(output_handle=str(bool(res)).lower(), value=input)
180
 
181
 
182
- class RagEngine(enum.Enum):
183
  Chroma = "Chroma"
184
  Custom = "Custom"
185
 
 
179
  return one_by_one.Output(output_handle=str(bool(res)).lower(), value=input)
180
 
181
 
182
+ class RagEngine(str, enum.Enum):
183
  Chroma = "Chroma"
184
  Custom = "Custom"
185
 
lynxkite-lynxscribe/src/lynxkite_lynxscribe/lynxscribe_ops.py CHANGED
@@ -45,18 +45,18 @@ output_on_top = ops.output_position(output="top")
45
 
46
 
47
  # defining the cloud provider enum
48
- class CloudProvider(Enum):
49
  GCP = "gcp"
50
  AWS = "aws"
51
  AZURE = "azure"
52
 
53
 
54
- class RAGVersion(Enum):
55
  V1 = "v1"
56
  V2 = "v2"
57
 
58
 
59
- class MessageRole(Enum):
60
  SYSTEM = "system"
61
  USER = "user"
62
 
 
45
 
46
 
47
  # defining the cloud provider enum
48
+ class CloudProvider(str, Enum):
49
  GCP = "gcp"
50
  AWS = "aws"
51
  AZURE = "azure"
52
 
53
 
54
+ class RAGVersion(str, Enum):
55
  V1 = "v1"
56
  V2 = "v2"
57
 
58
 
59
+ class MessageRole(str, Enum):
60
  SYSTEM = "system"
61
  USER = "user"
62