-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wei-chenglai <[email protected]>
- Loading branch information
Showing
15 changed files
with
89 additions
and
196 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
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 +1 @@ | ||
huggingface_hub==0.23.4 | ||
huggingface-hub>=0.27.0,<0.28 |
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,23 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def mock_env_vars(): | ||
"""Fixture to set and clean up environment variables""" | ||
original_env = dict(os.environ) | ||
|
||
def _set_env_vars(**kwargs): | ||
for key, value in kwargs.items(): | ||
if value is None: | ||
os.environ.pop(key, None) | ||
else: | ||
os.environ[key] = str(value) | ||
return os.environ | ||
|
||
yield _set_env_vars | ||
|
||
# Cleanup | ||
os.environ.clear() | ||
os.environ.update(original_env) |
Empty file.
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
Empty file.
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
Empty file.
Empty file.
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,6 +0,0 @@ | ||
import os | ||
import sys | ||
|
||
sys.path.insert( | ||
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../")) | ||
) | ||
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,47 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def setup_temp_path(monkeypatch): | ||
"""Creates temporary directory and patches path constant. | ||
This fixture: | ||
1. Creates a temporary directory | ||
2. Allows configuration of path constant | ||
3. Handles automatic cleanup after tests | ||
4. Restores original environment state | ||
Args: | ||
monkeypatch: pytest fixture for modifying objects | ||
Returns: | ||
function: A configurator that accepts path_var (str) and returns temp_dir path | ||
Usage: | ||
def test_something(setup_temp_path): | ||
temp_dir = setup_temp_path("MODEL_PATH") | ||
# temp_dir is created and MODEL_PATH is patched | ||
# cleanup happens automatically after test | ||
""" | ||
# Setup | ||
original_env = dict(os.environ) | ||
current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
temp_dir = tempfile.mkdtemp(dir=current_dir) | ||
|
||
def configure_path(path_var: str): | ||
"""Configure path variable in kubeflow.training""" | ||
import kubeflow.training as training | ||
|
||
monkeypatch.setattr(training, path_var, temp_dir) | ||
return temp_dir | ||
|
||
yield configure_path | ||
|
||
# Cleanup temp directory after test | ||
shutil.rmtree(temp_dir, ignore_errors=True) | ||
os.environ.clear() | ||
os.environ.update(original_env) |
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.