From 3d06688117593eac9727485a996764db812de94c Mon Sep 17 00:00:00 2001 From: Chris White Date: Wed, 14 Oct 2020 11:55:06 -0700 Subject: [PATCH] Ensure empty label lists are disambiguated from None --- src/prefect_server/api/flows.py | 2 +- tests/api/test_flows.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/prefect_server/api/flows.py b/src/prefect_server/api/flows.py index 0fa1e8c2..2bd85be3 100644 --- a/src/prefect_server/api/flows.py +++ b/src/prefect_server/api/flows.py @@ -545,7 +545,7 @@ async def schedule_flow_runs(flow_id: str, max_runs: int = None) -> List[str]: # if the event has parameter defaults or labels, we do allow for # same-time scheduling - if event.parameter_defaults or event.labels: + if event.parameter_defaults or event.labels is not None: md5 = hashlib.md5() param_string = str(sorted(json.dumps(event.parameter_defaults))) label_string = str(sorted(json.dumps(event.labels))) diff --git a/tests/api/test_flows.py b/tests/api/test_flows.py index c1ce5bc6..e35feef5 100644 --- a/tests/api/test_flows.py +++ b/tests/api/test_flows.py @@ -1142,6 +1142,10 @@ async def test_doesnt_schedule_same_time_twice(self, project_id): [dict(parameter_defaults=dict(x="a")), dict(labels=["b"])], [dict(labels=["c", "d"]), dict(labels=["c"])], [dict(labels=None), dict(labels=["ef"])], + [ + dict(labels=None), + dict(labels=[]), + ], # the scheduler should distinguish between none vs. empty ], ) async def test_allows_for_same_time_if_event_attrs_are_different(