You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a function to lightning_utilities/core/imports.py that returns the minimum version of a dependency of a package.
Motivation
The minimum version of a dependency could be needed in more than one place in the code. When a change is needed, this needs to be done in multiple places. The issue is that it can be forgotten to update one location. An example is requirements/pytorch/extra.txt#L8 and src/pytorch_lightning/cli.py#L32.
A possible implementation of this function could be:
defget_minimum_dependency_version(package_name: str, dependency_name: str) ->str:
"""Returns the minimum version of a dependency of a package. >>> get_minimum_dependency_version("pytorch-lightning", "jsonargparse") '4.12.0' """fordependencyinmetadata.requires(package_name):
ifre.match(f"^{dependency_name}(|[^\w].*)$", dependency):
returnre.sub(r".*>=([\d.]+).*", r"\1", dependency)
raiseValueError(f"dependency {dependency_name!r} not found in package {package_name!r}")
Alternatives
Keep updating multiple places in the code. When there is a mistake, fix it later.
Additional context
None
The text was updated successfully, but these errors were encountered:
Hi @mauvilsa, thank you for your suggestion! It overall sounds good to me. One possible improvement is to update the error message to something like this so that users will know it's not their fault when they see the error:
- raise ValueError(f"dependency {dependency_name!r} not found in package {package_name!r}")+ raise ValueError(f"This is an internal error. Please file a GitHub issue with the error message. Dependency {dependency_name!r} not found in package {package_name!r}.")
🚀 Feature
Add a function to
lightning_utilities/core/imports.py
that returns the minimum version of a dependency of a package.Motivation
The minimum version of a dependency could be needed in more than one place in the code. When a change is needed, this needs to be done in multiple places. The issue is that it can be forgotten to update one location. An example is requirements/pytorch/extra.txt#L8 and src/pytorch_lightning/cli.py#L32.
Maybe this could be useful in other cases.
Pitch
Be able to change
to
A possible implementation of this function could be:
Alternatives
Keep updating multiple places in the code. When there is a mistake, fix it later.
Additional context
None
The text was updated successfully, but these errors were encountered: