-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new_model_integrations
- Loading branch information
Showing
16 changed files
with
187 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Utilities for directory operations.""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
|
||
def resolve_model_path(search_path: str, model_id: str) -> Path: | ||
"""Find the first path under search_path for model_id. All entries in | ||
search_path must be: | ||
* an existing directory | ||
* must be readable by the current process | ||
Args: | ||
search_path (str): A unix-like ":" separated list of directories such a "dir1:dir2" | ||
model_id (str): a model_id (which is really just a subdirectory under dir1 or dir2) | ||
Returns: | ||
Path: the first matching path, None if no path is fount. | ||
""" | ||
|
||
_amodeldir_found = next( | ||
( | ||
adir | ||
for adir in (Path(p) for p in search_path.split(":")) | ||
if adir.exists() | ||
and adir.is_dir() | ||
and os.access(adir, os.R_OK) | ||
and (adir / model_id).exists() | ||
and os.access(adir / model_id, os.R_OK) | ||
), | ||
None, | ||
) | ||
if not _amodeldir_found: | ||
return None | ||
return _amodeldir_found / model_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
inference_payloads.py | ||
hfutil.py | ||
# THIS FILE IS AUTOMATICALLY GENERATED, YOUR CHANGES WILL BE OVERWRITTEN | ||
dataframe_checks.py | ||
dirutil.py | ||
errors.py | ||
hfutil.py | ||
inference_payloads.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
# These version placeholders will be replaced later during substitution. | ||
__version__ = "0.0.0" | ||
__version_tuple__ = (0, 0, 0) | ||
prometheus_metrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
inference_payloads.py | ||
# THIS FILE IS AUTOMATICALLY GENERATED, YOUR CHANGES WILL BE OVERWRITTEN | ||
dataframe_checks.py | ||
dirutil.py | ||
errors.py | ||
hfutil.py | ||
dataframe_checks.py | ||
inference_payloads.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from tsfminference.dirutil import resolve_model_path | ||
|
||
|
||
def test_resolve_model_path(): | ||
with tempfile.TemporaryDirectory() as dir1: | ||
with tempfile.TemporaryDirectory() as dir2: | ||
dirpath = f"{dir1}:{dir2}" | ||
os.mkdir(Path(dir1) / "amodel") | ||
assert resolve_model_path(dirpath, "amodel") == Path(dir1) / "amodel" | ||
assert resolve_model_path(dirpath, "foobar") is None | ||
assert resolve_model_path("fzbatt:zap", "amodel") is None | ||
os.mkdir(Path(dir2) / "anewmodel") | ||
assert resolve_model_path(dirpath, "anewmodel") == Path(dir2) / "anewmodel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.