darabos commited on
Commit
6cdf515
·
1 Parent(s): f9098d0

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"