As part of our CICD we have a script that register...
# ask-community
c
As part of our CICD we have a script that registers flows for us; I've noticed that our script ends up generating new versions of flows even though nothing changed about the flow. So, in order to debug this, I wrote some debugging statements during CICD:
Copy code
if not args.dry_run:
        project = args.project
        logger.log(SUCCESS, f"Registering flow '{flow.name}' to project '{project}'.")
        logger.debug(f"Serialized flow: {json.dumps(flow.serialize(), indent=4, sort_keys=True)}")
        logger.debug(f"Hashed flow: {flow.serialized_hash()}")
        flow.register(
            project_name=project,
            idempotency_key=flow.serialized_hash(),
            set_schedule_active=set_schedule_active,
        )
I noticed that on back to back execution of the above script, for the same flow, to the same project, different hashes were being created. When I look at the
serialized_hash
of those flows I see no difference. To confirm the serialized flows are the same, I've saved the logging output to two json files (see screenshot). The only difference I can spot is that is use
indent=4
in my json.dumps however the codebase does not.
k
Hey, will test this myself and see if the version bumps up for me
Can I see how you define your schedule? And do you have any date or time based parameters?
My version is not bumping up when I try this
c
This is how I call the code snippet shown above:
Copy code
freezer = freeze_time("2021-01-14 22:00:00")
freezer.start()
for flow_file, flow in flows.items():
  register_flow(flow, flow_file, args)
freezer.stop()
I do this to ensure any calls to
now()
evaluate to the same thing. I think this addresses your question about any dates or times
Schedule is being set like
Copy code
flow.schedule = CronSchedule(("00 10 * * *", start_date=pendulum.datetime(2021, 1, 1, tz=tz))
k
This looks right to me.
I think I might need a minimum example for this one to debug further
c
yeah seems reasonable; lemme put a pin in this and remove adjust some of my debugging statements. I'll report back with what I find
d
Do you have in your flow any parameter with a default value that could change Everytime you register? Like datetime.now