From e83de6ef372a23c03631f3ecce916b4f157dda56 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Sun, 26 Feb 2023 13:49:32 +0100 Subject: [PATCH] Wait for repodata_record.json to appear --- conda_lock/conda_solver.py | 49 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/conda_lock/conda_solver.py b/conda_lock/conda_solver.py index c698d9c80..0824adb6d 100644 --- a/conda_lock/conda_solver.py +++ b/conda_lock/conda_solver.py @@ -217,6 +217,41 @@ def print_pkgs_dirs_contents(pkgs_dirs: List[pathlib.Path]) -> None: print(entry) +def get_repodata_record( + pkgs_dirs: List[pathlib.Path], dist_name: str +) -> Optional[FetchAction]: + import time + + for pkgs_dir in pkgs_dirs: + record = pkgs_dir / dist_name / "info" / "repodata_record.json" + if record.exists(): + with open(record) as f: + repodata: FetchAction = json.load(f) + return repodata + print(f"Could not find repodata_record.json for {dist_name} in {pkgs_dirs}") + for _ in range(200): + for pkgs_dir in pkgs_dirs: + for path in pkgs_dir.glob(f"{dist_name}*"): + if path.is_file(): + print(f"File: {path}") + elif path.is_dir(): + print(f"Directory: {path}") + if path.name == dist_name: + print("Contents:") + for entry in path.iterdir(): + print(f" {entry}") + if entry.name == "info": + for info_entry in entry.iterdir(): + print(f" {info_entry}") + if info_entry.name == "repodata_record.json": + with open(info_entry) as f: + print(f.read()) + print("We would have been able to use this.") + return None + time.sleep(0.1) + return None + + def _reconstruct_fetch_actions( conda: PathLike, platform: str, @@ -259,18 +294,8 @@ def _reconstruct_fetch_actions( for link_pkg_name in link_only_names: link_action = link_actions[link_pkg_name] - for pkgs_dir in pkgs_dirs: - record = ( - pkgs_dir - / link_action["dist_name"] - / "info" - / "repodata_record.json" - ) - if record.exists(): - with open(record) as f: - repodata: FetchAction = json.load(f) - break - else: + repodata = get_repodata_record(pkgs_dirs, link_action["dist_name"]) + if repodata is None: print(f"\n\n---\n{link_pkg_name=}\n\n---\n{link_action=}") print_pkgs_dirs_contents(pkgs_dirs) raise FileNotFoundError(