-
Notifications
You must be signed in to change notification settings - Fork 54
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
Defer fetching role and warehouse until they're needed #1631
Conversation
if cli_context.connection.warehouse: | ||
self.default_warehouse = to_identifier(cli_context.connection.warehouse) | ||
self._default_role = self._UNSET | ||
self._default_warehouse = self._UNSET |
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.
self.default_warehouse
wasn't used externally, so it's safe to change it to self._default_warehouse
bb3394b
to
c0d90c6
Compare
fe74040
to
c09aaa6
Compare
self._default_role = self._UNSET | ||
self._default_warehouse = self._UNSET | ||
|
||
def _get_default_role(self): |
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: could you add a return type annotation? I think it's important here to label whether the return value is optional or not
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.
done
if self._default_warehouse is self._UNSET: | ||
cli_context = get_cli_context() | ||
if cli_context.connection.warehouse: | ||
self._default_warehouse = to_identifier( | ||
cli_context.connection.warehouse | ||
) | ||
return self._default_warehouse |
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.
there is no connection warehouse, isn't this going to return UNSET? That doesn't sound right. The role logic doesn't have this issue because if assigns None
even if the fallback logic fails to produce a valid role.
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-bdufour good catch, I updated the implementation to use @cached_property
in the ActionContext
since we don't need to be caching them in WorkspaceManager
e8a07c1
to
06d701a
Compare
06d701a
to
5e54a5c
Compare
We have some commands, like `snow app bundle`/`snow ws bundle` that don't even need a connection, so let's defer connecting to Snowflake until it's actually needed by the particular action being run. For now, all `snow ws` commands are still marked as requiring a connection, that will be fixed separately.
Pre-review checklist
Changes description
We have some commands, like
snow app bundle
/snow ws bundle
that don't even need a connection, so let's defer connecting to Snowflake until it's actually needed by the particular action being run.For now, all
snow ws
commands are still marked as requiring a connection, that will be fixed separately.