-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: search current working directory for config file #1464
base: main
Are you sure you want to change the base?
Changes from all commits
5e47e97
3d85bf0
3ebbb8c
2bd6913
fe029fe
a838a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,12 +84,14 @@ def _load_yaml(directory: Optional[str]) -> Optional[RecursiveDict]: | |
return file_config_lowercase | ||
return None | ||
|
||
# Give priority to the PYICEBERG_HOME directory | ||
if pyiceberg_home_config := _load_yaml(os.environ.get(PYICEBERG_HOME)): | ||
return pyiceberg_home_config | ||
# Look into the home directory | ||
if pyiceberg_home_config := _load_yaml(os.path.expanduser("~")): | ||
return pyiceberg_home_config | ||
# Directories to search for the configuration file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: i like the comment on search order "PYICEBERG_HOME, home directory, then current directory" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a new line to show this in 2bd6913, is this what you are looking for? I just added back this comment underneath. |
||
# The current search order is: PYICEBERG_HOME, home directory, then current directory | ||
search_dirs = [os.environ.get(PYICEBERG_HOME), os.path.expanduser("~"), os.getcwd()] | ||
|
||
for directory in search_dirs: | ||
if config := _load_yaml(directory): | ||
return config | ||
|
||
# Didn't find a config | ||
return None | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: also add test https://grep.app/search?q=pyiceberg.yaml&filter[repo][0]=apache/iceberg-python&filter[path][0]=tests/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried adding a test here, but I wonder if there are opportunities to clean it up.