Hi, I'm trying to build out a registration process...
# ask-community
s
Hi, I'm trying to build out a registration process that uses
flow.serialized_hash()
to only register the modified flows. However,
flow.serialized_hash()
is not returning a consistent hash value for flows that have not been modified. Why would this be the case? For context, I'm testing by registering the flows locally with
flow.register()
k
Hey @Samuel Kohlleffel, just to make sure, you’re doing something like
flow.register(…, idempotency_key=flow.serialized_hash())
, or are you just running
flow.serialized_hash()
multiple times and comparing the values?
s
@Kevin Kho I initially was trying
flow.register(…, idempotency_key=flow.serialized_hash())
but that wasn't working for me, so then I tried to just test
flow.serialized_hash()
by running it and comparing the values on independent registration runs. I also compared the
flow.serialize()
values on independent runs and those are different values as well.
k
Will ask the team more about this and get back to you
s
Ok, thanks
After doing a little more digging, it looks like the difference in
flow.serialize()
is the following: Test 1:
"start_date": {"dt": "2021-08-03T10:47:33.780910"
Test2:
"start_date": {"dt": "2021-08-03T10:49:13.281844"
Does the time of registration impact the
flow.serialize()
return value?
@Kevin Kho Here's the entire json key/value for reference:
"clocks": [{"__version__": "0.15.1", "cron": "20 6 * * *", "day_or": true, "end_date": null, "labels": null, "parameter_defaults": {}, "start_date": {"dt": "2021-08-03T10:49:13.281844", "tz": "America/Chicago"}, "type": "CronClock"}],
k
Can you give me the code for the Flow block? I guess it good if the clock start time if being moved. I’ll try this myself.
s
start_date = pendulum.now(tz="America/Chicago")
clocks = [CronClock(s, start_date=start_date) for s in cron_strings]
run_schedule = create_cron_schedule("20 6 * * *")
with Flow(
    
name="netchb-to-snowflake",
    
schedule=netchb_run_schedule,
) as flow:
   
flow.chain(task chain...)
I think I understand the problem now. We are using the optional
start_date
parameter when building the Cron schedule. The
start_date
value is then used in the
flow.serialize()
json object which in turn causes inconsistent hash values because we are using
pendulum.now(tz="America/Chicago")
as the
start_date
.
k
I see. I’ll ask the team about how to approach this.
Hey @Samuel Kohlleffel, so this is expected behavior, otherwise we would not be able to re-register flows that have start dates changes. Something you can to in this the
start_date
to the first of the year for something in the past so that the
serialized_hash
will stay the same.
s
That worked, thanks!
👍 1