-
Notifications
You must be signed in to change notification settings - Fork 81
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
[GH-1420] Notification Improvements Stage 1 #1748
base: main
Are you sure you want to change the base?
[GH-1420] Notification Improvements Stage 1 #1748
Conversation
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.
part 1 Review - still have a couple more files on Dataset Table notifications and weekly digest
backend/dataall/modules/notifications/services/admin_notifications.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/ses_email_notification_service.py
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/ses_email_notification_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/shares_base/services/share_notification_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/shares_base/services/sharing_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/shares_base/services/share_notification_service.py
Outdated
Show resolved
Hide resolved
def find_share_by_dataset_attributes(session, dataset_uri, dataset_owner, groups = None): | ||
if groups is None: | ||
groups = [] |
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 guessing there is an edge case where groups could be passed in explicitly as None
before and not being set to []
so the query failed?
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.
tbh, I added it because my editor was suggesting an improvement. I think this article does a fine job at explaining why - https://nikos7am.com/posts/mutable-default-arguments/
backend/dataall/modules/notifications/tasks/weekly_digest_reminder.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/tasks/weekly_digest_reminder.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/tasks/weekly_digest_reminder.py
Outdated
Show resolved
Hide resolved
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.
some additional comments from pending file review
backend/dataall/modules/notifications/tasks/weekly_digest_reminder.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/tasks/weekly_digest_reminder.py
Outdated
Show resolved
Hide resolved
if table_status_map: | ||
log.info('Sending email notification after dataset table updates were found') | ||
try: | ||
DatasetTableNotifications(dataset=dataset).notify_dataset_table_updates(session=session, table_status_map=table_status_map) | ||
except Exception as e: | ||
error_log = f"Error occurred while sending email to notify about changes to the glue tables for dataset with uri: {dataset.datasetUri} due to: {e}" | ||
task_exceptions.append(error_log) |
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.
table_status_map
will always be defined so this will always execute right?
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.
also should there be a try catch here or only on the loop over datasets?
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.
table_status_map will always be defined so this will always execute right?
The table_status_map
will be empty when there are no newly added tables, no table has been deleted , no table which was deleted previously has been added. And thus when it is empty the if part won't execute.
also should there be a try catch here or only on the loop over datasets?
I have added this try catch explicitly so that that any email sending failures are caught. Also with this , the rest of the code deosn't get affected and I don't want it to get affected
Hi @noah-paige , I have updated the PR. Please let me know if you have any additional code comments. Let me know if you need any clarification / discussion on few of my replies on your comments . Few additional things which I noticed and added as a part of new updated PR,
|
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: should we also explicitly import db
in the __init__
file? (at dataall/backend/dataall/core/groups/__init__.py
) -- think right now it is implicitly imported via api
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 wouldn't mind it getting imported implicitly. With a blank init all the group_models and constants file will be imported.
backend/dataall/modules/notifications/services/admin_notifications.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/admin_notifications.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/admin_notifications.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/ses_email_notification_service.py
Show resolved
Hide resolved
backend/dataall/modules/notifications/services/ses_email_notification_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/shares_base/services/sharing_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/modules/shares_base/services/sharing_service.py
Outdated
Show resolved
Hide resolved
@@ -42,11 +42,15 @@ def find_share(session, dataset: DatasetBase, env, principal_id, principal_role_ | |||
) | |||
|
|||
@staticmethod | |||
def find_dataset_shares(session, dataset_uri): | |||
return session.query(ShareObject).filter(ShareObject.datasetUri == dataset_uri).all() | |||
def find_dataset_shares(session, dataset_uri: str): |
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.
Nothing has changed here. Only returning via query.allI() instead of on the same line
@@ -332,30 +437,3 @@ def _create_notification_task(self, subject, msg): | |||
log.info(f'Notification type : {share_notification_config_type} is not active') | |||
else: | |||
log.info('Notifications are not active') | |||
|
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.
Removing this function from here and moving it to ses_email_notification_service.py
@@ -32,7 +32,8 @@ | |||
"active": false, | |||
"persistent_reminders": false, | |||
"parameters": { | |||
"group_notifications": true | |||
"group_notifications": true, | |||
"admin_notifications": 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.
Adding this new parameter to switch on/off admin notifications. This can be later removed and admin notifications can be enabled by default when email notifications are enabled. Keeping this for now, to test and see how many notifications an admin might get with the current code change. There is a chance in which admins can be bombarded with a lot of notifications in which this will serve as a good way to stop creating admin notifications
@@ -161,7 +161,7 @@ def __init__( | |||
command=['python3.9', '-m', 'dataall.core.environment.tasks.env_stacks_updater'], | |||
container_id='container', | |||
ecr_repository=ecr_repository, | |||
environment=self._create_env(), | |||
environment=self.env_vars, |
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.
Switching to env_vars as those contains the same as self._create_env()
Hi @petrkalos , @noah-paige , I have made code changes after taking a look at the review comments. Can you please take a look and let me if this PR looks good now I have re-tested after code changes
|
Feature or Bugfix
Detail
Stage 1 as described in the Gh issue 1420 ( #1420 (comment))
Table on information about when notifications are sent to whom they are sent. I will add this as a part of documentation as well.
Tests
Relates
Security
Please answer the questions below briefly where applicable, or write
N/A
. Based onOWASP 10.
fetching data from storage outside the application (e.g. a database, an S3 bucket)?
eval
or similar functions are used?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.