Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix: snowflake python connector default config dir (#125)
<!--- Provide a general summary of your changes in the Title above --> ## Description Snowflake python connector have a logic to get default[ root directory for configurations](https://github.com/snowflakedb/snowflake-connector-python/blob/9ddb2050cde13819a289fb6982b48431f253a53e/src/snowflake/connector/sf_dirs.py#L47): ```python def _resolve_platform_dirs() -> PlatformDirsProto: """Decide on what PlatformDirs class to use. In case a folder exists (which can be customized with the environmental variable `SNOWFLAKE_HOME`) we use that directory as all platform directories. If this folder does not exist we'll fall back to platformdirs defaults. This helper function was introduced to make this code testable. """ platformdir_kwargs = { "appname": "snowflake", "appauthor": False, } snowflake_home = pathlib.Path( os.environ.get("SNOWFLAKE_HOME", "~/.snowflake/"), ).expanduser() if snowflake_home.exists(): return SFPlatformDirs( str(snowflake_home), **platformdir_kwargs, ) else: # In case SNOWFLAKE_HOME does not exist we fall back to using # platformdirs to determine where system files should be placed. Please # see docs for all the directories defined in the module at # https://platformdirs.readthedocs.io/ return PlatformDirs(**platformdir_kwargs) ``` Currently in databricks jobs execution this one is being set to `'/root/.snowflake'` which is not allowed to be accessed. The fix is to catch the error and provide `tmp` folder instead of `root`. ## Related Issue #124 ## Motivation and Context Be able to use snowflake python in databricks ## How Has This Been Tested? Added new tests ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [ ] I have read the **CONTRIBUTING** document. - [x] I have added tests to cover my changes. - [x] All new and existing tests passed.
- Loading branch information