-
Notifications
You must be signed in to change notification settings - Fork 85
Snow 2306184 ng config support 3 #2638
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: main
Are you sure you want to change the base?
Conversation
54e7ad4 to
52151dd
Compare
99a467d to
c32692c
Compare
68ccdbc to
ee5e0ce
Compare
ee5e0ce to
2484c26
Compare
sfc-gh-jwilkowski
left a comment
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 left 1 important question about connections_file_override which does not seem to be needed (maybe yet?). Otherwise a general comment would be about recurring issues across this PR:
- lots of local imports, where I don't think most of them would cause circular deps
- lots of comments that don't add much value
- I've seen this pattern repeating several times - maybe path resolver could go into SecurePath so that we can avoid repeating those?
# Resolve Windows short paths to prevent cleanup issues
resolved_tmp_dir = path_resolver(tmp_dir)
config_path = Path(resolved_tmp_dir) / "config.toml"
Otherwise, looks great!
2484c26 to
66356e5
Compare
af729e4 to
304a27a
Compare
304a27a to
927bc4f
Compare
0454d1a to
c02a716
Compare
0fa6b1d to
1ee50c4
Compare
| hidden=os.environ.get(ALTERNATIVE_CONFIG_ENV_VAR, "").lower() | ||
| not in ("1", "true", "yes", "on"), | ||
| ) | ||
| def show_config_sources( |
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.
when I'm thinking about this command one of the primary use cases would be "I have connection x defined in different places, how can I see where it's taking it's values from". what do you think about providing --connection flag to serve that instead of key argument?
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.
Maybe in future. This PR is already huge.
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.
then for now I'd only suggest to make key an option not an argument
| "-d", | ||
| help="Show detailed resolution chains for all sources consulted.", | ||
| ), | ||
| export_file: Optional[Path] = typer.Option( |
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.
from what I understood this option and related logic should be removed
1ee50c4 to
5d3c16a
Compare
| Example: | ||
| Input: | ||
| connections = {"dev": {"account": "dev_acc", "user": "dev_user"}} | ||
| params = {"user": "override_user", "password": "new_pass"} | ||
| Output: | ||
| {"dev": {"account": "dev_acc", "user": "override_user", "password": "new_pass"}} |
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.
This feels confusing, at least I interpreted it as if the top level settings would override what's defined on particular connection level
| return cls._apply_default_connection_fallback(result) | ||
|
|
||
| @classmethod | ||
| def _apply_default_connection_fallback( |
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.
@sfc-gh-mraba here's the logic that actually takes general settings and applies specifics overlay
| def attach_observer(self, observer: ResolutionObserver) -> None: | ||
| """Attach a new observer at runtime.""" | ||
| self._observers.append(observer) | ||
| if isinstance(observer, TelemetryObserver): | ||
| self._telemetry_observer = observer | ||
| if isinstance(observer, ResolutionHistoryTracker): | ||
| self._history_observer = observer |
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.
This method seems to be redundant. It's only used once in ensure_history_tracking to attach ResolutionHistoryTracker. Those 3 lines might just as well end up in ensure_history_tracking
| Returns: | ||
| True if a new tracker was attached and observers should be reset. |
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.
seems that this return value is needed only for resetting - why not do it in this method? Feels weird when you call ensure_something method and it returns you false even though that thing is ensured
| for observer in self._observers: | ||
| getattr(observer, method_name)(*args, **kwargs) | ||
|
|
||
| def add_source(self, source: "ValueSource") -> 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.
dead code?
| """ | ||
| return [s for s in self._sources if s.source_type is source_type] | ||
|
|
||
| def _record_discoveries(self, source_values: Dict[str, ConfigValue]) -> 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.
dead code
…ith sanitisation 2
…quested - fix win tests
…quested - fix rebase
e8f727c to
b599018
Compare
Pre-review checklist
Changes description
This PR refactors the Snowflake CLI configuration management by removing the module-level
CONFIG_MANAGERsingleton and replacing it with a factory-based approach managed through theCliGlobalContext. This change improves testability and eliminates test flakiness caused by shared global state.