Skip to content

Commit

Permalink
fix:Make db_name recognizable.
Browse files Browse the repository at this point in the history
  • Loading branch information
KenyonY committed Dec 26, 2023
1 parent c119fee commit 8ecad0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions flaxkv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from .core import LevelDBDict, LMDBDict, RemoteDBDict

__version__ = "0.2.1"
__version__ = "0.2.2"

__all__ = [
"FlaxKV",
Expand All @@ -36,7 +36,7 @@
def FlaxKV(
db_name: str,
root_path_or_url: str = ".",
backend='lmdb',
backend='leveldb',
rebuild=False,
raw=False,
**kwargs,
Expand Down
2 changes: 1 addition & 1 deletion flaxkv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ def __init__(
else:
logger.disable('flaxkv')

self._db_name = db_name
self._db_manager = DBManager(
db_type=db_type,
root_path_or_url=root_path_or_url,
db_name=db_name,
rebuild=rebuild,
**kwargs,
)
self._db_name = self._db_manager.db_name
self._raw = raw
self._cache_all_data = cache
self._register_auto_close()
Expand Down
5 changes: 3 additions & 2 deletions flaxkv/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(
url_pattern = re.compile(r'^(http://|https://|ftp://)')
if url_pattern.match(root_path_or_url):
self.db_address = root_path_or_url
self.db_name = f"{db_name}-{kwargs.get('backend', 'leveldb')}"
else:
self.db_address = os.path.join(
root_path_or_url, f"{db_name}-{self.db_type}"
Expand Down Expand Up @@ -85,7 +86,7 @@ def connect(self, **kwargs):
env = RemoteTransaction(
base_url=self.db_address,
db_name=self.db_name,
backend=kwargs.pop("backend", "lmdb"),
backend=kwargs.pop("backend", "leveldb"),
rebuild=self._rebuild,
timeout=kwargs.pop("timeout", 15),
**kwargs,
Expand Down Expand Up @@ -210,7 +211,7 @@ def __init__(
self,
base_url: str,
db_name: str,
backend="lmdb",
backend="leveldb",
rebuild=False,
timeout=15,
**kwargs,
Expand Down

0 comments on commit 8ecad0f

Please sign in to comment.