Fix src import on HF cache: use absolute() not resolve() (symlink)
Browse files- forecast.py +6 -2
forecast.py
CHANGED
|
@@ -36,8 +36,12 @@ import yaml
|
|
| 36 |
# Make the vendored TempoPFN package importable as `src.*`.
|
| 37 |
# Works both in the CODE-SHARE layout (inference/forecast.py + ../tempopfn) and
|
| 38 |
# in a flat HF repo (forecast.py + ./tempopfn at the same level).
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
if (_cand / "src").is_dir():
|
| 42 |
sys.path.insert(0, str(_cand))
|
| 43 |
break
|
|
|
|
| 36 |
# Make the vendored TempoPFN package importable as `src.*`.
|
| 37 |
# Works both in the CODE-SHARE layout (inference/forecast.py + ../tempopfn) and
|
| 38 |
# in a flat HF repo (forecast.py + ./tempopfn at the same level).
|
| 39 |
+
#
|
| 40 |
+
# NOTE: use .absolute() and NOT .resolve(): on the Hugging Face Hub cache, files in
|
| 41 |
+
# snapshots/<commit>/ are *symlinks* into blobs/. .resolve() would follow the symlink
|
| 42 |
+
# into blobs/ (where `tempopfn/` does not sit beside the file), breaking the import.
|
| 43 |
+
_HERE = Path(__file__).absolute().parent
|
| 44 |
+
for _cand in (_HERE, _HERE / "tempopfn", _HERE.parent, _HERE.parent / "tempopfn"):
|
| 45 |
if (_cand / "src").is_dir():
|
| 46 |
sys.path.insert(0, str(_cand))
|
| 47 |
break
|