-
Notifications
You must be signed in to change notification settings - Fork 56
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
Enable Event Sharing V2 in SnowCLI #1823
base: main
Are you sure you want to change the base?
Conversation
src/snowflake/cli/_plugins/nativeapp/entities/models/telemetry.py
Outdated
Show resolved
Hide resolved
340bf4e
to
7380050
Compare
|
||
@field_validator("optional_shared_events") | ||
@classmethod | ||
def transform_artifacts( |
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.
def transform_artifacts( | |
def validate_optional_shared_events( |
?
authorize_event_sharing: Optional[bool] = Field( | ||
title="Whether to authorize Snowflake to share application usage data with application package provider. This automatically enables the sharing of required telemetry events.", | ||
default=None, | ||
) | ||
optional_shared_events: Optional[List[str]] = Field( |
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.
do these need to be optional to have a default? do we handle these fields differently if they're None
vs False
/[]
?
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 am not sure if optional [] as default will have any side effect (I know it's not recommended in function params)
|
||
# make sure that each event is made of letters and underscores: | ||
for event in original_shared_events: | ||
if not event.isalpha() and not event.replace("_", "").isalpha(): |
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.
if not event.isalpha() and not event.replace("_", "").isalpha(): | |
if not re.fullmatch(r"[a-zA-Z_]", event): |
?
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.
if you don't want the regex, then you only need
if not event.isalpha() and not event.replace("_", "").isalpha(): | |
if not event.replace("_", "").isalpha(): |
workspace_ctx = self._workspace_ctx | ||
console = workspace_ctx.console | ||
project_root = workspace_ctx.project_root |
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.
workspace_ctx = self._workspace_ctx | |
console = workspace_ctx.console | |
project_root = workspace_ctx.project_root | |
console = self._workspace_ctx.console |
is_dev_mode = install_method.is_dev_mode | ||
|
||
mandatory_events_found = ( | ||
len(find_mandatory_events_in_manifest_file(project_root / deploy_root)) > 0 |
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.
len(find_mandatory_events_in_manifest_file(project_root / deploy_root)) > 0 | |
len(find_mandatory_events_in_manifest_file(self.project_root / deploy_root)) > 0 |
manifest_contents=manifest_contents, | ||
authorize_event_sharing=authorize_event_sharing, | ||
) | ||
assert not mock_diff_result.has_changes() |
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.
mock_diff_result
is never passed anywhere, how can this assertion fail? (also found in other tests)
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.
yea it doesn't make sense - i'll remove it from this new file at least.
allow_always_policy = AllowAlwaysPolicy() | ||
ask_always_policy = AskAlwaysPolicy() | ||
deny_always_policy = DenyAlwaysPolicy() |
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.
these are unused in this file. your _create_or_upgrade_app
takes in a policy
param, did you mean to use them there?
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 it's a left-over copy from another file.
mock_console.warning.assert_has_calls( | ||
[ | ||
mock.call( | ||
"WARNING: Mandatory events are present in the manifest file, but event sharing is not authorized in the application telemetry field. This will soon be required to set in order to deploy applications." | ||
) | ||
] | ||
) |
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.
mock_console.warning.assert_has_calls( | |
[ | |
mock.call( | |
"WARNING: Mandatory events are present in the manifest file, but event sharing is not authorized in the application telemetry field. This will soon be required to set in order to deploy applications." | |
) | |
] | |
) | |
mock_console.warning.assert_called_with( | |
"WARNING: Mandatory events are present in the manifest file, but event sharing is not authorized in the application telemetry field. This will soon be required to set in order to deploy applications." | |
) |
) | ||
|
||
|
||
def setup_project_file(current_working_directory: str, pdf=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.
let's use project factories in 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.
I would like to keep this for a separate PR if possible.
print(mock_execute.mock_calls) | ||
raise e |
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.
?
Pre-review checklist
Changes description
Enable Event Sharing V2 in SnowCLI.
Example:
Above example authorize telemetry to be shared to provider. In addition to required telemetry by the provider, consumer can specify a list of extra events to share with the provider.
There are 2 flags introduced to control the BCR in the backend. One to enable telemetry on consumer for same-account applications, and another to enforce that the consumer authorize event sharing when the provider has mandatory events.