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
7070from pyiceberg .utils .properties import property_as_bool
7171from pyiceberg .view import View
7272from pyiceberg .view .metadata import ViewVersion
7676
7777logger = logging .getLogger (__name__ )
7878
79- _ENV_CONFIG = Config ()
80-
8179TOKEN = "token"
8280TYPE = "type"
8381PY_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
286285def delete_files (io : FileIO , files_to_delete : set [str ], file_type : str ) -> None :
0 commit comments