forked from modelscope/modelscope
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor zero sized file downloading (modelscope#991)
- Loading branch information
1 parent
4c518db
commit 74d97ea
Showing
2 changed files
with
39 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) Alibaba, Inc. and its affiliates. | ||
import os.path | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
||
from modelscope import snapshot_download | ||
|
||
|
||
class HubEmptyFile(unittest.TestCase): | ||
|
||
def setUp(self): | ||
temporary_dir = tempfile.mkdtemp() | ||
self.work_dir = temporary_dir | ||
|
||
def tearDown(self): | ||
shutil.rmtree(self.work_dir, ignore_errors=True) | ||
|
||
def test_download_empty_file(self): | ||
model_dir = snapshot_download( | ||
'tastelikefeet/test_empty_download', cache_dir=self.work_dir) | ||
self.assertTrue(model_dir is not None) | ||
self.assertTrue(os.path.exists(os.path.join(model_dir, '1.txt'))) | ||
self.assertTrue( | ||
os.path.exists(os.path.join(model_dir, 'configuration.json'))) | ||
self.assertTrue(os.path.exists(os.path.join(model_dir, 'init.py'))) | ||
self.assertTrue(os.path.exists(os.path.join(model_dir, 'README.md'))) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |