From 20f1dd1bfd88aa81f8b629032dfbe8cfd51128da Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:35:09 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/anemoi/inference/checkpoint.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/anemoi/inference/checkpoint.py b/src/anemoi/inference/checkpoint.py index cdf34bf..5a1754d 100644 --- a/src/anemoi/inference/checkpoint.py +++ b/src/anemoi/inference/checkpoint.py @@ -11,8 +11,8 @@ import datetime import logging from collections import defaultdict -from pathlib import Path from functools import cached_property +from pathlib import Path from anemoi.utils.checkpoints import load_metadata from earthkit.data.utils.dates import to_datetime @@ -25,19 +25,22 @@ def _download_huggingfacehub(huggingface_config): """Download model from huggingface""" try: - from huggingface_hub import hf_hub_download, snapshot_download + from huggingface_hub import hf_hub_download + from huggingface_hub import snapshot_download except ImportError as e: raise ImportError("Could not import `huggingface_hub`, please run `pip install huggingface_hub`.") from e - if 'filename' in huggingface_config: + if "filename" in huggingface_config: config_path = hf_hub_download(**huggingface_config) else: repo_path = Path(snapshot_download(**huggingface_config)) - ckpt_files = list(repo_path.glob('*.ckpt')) + ckpt_files = list(repo_path.glob("*.ckpt")) if len(ckpt_files) == 1: return str(ckpt_files[0]) else: - ValueError(f"Multiple ckpt files found in repo, {ckpt_files}.\nCannot pick one to load, please specify `filename`.") + ValueError( + f"Multiple ckpt files found in repo, {ckpt_files}.\nCannot pick one to load, please specify `filename`." + ) return config_path