-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance(datastore): tune datastore storage dir by swcli config (#902)
tune datastore storage dir by swcli config
- Loading branch information
1 parent
d418acc
commit 52cafb9
Showing
5 changed files
with
54 additions
and
41 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
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,14 +1,25 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
import unittest | ||
|
||
from starwhale.utils import config as sw_config | ||
from starwhale.consts import ENV_SW_CLI_CONFIG, ENV_SW_LOCAL_STORAGE | ||
from starwhale.utils.fs import empty_dir, ensure_dir | ||
|
||
|
||
class BaseTestCase(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.root = os.path.join(tempfile.gettempdir(), "datastore_test") | ||
os.makedirs(self.root, exist_ok=True) | ||
os.environ["SW_ROOT_PATH"] = self.root | ||
self._test_local_storage = tempfile.mkdtemp(prefix="sw-test-mock-") | ||
os.environ[ENV_SW_CLI_CONFIG] = os.path.join( | ||
self._test_local_storage, "config.yaml" | ||
) | ||
os.environ[ENV_SW_LOCAL_STORAGE] = self._test_local_storage | ||
sw_config._config = {} | ||
|
||
self.root = str(sw_config.SWCliConfigMixed().datastore_dir) | ||
ensure_dir(self.root) | ||
|
||
def tearDown(self) -> None: | ||
shutil.rmtree(self.root) | ||
empty_dir(self._test_local_storage) | ||
os.environ.pop(ENV_SW_CLI_CONFIG, "") | ||
os.environ.pop(ENV_SW_LOCAL_STORAGE, "") |
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