-
Notifications
You must be signed in to change notification settings - Fork 229
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/integrate connections toml #298
Feat/integrate connections toml #298
Conversation
@sfc-gh-tmathew and @sfc-gh-jhansen, flagging a few 4.0.0 candidates. I'm especially interested in this one, as it both simplifies the implementation and supports connections.toml configuration. |
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.
Wow, very impressed at the amount of work here. I'm not a schemachange maintainer, but would benefit from this. Left some suggestions.
Also, I haven't spent a lot of time in the code of the Python Connector, but it seems like schemachange is doing a lot of work around the config and connection that should be handled by the Connector. I wonder if there are ways to lean on it more heavily, allowing a lot of this schemachange code to be cut out.
Thanks, hoping this gets merged sooner or later!
schemachange/config/utils.py
Outdated
"snowflake_password": connection.get("password"), | ||
"snowflake_private_key_path": connection.get("private-key"), | ||
"snowflake_token_path": connection.get("token_file_path"), | ||
} |
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 has a lot of overlap with DeployConfig's get_session_kwargs()
, so wondering if it makes sense to centralize the logic. If that doesn't make sense, would at least suggest moving it to a standalone function.
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'm not sure we can easily combine them. In one case, the keys have the snowflake prefix. In the other case, the class attributes have the snowflake prefix. We could drop the snowflake prefix from the DeployConfig and have a straight mapping 🤔 . I want to say that there was a standard library name overlap or something with that approach. As for making it a standalone function, is this what you're thinking:
def get_connection_kwargs(connection):
return {
"snowflake_account": connection.get("account"),
"snowflake_user": connection.get("user"),
"snowflake_role": connection.get("role"),
"snowflake_warehouse": connection.get("warehouse"),
"snowflake_database": connection.get("database"),
"snowflake_schema": connection.get("schema"),
"snowflake_authenticator": connection.get("authenticator"),
"snowflake_password": connection.get("password"),
"snowflake_private_key_path": connection.get("private-key"),
"snowflake_token_path": connection.get("token_file_path"),
}
What would you call it? get_connection_kwargs is the name of the function that would call this function. I don't have a problem with factoring the mapping out though.
@afeld, that's a great point. I maintained some legacy "check for required arguments" logic, but we could forego this and pass snowflake-related arguments to the Python Connector. |
Awesome work here!
I agree. I've heard these teams are working to help introduce more parity between the Python Connector and Snowflake CLI, hopefully it improves soon.
Should we introduce an additional argument for |
@zanebclark, Can you pull from the current master branch, sync up and then discuss the plan to bake this feature into an upcoming release? We will need to update the changelog.md to communicate the change in connection properties. |
@sfc-gh-tmathew, sure thing. On the subject of improving contribution documentation, check out #296. |
# Conflicts: # schemachange/session/Credential.py # schemachange/session/SnowflakeSession.py
@sfc-gh-twhite , I've added support for the |
@sfc-gh-tmathew , this is good to go. Let me know if I missed something. |
@sfc-gh-tmathew @sfc-gh-jhansen @sfc-gh-twhite , I took steps to do the following:
Some questions around Snowflake's documentation:
|
While I'm complaining, I'll point out that the connections.toml syntax for the private key is "private-key" and the token file path is "token_file_path". At this rate, I'd fully expect the private key passphrase to require the key of "privateKeyPassphrase" |
…guments, comment later removals
Thank you for working through this!
It can with the
|
0f7bc2a
to
3e21f3c
Compare
e0285c3
to
c07f97c
Compare
Thanks @sfc-gh-twhite. It turns out I didn't need to know what the connections.toml argument was because I'm not interested in connection arguments anymore. |
@sfc-gh-tmathew @sfc-gh-jhansen @sfc-gh-twhite, I think this ready for another review:
How soon do you think we could review this and get it into master? I hate to be pushy, but I'm working with a client that's more comfortable referencing the master branch in the long run. |
Support configuration via a connections.toml file.
Previously, credential and required argument logic was distributed across different classes and didn't consider a connections.toml file. This pull request combines configuration and credential logic, supporting an easy-to-follow order of preference for different sources. The
get_merged_config
function pulls from the following sources with descending preference:The
check_for_required_args
logic is authentication-method specific.The following cli arguments have been added:
Limitions / Concerns
config.toml
and the Snowflake Python connector only supports aconnections.toml
. There's a real lack of parity across the tools here.