"...text-generation-inference.git" did not exist on "54fec9319371b2792526e0cbfebe6cee66ed3980"
Unverified Commit 53f498d2 authored by Charchit Sharma's avatar Charchit Sharma Committed by GitHub
Browse files

Use of Posix to better support Windows compatibility in testing_utils (#6587)

* changes in utils

* removed loc
parent 99086091
...@@ -137,7 +137,7 @@ def get_tests_dir(append_path=None): ...@@ -137,7 +137,7 @@ def get_tests_dir(append_path=None):
tests_dir = os.path.dirname(tests_dir) tests_dir = os.path.dirname(tests_dir)
if append_path: if append_path:
return os.path.join(tests_dir, append_path) return Path(tests_dir, append_path).as_posix()
else: else:
return tests_dir return tests_dir
...@@ -335,10 +335,9 @@ def require_python39_or_higher(test_case): ...@@ -335,10 +335,9 @@ def require_python39_or_higher(test_case):
def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -> np.ndarray: def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -> np.ndarray:
if isinstance(arry, str): if isinstance(arry, str):
# local_path = "/home/patrick_huggingface_co/"
if local_path is not None: if local_path is not None:
# local_path can be passed to correct images of tests # local_path can be passed to correct images of tests
return os.path.join(local_path, "/".join([arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]])) return Path(local_path, arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]).as_posix()
elif arry.startswith("http://") or arry.startswith("https://"): elif arry.startswith("http://") or arry.startswith("https://"):
response = requests.get(arry) response = requests.get(arry)
response.raise_for_status() response.raise_for_status()
...@@ -521,9 +520,9 @@ def export_to_video(video_frames: List[np.ndarray], output_video_path: str = Non ...@@ -521,9 +520,9 @@ def export_to_video(video_frames: List[np.ndarray], output_video_path: str = Non
def load_hf_numpy(path) -> np.ndarray: def load_hf_numpy(path) -> np.ndarray:
if not path.startswith("http://") or path.startswith("https://"): if not path.startswith("http://") or path.startswith("https://"):
path = os.path.join( path = Path(
"https://huggingface.co/datasets/fusing/diffusers-testing/resolve/main", urllib.parse.quote(path) "https://huggingface.co/datasets/fusing/diffusers-testing/resolve/main", urllib.parse.quote(path)
) ).as_posix()
return load_numpy(path) return load_numpy(path)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment