From 4f65a7954566394fe11964d473699f373f539a81 Mon Sep 17 00:00:00 2001 From: "D. Paolella" Date: Wed, 1 Mar 2023 11:08:45 +0100 Subject: [PATCH] Purge occurrences of loop.run_until_complete() --- doozerlib/cli/release_gen_assembly.py | 43 +++++++++++++-------------- doozerlib/cli/release_gen_payload.py | 17 +++++------ 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/doozerlib/cli/release_gen_assembly.py b/doozerlib/cli/release_gen_assembly.py index be97466fb..cb43b1b39 100644 --- a/doozerlib/cli/release_gen_assembly.py +++ b/doozerlib/cli/release_gen_assembly.py @@ -10,7 +10,7 @@ from doozerlib import util from doozerlib.assembly import AssemblyTypes -from doozerlib.cli import cli, pass_runtime +from doozerlib.cli import cli, pass_runtime, click_coroutine from doozerlib import exectools from doozerlib.model import Model from doozerlib import brew @@ -58,31 +58,30 @@ def releases_gen_assembly(ctx, name): @click.option('--output-file', '-o', required=False, help='Specify a file path to write the generated assembly definition to') @pass_runtime +@click_coroutine @click.pass_context -def gen_assembly_from_releases(ctx, runtime: Runtime, nightlies: Tuple[str, ...], standards: Tuple[str, ...], - custom: bool, in_flight: Optional[str], previous_list: Tuple[str, ...], - auto_previous: bool, graph_url: Optional[str], graph_content_stable: Optional[str], - graph_content_candidate: Optional[str], suggestions_url: Optional[str], - output_file: Optional[str]): +async def gen_assembly_from_releases(ctx, runtime: Runtime, nightlies: Tuple[str, ...], standards: Tuple[str, ...], + custom: bool, in_flight: Optional[str], previous_list: Tuple[str, ...], + auto_previous: bool, graph_url: Optional[str], graph_content_stable: Optional[str], + graph_content_candidate: Optional[str], suggestions_url: Optional[str], + output_file: Optional[str]): runtime.initialize(mode='both', clone_distgits=False, clone_source=False, prevent_cloning=True) - assembly_def = asyncio.get_event_loop().run_until_complete( - GenAssemblyCli( - runtime=runtime, - gen_assembly_name=ctx.obj['ASSEMBLY_NAME'], - nightlies=nightlies, - standards=standards, - custom=custom, - in_flight=in_flight, - previous_list=previous_list, - auto_previous=auto_previous, - graph_url=graph_url, - graph_content_stable=graph_content_stable, - graph_content_candidate=graph_content_candidate, - suggestions_url=suggestions_url, - ).run() - ) + assembly_def = await GenAssemblyCli( + runtime=runtime, + gen_assembly_name=ctx.obj['ASSEMBLY_NAME'], + nightlies=nightlies, + standards=standards, + custom=custom, + in_flight=in_flight, + previous_list=previous_list, + auto_previous=auto_previous, + graph_url=graph_url, + graph_content_stable=graph_content_stable, + graph_content_candidate=graph_content_candidate, + suggestions_url=suggestions_url, + ).run() print(yaml.dump(assembly_def)) if output_file: diff --git a/doozerlib/cli/release_gen_payload.py b/doozerlib/cli/release_gen_payload.py index c80b49b20..fb134c39f 100644 --- a/doozerlib/cli/release_gen_payload.py +++ b/doozerlib/cli/release_gen_payload.py @@ -18,7 +18,7 @@ from doozerlib.brew import KojiWrapperMetaReturn from doozerlib.rhcos import RHCOSBuildInspector, RhcosMissingContainerException -from doozerlib.cli import cli, pass_runtime +from doozerlib.cli import cli, pass_runtime, click_coroutine from doozerlib.image import ImageMetadata, BrewBuildImageInspector, ArchiveImageInspector from doozerlib.assembly_inspector import AssemblyInspector from doozerlib.runtime import Runtime @@ -57,11 +57,12 @@ help="Also create a release payload for multi-arch/heterogeneous clusters.") @click.option("--moist-run", default=False, is_flag=True, help="Mirror and determine tags but do not actually update imagestreams.") +@click_coroutine @pass_runtime -def release_gen_payload(runtime: Runtime, is_name: str, is_namespace: str, organization: str, - repository: str, release_repository: str, output_dir: str, exclude_arch: Tuple[str, ...], - skip_gc_tagging: bool, emergency_ignore_issues: bool, - apply: bool, apply_multi_arch: bool, moist_run: bool): +async def release_gen_payload(runtime: Runtime, is_name: str, is_namespace: str, organization: str, + repository: str, release_repository: str, output_dir: str, exclude_arch: Tuple[str, ...], + skip_gc_tagging: bool, emergency_ignore_issues: bool, + apply: bool, apply_multi_arch: bool, moist_run: bool): """ Computes a set of imagestream tags which can be assembled into an OpenShift release for this assembly. The tags may not be valid unless --apply or --moist-run triggers mirroring. @@ -107,7 +108,7 @@ def release_gen_payload(runtime: Runtime, is_name: str, is_namespace: str, organ """ runtime.initialize(mode="both", clone_distgits=False, clone_source=False, prevent_cloning=True) - pipeline = GenPayloadCli( + await GenPayloadCli( runtime, is_name or assembly_imagestream_base_name(runtime), is_namespace or default_imagestream_namespace_base_name(), @@ -116,9 +117,7 @@ def release_gen_payload(runtime: Runtime, is_name: str, is_namespace: str, organ exclude_arch, skip_gc_tagging, emergency_ignore_issues, apply, apply_multi_arch, moist_run - ) - - asyncio.get_event_loop().run_until_complete(pipeline.run()) + ).run() def default_imagestream_base_name(version: str) -> str: