Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST calling delete_repo under tempfile for fixing the test #804

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 10 additions & 37 deletions tests/test_keras_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,33 +370,6 @@ def test_push_to_hub_model_card_plot_false(self):
self.assertFalse("model.png" in [f.rfilename for f in model_info.siblings])
self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)

@retry_endpoint
def test_push_to_hub_tensorboard(self):
REPO_NAME = "PUSH_TO_HUB"
with tempfile.TemporaryDirectory() as tmpdirname:
os.makedirs(f"{tmpdirname}/log_dir")
with open(f"{tmpdirname}/log_dir/tensorboard.txt", "w") as fp:
fp.write("Keras FTW")
model = self.model_init()
model = self.model_fit(model)
push_to_hub_keras(
model,
repo_path_or_name=f"{WORKING_REPO_DIR}/{REPO_NAME}",
log_dir=f"{tmpdirname}/log_dir",
api_endpoint=ENDPOINT_STAGING,
use_auth_token=self._token,
git_user="ci",
git_email="ci@dummy.com",
)
model_info = HfApi(endpoint=ENDPOINT_STAGING).model_info(
f"{USER}/{REPO_NAME}",
)

self.assertTrue(
"logs/tensorboard.txt" in [f.rfilename for f in model_info.siblings]
)
self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)

@retry_endpoint
def test_override_tensorboard(self):
REPO_NAME = repo_name("PUSH_TO_HUB")
Expand Down Expand Up @@ -428,17 +401,17 @@ def test_override_tensorboard(self):
git_email="ci@dummy.com",
)

model_info = HfApi(endpoint=ENDPOINT_STAGING).model_info(
f"{USER}/{REPO_NAME}",
)
self.assertTrue(
"logs/override.txt" in [f.rfilename for f in model_info.siblings]
)
self.assertFalse(
"logs/tensorboard.txt" in [f.rfilename for f in model_info.siblings]
)
model_info = HfApi(endpoint=ENDPOINT_STAGING).model_info(
f"{USER}/{REPO_NAME}",
)
self.assertTrue(
"logs/override.txt" in [f.rfilename for f in model_info.siblings]
)
self.assertFalse(
"logs/tensorboard.txt" in [f.rfilename for f in model_info.siblings]
)

self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)
self._api.delete_repo(repo_id=f"{REPO_NAME}", token=self._token)

@retry_endpoint
def test_push_to_hub_model_kwargs(self):
Expand Down