-
Notifications
You must be signed in to change notification settings - Fork 234
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
Full update options for Delta Sharing shares, recipients, and providers #530
Conversation
Codecov Report
@@ Coverage Diff @@
## main #530 +/- ##
==========================================
- Coverage 60.72% 60.29% -0.43%
==========================================
Files 55 55
Lines 4692 4727 +35
==========================================
+ Hits 2849 2850 +1
- Misses 1843 1877 +34
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
Basically LGTM. Just a couple questions.
if recipient_profile is not None: | ||
_data['recipient_profile_str'] = mc_pretty_format(recipient_profile) | ||
if comment is not None: | ||
_data['comment'] = 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.
Are we keeping the new_name
, comment
, recipient_profile
args for backward compatibility (in case other apps call this function)? Looks like our CLI code only calls it with provider_spec
.
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.
Yes. The API is "public", so the test has been complaining about backwards incompatibility. This is to maintain the existing API.
updates = [] | ||
for a in add_table: | ||
updates.append({'action': 'ADD', 'data_object': shared_data_object(a)}) | ||
for r in remove_table: | ||
updates.append({'action': 'REMOVE', 'data_object': shared_data_object(r)}) | ||
d = {'updates': updates} | ||
share_json = UnityCatalogApi(api_client).update_share(name, d) | ||
data = {'name': new_name, 'comment': comment, 'owner': owner, 'updates': updates} |
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 wondering if we should filter out keys that have value None
. Probably not needed now, since the server won't see those fields defined. We'll need to revisit this once the UC 'update' APIs allow clearing fields (with FieldMasks or whatever).
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.
Yeah, we can do that later, since all the other APIs do something similar along the lines.
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.
LGTM. Might want to wait til @pietern or team member can have a look before merging.
@@ -188,7 +197,7 @@ def delete_share_cli(api_client, name): | |||
@click.option('--allowed_ip_address', default=None, required=False, multiple=True, |
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.
@wchau Could you change this to use dashes to be consistent with everything else and check if other commands use the same? We shouldn't end up in a situation where folks depend on it.
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
help='Free-form text description.') | ||
@click.option('--owner', default=None, required=False, | ||
help='Owner of the recipient.') | ||
@click.option('--allowed_ip_address', default=None, required=False, multiple=True, |
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.
Same.
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
databricks_cli/utils.py
Outdated
|
||
def merge_dicts(*dicts): | ||
""" | ||
Merges dicts throw shallow copy. |
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.
*through
Please rename this to merge_dicts_shallow
to reflect the shallow nature at the call site.
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.
No need for this function at all, per the other 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.
Per other comment
name, | ||
provider_spec=merge_dicts( | ||
data, | ||
{'recipient_profile_str': mc_pretty_format(profile_json)})), |
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 think you can just set the recipient_profile_str
key prior to this call. No need for a merge_dicts
call.
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.
We can't set this easily without a nested def because it's scoped within a lambda function. With merge_dicts_shallow
, it can be reused in the future in a easier fashion.
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.
Thanks for the update. Please consider addressing the concern w.r.t. --allowed-ip-address
in the update operation in a follow up PR. No need to block a release for this to be addressed.
help=( | ||
'IP address in CIDR notation that is allowed to use delta sharing ' | ||
'(can be specified multiple times). Specify a single empty string to disable ' | ||
'IP allowlist.')) |
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 is a bad API, IMO. If the intent is to clear the allowed IP addresses field to delete them, there should be a dedicated option, e.g. --clear-allowed-ip-addresses
to do so. Using a magic empty string can lead to incorrect usage where the list is cleared accidentally (e.g. bad interpolation in a script).
Added support for all updates to shares, recipients, and providers.
Allow option to either specify individual fields to update or JSON.
Tested locally.