Fix graph champion version promotion
This commit is contained in:
parent
ea54d53bf8
commit
6b1e520845
1 changed files with 2 additions and 0 deletions
|
|
@ -64,12 +64,14 @@ def _champion_graph(spec) -> ExecutionGraphVersion:
|
|||
name=spec.name,
|
||||
defaults={"graph_type": spec.graph_type, "description": str(spec.metadata.get("description", ""))},
|
||||
)
|
||||
ExecutionGraphVersion.objects.filter(graph=definition, status=ExecutionGraphVersionStatus.CHAMPION).exclude(version=spec.version).update(status=ExecutionGraphVersionStatus.RETIRED)
|
||||
version, created = ExecutionGraphVersion.objects.get_or_create(
|
||||
graph=definition,
|
||||
version=spec.version,
|
||||
defaults={"status": ExecutionGraphVersionStatus.CHAMPION, "graph_spec": spec.to_dict(), "metadata": {"immutable_after_use": True}, "promoted_at": timezone.now()},
|
||||
)
|
||||
if not created and version.status != ExecutionGraphVersionStatus.CHAMPION:
|
||||
ExecutionGraphVersion.objects.filter(graph=definition, status=ExecutionGraphVersionStatus.CHAMPION).exclude(pk=version.pk).update(status=ExecutionGraphVersionStatus.RETIRED)
|
||||
version.status = ExecutionGraphVersionStatus.CHAMPION
|
||||
version.promoted_at = timezone.now()
|
||||
version.save(update_fields=["status", "promoted_at"])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue