Skip to content

Commit 33e8f36

Browse files
committed
feat: search current working directory for config file
1 parent 119abe0 commit 33e8f36

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

mkdocs/docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ hide:
2828

2929
There are three ways to pass in configuration:
3030

31-
- Using the `~/.pyiceberg.yaml` configuration file
31+
- Using the `.pyiceberg.yaml` configuration file stored in either the directory specified by the `PYICEBERG_HOME` environment variable, the home directory, or current working directory.
3232
- Through environment variables
3333
- By passing in credentials through the CLI or the Python API
3434

pyiceberg/utils/config.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ def _load_yaml(directory: Optional[str]) -> Optional[RecursiveDict]:
8484
return file_config_lowercase
8585
return None
8686

87-
# Give priority to the PYICEBERG_HOME directory
88-
if pyiceberg_home_config := _load_yaml(os.environ.get(PYICEBERG_HOME)):
89-
return pyiceberg_home_config
90-
# Look into the home directory
91-
if pyiceberg_home_config := _load_yaml(os.path.expanduser("~")):
92-
return pyiceberg_home_config
87+
# Directories to search for the configuration file
88+
search_dirs = [os.environ.get(PYICEBERG_HOME), os.path.expanduser("~"), os.getcwd()]
89+
90+
for directory in search_dirs:
91+
if config := _load_yaml(directory):
92+
return config
93+
9394
# Didn't find a config
9495
return None
9596

0 commit comments

Comments
 (0)