-
Notifications
You must be signed in to change notification settings - Fork 209
Make default Config() Initialization respect target_path in default config file #2093
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
base: master
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughMade Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 @ryanquincypaul |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@elementary/config/config.py`:
- Around line 93-101: Remove the transient stdout debug prints that can leak
secrets: eliminate the print(...) calls after computing self.target_dir in the
constructor where self.target_dir = self._first_not_none(target_path,
config.get("target-path"), self.DEFAULT_TARGET_PATH) is set; if you need
diagnostics, replace those prints with a call to a logger (e.g. logger.debug)
that redacts sensitive fields from config (or only logs non-sensitive fields
like the resolved DEFAULT_TARGET_PATH and final target_dir) and ensure the code
references the same symbols (_first_not_none, target_path, config,
DEFAULT_TARGET_PATH, target_dir) so the behavior and debugging remain clear
without printing secrets to stdout.
|
I did not mean to make this to the main repo, just my fork as I was having trouble with local unit tests even with unmodified code. I was just pushing to see the unit tests run in the github actions as I couldn't get them to pass locally. I was just going to build a wheel from this and use it manually in databricks tasks! But whatever it is out there now. I will make a little more effort in the description. |
|
To be clear, i'm not requesting anything. It would be cool if this was builtin, but as of now I am just going to build a wheel and try it out in databricks now and I can report back. I didn't mean for this to be visible lol. Open to any feedback though regardless. |
|
@coderabbitai summary |
✅ Actions performedSummary regeneration triggered. |
|
So this worked! But adding |
The problem
In databricks python tasks using serverless compute, the default current working directory doesn't allow writes. The logo and version checking code instantiates a Config object with the default values and no way to configure them which means target_path goes to
DEFAULT_TARGET_PATH = os.getcwd() + "/edr_target"and no way to override it. Below the solution I will put lines of code of the issues in case that is relevant.What I would like to have happen
I don't think the logo and version checking logic should require file writes that I have no option of skipping at all, but in lieu of that, instead of
os.chdir()-ing the working directory to somewhere like/tmp, I'd rather just use the already existing target_path option to tell edr to put files in a place where I am allowed to write. The logo and upgrade check calls use a default Config() option which forces a default path using os.getcwd(). I would like it so at least options in a config file written at the default location (~/.edr/config.yml) is respected in a defaultConfig()call. I can then at least give it atarget-path: /tmp/WHATEVER_{unique_timestamp}or something so it can create theedr_targetdirectory just to print the logo and check the dbt and python package version numbers in peace. It would be great if it would also respect the arguments I am passing in as I am using the --target-path parameter foredr reportto store it somewhere in a databricks volume.What I did
I am just setting the default value of target_path to None so that it gets to the check for a value in the default config directory in the
_first_not_noneset, and then it will go to the original DEFAULT_TARGET_PATH. I am also setting the DBT_LOG_PATH env var to the target_dir and not the passed in target_path.https://github.com/ryanquincypaul/elementary/blob/8243a7068b21a72ad0bbc921b5f04c0bca6131b3/elementary/config/config.py#L49
https://github.com/ryanquincypaul/elementary/blob/8243a7068b21a72ad0bbc921b5f04c0bca6131b3/elementary/config/config.py#L93-L100
Other solutions I had thought of
More details on issue
Should be noted that there were PRs made and accepted adding configuration to disable the logo and version checking:
#1903
#1674
elementary/elementary/cli/cli.py
Lines 15 to 16 in 398b34a
Config()with no parameters given or any other way to override the target_path.elementary/elementary/cli/logo.py
Lines 15 to 21 in 398b34a
elementary/elementary/cli/upgrade.py
Lines 10 to 14 in 398b34a
elementary/elementary/config/config.py
Lines 36 to 38 in 398b34a
elementary/elementary/config/config.py
Line 44 in 398b34a
elementary/elementary/config/config.py
Line 49 in 398b34a
Nonevia the command line if these default Config() calls even listened to that input. Furthermore, the DBT_LOG_PATH setting doesn't even respect the config path anyway, it's only using what's passed into thetarget_pathparameter which again is just the default one in logo and variable checking code.elementary/elementary/config/config.py
Lines 93 to 99 in 398b34a
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.