-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add all expid_dir_path functions to autosubmit.py, add attached files to emails #1997
base: master
Are you sure you want to change the base?
Conversation
In GitLab by @isimo00 on Nov 5, 2024, 12:27 requested review from @dbeltrankyl and removed review request for @kinow |
In GitLab by @isimo00 on Nov 5, 2024, 12:49 mentioned in commit 4eec259671daf0dcadb2454ac58c7a91dd9b5afe |
In GitLab by @isimo00 on Nov 5, 2024, 12:49 added 9 commits
|
In GitLab by @dbeltrankyl on Nov 5, 2024, 12:54 Commented on autosubmit/notifications/mail_notifier.py line 76 Hello @isimo00, Thanks for working on it! I think it should point directly to the exact err and exact out instead of the folder. Maybe.. we can attach the logs in the mail itself? and/or point to the specific log in GUI? As it can be easily read ( the latter, not sure how to do it without hardcore it FYI @LuiggiTenorioK ) what do you think? |
In GitLab by @isimo00 on Nov 5, 2024, 12:58 marked the checklist item Resolve merging conflicts as completed |
In GitLab by @dbeltrankyl on Nov 5, 2024, 12:58 Commented on test/unit/conftest.py line 68 Hello, Why the change of Maybe we can use Path().joinpath() if you find that FYI @kinow |
In GitLab by @dbeltrankyl on Nov 5, 2024, 12:58 Commented on test/unit/conftest.py line 68 In general, I think that @kinow recommended using Path for all ( per example, os.path.exists -> Path().exists() ) , os.makedirs -> Path().mkdir(Parents=True,exists_ok=True) ( didn't double check the syntax) ) edit: There are other similar cases across the changes |
In GitLab by @dbeltrankyl on Nov 5, 2024, 13:04 Commented on test/unit/conftest.py line 197 Can we use the mocker fixture there? Instead of using
|
In GitLab by @isimo00 on Nov 5, 2024, 13:04 Commented on test/unit/conftest.py line 68 The functions added here (e.g. aslogs_dir = BasicConfig.aslog_dir_mock(expid) in line 50) return |
In GitLab by @dbeltrankyl on Nov 5, 2024, 13:06 Thanks @isimo00! I comment in one stuff to change ( maybe) and commented on some stuff about the tests. I think we should agree on what to use for the Paths with @kinow , @LuiggiTenorioK mainly to normalize the code |
In GitLab by @isimo00 on Nov 5, 2024, 13:06 Commented on autosubmit/notifications/mail_notifier.py line 76 You mean adding/pasting the content of the log files in the mail? |
In GitLab by @dbeltrankyl on Nov 5, 2024, 13:15 Commented on autosubmit/notifications/mail_notifier.py line 76 I mean:
|
In GitLab by @LuiggiTenorioK on Nov 5, 2024, 13:34 Commented on autosubmit/notifications/mail_notifier.py line 76
The GUI shows the latest |
In GitLab by @LuiggiTenorioK on Nov 5, 2024, 13:38
Agree that using |
In GitLab by @isimo00 on Nov 5, 2024, 14:35 Started switching back to |
In GitLab by @isimo00 on Nov 5, 2024, 15:33 mentioned in commit 867e93ff52b3583772ea6e97371c5dabf5619ea0 |
In GitLab by @isimo00 on Nov 5, 2024, 15:33 added 1 commit
|
In GitLab by @isimo00 on Nov 5, 2024, 15:47 Commented on test/unit/conftest.py line 197 changed this line in version 4 of the diff |
In GitLab by @isimo00 on Nov 5, 2024, 15:47 added 1 commit
|
In GitLab by @isimo00 on Nov 5, 2024, 15:55 Commented on test/unit/conftest.py line 68 changed this line in version 5 of the diff |
In GitLab by @isimo00 on Nov 5, 2024, 15:55 added 1 commit
|
In GitLab by @kinow on Nov 6, 2024, 10:13 Commented on autosubmit/notifications/mail_notifier.py line 76 Not reviewing this one, just going through inbox emails... but maybe we could use a single f-string multiline text without concatenation? Instead of f'some string {vars} \n\n' \
+ f'another string being concatenated {vars} \n etc' I think this should work too? f'''some string {vars} \n\n
more text {vars}
etc''' |
In GitLab by @isimo00 on Nov 26, 2024, 13:18 Commented on autosubmit/notifications/mail_notifier.py line 76 changed this line in version 6 of the diff |
In GitLab by @isimo00 on Nov 26, 2024, 13:18 added 1 commit
|
In GitLab by @isimo00 on Dec 4, 2024, 11:46 added 1 commit
|
In GitLab by @isimo00 on Dec 5, 2024, 10:46 mentioned in commit df8c557e5713428f0c8e1afca942081ed958e55e |
In GitLab by @isimo00 on Dec 5, 2024, 10:46 added 1 commit
|
In GitLab by @isimo00 on Dec 9, 2024, 12:34 added 1 commit
|
In GitLab by @dbeltrankyl on Dec 10, 2024, 15:01 Hello @isimo00 , Sorry, I lost track of this one with all the other stuff. Is something pending review, or are you still working on it? Note that the Notify_on value seems to not be there !532, so I believe you won't be able to do a manual functional test ( launch autosubmit run and see if you receive the mail ) |
In GitLab by @isimo00 on Dec 10, 2024, 15:06 The code and testing is all done as of now but it won't be merged until the newest version of the configparser (1.0.76) is released, since this has some dependencies on stuff from the configparser that has been commited but not launched as a new version yet. So maybe it's better to wait until then and I after I fix the possible merge conflicts of the future before reviewing it. |
Hello @isimo00 I've updated the Autosubmit config parser to 1.0.76 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1997 +/- ##
==========================================
+ Coverage 48.93% 49.05% +0.12%
==========================================
Files 72 72
Lines 17525 17559 +34
Branches 3408 3416 +8
==========================================
+ Hits 8575 8614 +39
+ Misses 8150 8141 -9
- Partials 800 804 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov bot showing poor coverage. Although not related to this issue, tests the following autosubmit.py funcitons should be added:
|
Maybe we can split it, and leave the pathlib/os.path/BasicConfig changes in the other PR... then this one just adds the email thingy. |
All previous definitions all expid_path, tmp_path, log_path and aslogs_path (and similar) have been removed and their calls have been switched for BasicConfig.foo() calls. Impacted tests are mainly affected in terms of adding Mock objects since BasicConfig.foo() functions are not available in autosubmitconfigparser yet. No new tests added
@kinow For some reason I can't tag you as a reviewer, but this is finally done now! |
It's because I'm the creator of this pull request (due to how the migration script works -- it uses the migration user in the GitHub API calls, as owner). |
Ah I see. Well @kinow , let me know if you think something else is missing / you can't review it or I can tag Luiggi :) |
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.
@isimo00 reviewed most of the changes, pending just mail_notifier.py
now (:coffee: break)
|
||
class MailNotifier: | ||
def __init__(self, basic_config): | ||
self.config = basic_config | ||
|
||
def notify_experiment_status(self, exp_id,mail_to,platform): | ||
message_text = self._generate_message_experiment_status(exp_id, platform) | ||
message = MIMEText(message_text) | ||
message = MIMEMultipart() |
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 need to confirm if this is the best option. I remember the discussion, but I didn't have time to ponder about it, sorry.
@mcastril, here we have a few options, basically,
- we send a notification as we already do, but include the location of the logs in the VM/hub/somewhere
- we attach the complete log as-is into the email body
- we compress and then attach the logs (and delete the compressed archive as the original logs will remain anyway) into the email body
I think I am more included towards 1) to simplify or a 1.5) option, where we let users choose whether they want the location or the attachment, but I had seen a comment about doing the option 2), which is implemented here.
WDYT, Miguel?
files = [f for f in BasicConfig.expid_aslog_dir(exp_id).glob('*_run.log') if Path(f).is_file()] | ||
self._attach_files(message, files) | ||
except BaseException as e: | ||
Log.printlog('An error has occurred while attaching log files to a warning email about remote_platforms ', 6011) |
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.
So if we fail to attach any file, we just print the log? Or should we move this into the for-loop in attach_files? (i.e. log when a file fails, but keep trying the remaining ones?)
And should we just log, or fail the process?
And should we perhaps log but also add something in the email/mime-message, in the notification saying "Here's your notification, but sorry I couldn't attach file ABC.log for reasons"? 😬
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 ideally we'd want to attach as many log files as possible; so omit the ones we can't retrieve (if any) but still attach the rest. Modifying the mail body to explain this would also be nice, i.e. "This email has attached all the log files we could retrieve, there might be some missing".
I can add another log in the attach_files
function and write more specific log messages. I'd rather have a new one than moving this one since they can catch different exceptions - for instance, what if the ASLOGS dir doesn't exist? -.
I'm also wondering if we should compress the log files before attaching them, to delay reaching the file attachment limit (what is it?) Overall, attaching the files is a nice touch but the most relevant information for the user is the log path, which is always printed in the mail body.
Thank you for the extensive review @kinow! I've taken it as a sign to finally start using |
I think Luiggi is using Ruff. In the end, these tools in Python tend to follow more or less the same set of rules, based on pep8 (normally pep8 is a subset of all lint rules, as these tools add more on top of it). So that's a good start! But maybe check with Luiggi if it would be better if you used ruff too. This is up to discussion too, but ruff is also used in other BSC projects (and DestinE workflow, GSV, etc.) so there is a good case for us to use that too. And thank you for the great PR with tests, and for splitting the change in the pathlib that would require more test coverage. |
* Fix issue with the wrapper attribute * Fix issue with the wrapper attribute
…a vertical wrapper (#2038)
In GitLab by @isimo00 on Nov 5, 2024, 12:27
All previous definitions all
expid_path
,tmp_path
,log_path
andaslogs_path
(and similar) have been removed and their calls have been switched forBasicConfig.foo()
calls. Impacted tests are mainly affected in terms of adding Mock objects sinceBasicConfig.foo()
functions are not available in autosubmitconfigparser yet. No new tests added.