Support for version spec in requires & arbitrary mismatching depths across folders (#37854)

* Support for version spec in requires & arbitrary mismatching depths

* Quality

* Testing
This commit is contained in:
Lysandre Debut
2025-05-09 15:26:27 +02:00
committed by GitHub
parent 774dc274ac
commit 23d79cea75
4 changed files with 391 additions and 45 deletions

View File

@@ -84,6 +84,19 @@ class Trainer:
Backends that can be added here are all the backends that are available in the `import_utils.py` module.
Additionally, specific versions can be specified in each backend. For example, this is how you would specify
a requirement on torch>=2.6 on the `Trainer` class:
```python
from .utils.import_utils import requires
@requires(backends=("torch>=2.6", "accelerate"))
class Trainer:
...
```
You can specify the following operators: `==`, `>`, `>=`, `<`, `<=`, `!=`.
## Methods
[[autodoc]] utils.import_utils.define_import_structure