-
Notifications
You must be signed in to change notification settings - Fork 978
Open
Description
When adding params using ArgoEvent.add_to_payload, the event triggered flows have JSONType params remain strings. I assume this would be solved by removing the string conversion in
self._payload[key] = str(value) |
json.dumps
later, but should the type be validated when the parameter is loaded?
For example:
# trivial_flow.py
from metaflow import FlowSpec, step, trigger, Parameter, JSONType
@trigger(event="trigger_trivial")
class TrivialFlow(FlowSpec):
p1 = Parameter("p1", default={"a": 1, "b": "asdf"}, type=JSONType)
@step
def start(self):
print(f"p1: {self.p1}, {type(self.p1)}, {isinstance(self.p1, dict)}")
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
TrivialFlow()
# trivial_trigger_flow.py
from metaflow import FlowSpec, step
from metaflow.integrations import ArgoEvent
class TrivialTriggerFlow(FlowSpec):
@step
def start(self):
test_dict = {"c": 100, "d": "qwer"}
# results in: p1: {c: 100, d: qwer}, <class 'str'>, False
event = ArgoEvent("trigger_trivial")
event.add_to_payload("p1", test_dict)
event.safe_publish()
# results in: p1: {'c': 100, 'd': 'qwer'}, <class 'dict'>, True
event2 = ArgoEvent("trigger_trivial")
event2.safe_publish(payload=dict(p1=test_dict))
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
TrivialTriggerFlow()
Metadata
Metadata
Assignees
Labels
No labels