Adding support for ForwardRef in CLI#176
Merged
marcromeyn merged 15 commits intomainfrom Apr 28, 2025
Merged
Conversation
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
4320c36 to
034a999
Compare
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
hemildesai
reviewed
Mar 25, 2025
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
| return getattr(module, type_name) | ||
| except (ImportError, AttributeError): | ||
| pass | ||
| except Exception: |
Check notice
Code scanning / CodeQL
Empty except Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 10 months ago
To fix the issue, we should handle the exception in a way that provides useful information without disrupting the function's fallback behavior. The best approach is to log the exception using the logging module. This ensures that any issues are recorded for debugging purposes while maintaining the function's current behavior of returning the original annotation if resolution fails.
Changes to make:
- Replace the
passstatement in theexcept Exception:block with a logging statement that records the exception. - Use the
loggerobject already defined in the file to log the exception at an appropriate level (e.g.,logger.warningorlogger.debug).
Suggested changeset
1
nemo_run/cli/cli_parser.py
| @@ -1444,4 +1444,4 @@ | ||
| pass | ||
| except Exception: | ||
| pass | ||
| except Exception as e: | ||
| logger.warning("Failed to resolve annotation '%s' in function '%s': %s", annotation, fn, e) | ||
| return annotation |
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
Signed-off-by: Marc Romeyn <marcromeyn@gmail.com>
Signed-off-by: Marc Romeyn <mromeijn@nvidia.com>
hemildesai
approved these changes
Apr 28, 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.
NeMo has quite a few string type-hints, where the import is happening inside a
if TYPE_CHECKINGclause. This PR adds support for that, to resolve the right type (if possible).