is this error expected? ```TypeError: Object of t...
# prefect-community
k
is this error expected?
Copy code
TypeError: Object of type datetime is not JSON serializable
the relevant code is, outside the flow context:
Copy code
@task(result=PrefectResult())
def assert_db_trigger(event_name: str, events_fetcher: DailyFlowEvents, point_date: datetime):
    events = events_fetcher.fetch_events()
    while event_name not in events.keys() or events[event_name] < point_date:
        print(f"No trigger, yet for {event_name}")
        sleep(5)
        events = events_fetcher.fetch_events()
    return point_date
and
Copy code
point_datetime = datetime(year=point_date.year, month=point_date.month, day=point_date.day, hour=0, minute=0, second=0, microsecond=0, tzinfo=pytz.UTC)
and within the flow context:
Copy code
task_wait_for_reference_data_validated = assert_db_trigger("reference_data_validated", daily_flow_events, point_datetime)
do all function/method arguments need to be JSON serializable?
k
Hey @Kevin Weiler, This is correct, Prefect uses
cloudpickle
to serialize payloads between tasks to adhere to the Hybrid Model. Looks like your
datetime
object is causing this error to occur?
k
I think so - probably not a big deal, can construct this within the task most likely