Merged
Conversation
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
| Syntax( | ||
| self.GOODBYE_MESSAGE_BASH.format( | ||
| exp_id=self._id, | ||
| tasks=list(map(lambda job: job.id, self.jobs)), |
Check warning
Code scanning / CodeQL
'break' or 'return' statement in finally Warning
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, the return statement should be moved outside the finally block. This ensures that exceptions raised during the execution of the try block or the finally block are not suppressed. The cleanup operations in the finally block will still execute, but the exception will propagate correctly.
The best approach is to refactor the __exit__ method to store the return value in a variable and return it after the finally block. This preserves the intended functionality while ensuring proper exception handling.
Suggested changeset
1
nemo_run/run/experiment.py
| @@ -1136,2 +1136,3 @@ | ||
| def __exit__(self, exc_type, exc_value, tb): | ||
| return_value = None | ||
| try: | ||
| @@ -1146,5 +1147,5 @@ | ||
| self.status() | ||
| return | ||
| return_value = None | ||
|
|
||
| if self._launched: | ||
| elif self._launched: | ||
| if hasattr(self, "_direct") and self._direct: | ||
| @@ -1154,5 +1155,5 @@ | ||
| self.status() | ||
| return | ||
| return_value = None | ||
|
|
||
| if hasattr(self, "_waited") and self._waited: | ||
| elif hasattr(self, "_waited") and self._waited: | ||
| self.console.rule( | ||
| @@ -1161,10 +1162,10 @@ | ||
| self.status() | ||
| return | ||
|
|
||
| self.console.rule( | ||
| f"[bold magenta]Waiting for Experiment {self._id} to finish", | ||
| ) | ||
| self.status() | ||
| return_value = None | ||
|
|
||
| self._wait_for_jobs(jobs=self.jobs) | ||
| else: | ||
| self.console.rule( | ||
| f"[bold magenta]Waiting for Experiment {self._id} to finish", | ||
| ) | ||
| self.status() | ||
| self._wait_for_jobs(jobs=self.jobs) | ||
| finally: | ||
| @@ -1197,2 +1198,3 @@ | ||
| ) | ||
| return return_value | ||
|
|
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
Signed-off-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
hemildesai
approved these changes
Jul 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
The main issue I faced was not getting the sbatch script written, i used something like the following code