From e5a040d91c3fa7b2ff06abc3bc750e506d88d23f Mon Sep 17 00:00:00 2001 From: Moritz Date: Mon, 24 Aug 2026 23:51:15 +0200 Subject: [PATCH] fix(fetch recipes): use abra recipe lint instead of fetch --- alakazam.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/alakazam.py b/alakazam.py index 29cc4cd..038e10f 100755 --- a/alakazam.py +++ b/alakazam.py @@ -414,7 +414,7 @@ def is_connection_error(output: str) -> bool: return any(error in output.lower() for error in CONNECTION_ERRORS) -def abra(*args: str, machine_output: bool = False, ignore_error: bool = False) -> Union[str,Dict]: +def abra(*args: str, machine_output: bool = False, ignore_error: bool = False, offline: bool = True) -> Union[str,Dict]: """ Execute the 'abra' command with the specified arguments. This function acts as a wrapper around the 'abra' CLI tool. It allows for capturing the output and optionally returning it as machine-readable JSON. @@ -422,6 +422,7 @@ def abra(*args: str, machine_output: bool = False, ignore_error: bool = False) - *args: Variable length argument list representing the 'abra' command and its parameters. machine_output (bool): If True, expects the output in JSON format and parses it before returning. ignore_error (bool): If True, suppresses the raising of errors on non-zero return codes, otherwise an exception is raised. + offline (bool): If True, abra runs with -o and never touches the recipe git repos, this is the default for every call but the recipe refresh. Returns: str or dict: Returns the output from the 'abra' command. If machine_output is True, returns a dictionary, otherwise returns raw output as a string. @@ -429,7 +430,7 @@ def abra(*args: str, machine_output: bool = False, ignore_error: bool = False) - Raises: RuntimeError: If the 'abra' command exits with a non-zero return code and ignore_error is False, including the command output in the error. """ - command = ["abra", "-o", *args] + command = ["abra", "-o" if offline else "", *args] #remove empty elements command = [arg for arg in command if arg] if machine_output: @@ -466,6 +467,9 @@ def fetch_recipes(instance_configs: Dict[str, Dict[str, Any]]) -> None: Since every abra call runs with -o, the recipe git repos are never pulled implicitly. The mtime of `/.git/FETCH_HEAD` is used as the marker. + `abra recipe fetch` only clones a missing recipe, so an online `abra recipe + lint` is used instead: it pulls both the recipe repo and the recipe catalogue. + Args: instance_configs (dict): Merged instance configurations """ @@ -476,7 +480,10 @@ def fetch_recipes(instance_configs: Dict[str, Dict[str, Any]]) -> None: logging.debug(f"recipe {recipe} was fetched less than {FETCH_MAX_AGE}s ago, skip") continue logging.info(f"fetch recipe {recipe}") - abra("recipe", "fetch", "-f", recipe, ignore_error=True) + try: + abra("recipe", "lint", recipe, offline=False) + except RuntimeError as e: + logging.debug(f"could not fetch recipe {recipe}: {e}") if fetch_head.parent.is_dir(): fetch_head.touch()