Skip to content

Commit 23815d8

Browse files
committed
remove _ENV_CONFIG in catalog
1 parent 6c798f2 commit 23815d8

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pyiceberg/catalog/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
RecursiveDict,
6767
TableVersion,
6868
)
69-
from pyiceberg.utils.config import Config, merge_config
69+
from pyiceberg.utils.config import Config, get_env_config, merge_config
7070
from pyiceberg.utils.properties import property_as_bool
7171
from pyiceberg.view import View
7272
from pyiceberg.view.metadata import ViewVersion
@@ -76,8 +76,6 @@
7676

7777
logger = logging.getLogger(__name__)
7878

79-
_ENV_CONFIG = Config()
80-
8179
TOKEN = "token"
8280
TYPE = "type"
8381
PY_CATALOG_IMPL = "py-catalog-impl"
@@ -228,7 +226,7 @@ def _check_required_catalog_properties(name: str, catalog_type: CatalogType, con
228226
)
229227

230228

231-
def load_catalog(name: str | None = None, **properties: str | None) -> Catalog:
229+
def load_catalog(name: str | None = None, config: Config | None = None, **properties: str | None) -> Catalog:
232230
"""Load the catalog based on the properties.
233231
234232
Will look up the properties from the config, based on the name.
@@ -244,10 +242,11 @@ def load_catalog(name: str | None = None, **properties: str | None) -> Catalog:
244242
ValueError: Raises a ValueError in case properties are missing or malformed,
245243
or if it could not determine the catalog based on the properties.
246244
"""
245+
config = config or get_env_config()
247246
if name is None:
248-
name = _ENV_CONFIG.get_default_catalog_name()
247+
name = config.get_default_catalog_name()
249248

250-
env = _ENV_CONFIG.get_catalog_config(name)
249+
env = config.get_catalog_config(name)
251250
conf: RecursiveDict = merge_config(env or {}, cast(RecursiveDict, properties))
252251

253252
catalog_type: CatalogType | None
@@ -279,8 +278,8 @@ def load_catalog(name: str | None = None, **properties: str | None) -> Catalog:
279278
raise ValueError(f"Could not initialize catalog with the following properties: {properties}")
280279

281280

282-
def list_catalogs() -> list[str]:
283-
return _ENV_CONFIG.get_known_catalogs()
281+
def list_catalogs(config: Config) -> list[str]:
282+
return config.get_known_catalogs()
284283

285284

286285
def delete_files(io: FileIO, files_to_delete: set[str], file_type: str) -> None:

0 commit comments

Comments
 (0)