mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-15 18:48:24 +06:00
Make it easier to develop without a dev install (#22697)
* Make it easier to develop without a dev install * Remove ugly hack that doesn't work anyway
This commit is contained in:
parent
4c01231e67
commit
28c19ab58d
@ -162,14 +162,16 @@ You'll need **[Python 3.7]((https://github.com/huggingface/transformers/blob/mai
|
|||||||
it with `pip uninstall transformers` before reinstalling it in editable
|
it with `pip uninstall transformers` before reinstalling it in editable
|
||||||
mode with the `-e` flag.
|
mode with the `-e` flag.
|
||||||
|
|
||||||
Depending on your OS, you may need to install some external libraries as well if the `pip` installation fails.
|
Depending on your OS, and since the number of optional dependencies of Transformers is growing, you might get a
|
||||||
|
failure with this command. If that's the case make sure to install the Deep Learning framework you are working with
|
||||||
For macOS, you will likely need [MeCab](https://taku910.github.io/mecab/) which can be installed from Homebrew:
|
(PyTorch, TensorFlow and/or Flax) then do:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install mecab
|
pip install -e ".[quality]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
which should be enough for most use cases.
|
||||||
|
|
||||||
5. Develop the features on your branch.
|
5. Develop the features on your branch.
|
||||||
|
|
||||||
As you work on your code, you should make sure the test suite
|
As you work on your code, you should make sure the test suite
|
||||||
|
@ -202,7 +202,15 @@ source .env/bin/activate
|
|||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
```
|
```
|
||||||
|
|
||||||
and return to the parent directory
|
Depending on your OS, and since the number of optional dependencies of Transformers is growing, you might get a
|
||||||
|
failure with this command. If that's the case make sure to install the Deep Learning framework you are working with
|
||||||
|
(PyTorch, TensorFlow and/or Flax) then do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e ".[quality]"
|
||||||
|
```
|
||||||
|
|
||||||
|
which should be enough for most use cases. You can then return to the parent directory
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd ..
|
cd ..
|
||||||
|
@ -119,6 +119,13 @@ source .env/bin/activate
|
|||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Depending on your OS, and since the number of optional dependencies of Transformers is growing, you might get a
|
||||||
|
failure with this command. If that's the case make sure to install TensorFlow then do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e ".[quality]"
|
||||||
|
```
|
||||||
|
|
||||||
**Note:** You don't need to have CUDA installed. Making the new model work on CPU is sufficient.
|
**Note:** You don't need to have CUDA installed. Making the new model work on CPU is sufficient.
|
||||||
|
|
||||||
4. Create a branch with a descriptive name from your main branch
|
4. Create a branch with a descriptive name from your main branch
|
||||||
|
@ -24,7 +24,7 @@ When you open a pull request on 🤗 Transformers, a fair number of checks will
|
|||||||
|
|
||||||
In this document, we will take a stab at explaining what those various checks are and the reason behind them, as well as how to debug them locally if one of them fails on your PR.
|
In this document, we will take a stab at explaining what those various checks are and the reason behind them, as well as how to debug them locally if one of them fails on your PR.
|
||||||
|
|
||||||
Note that they all require you to have a dev install:
|
Note that, ideally, they require you to have a dev install:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install transformers[dev]
|
pip install transformers[dev]
|
||||||
@ -36,7 +36,18 @@ or for an editable install:
|
|||||||
pip install -e .[dev]
|
pip install -e .[dev]
|
||||||
```
|
```
|
||||||
|
|
||||||
inside the Transformers repo.
|
inside the Transformers repo. Since the number of optional dependencies of Transformers has grown a lot, it's possible you don't manage to get all of them. If the dev install fails, make sure to install the Deep Learning framework you are working with (PyTorch, TensorFlow and/or Flax) then do
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install transformers[quality]
|
||||||
|
```
|
||||||
|
|
||||||
|
or for an editable install:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e .[quality]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
|
@ -34,6 +34,14 @@ cd transformers
|
|||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Depending on your OS, and since the number of optional dependencies of Transformers is growing, you might get a
|
||||||
|
failure with this command. If that's the case make sure to install the Deep Learning framework you are working with
|
||||||
|
(PyTorch, TensorFlow and/or Flax) then do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e ".[quality]"
|
||||||
|
```
|
||||||
|
|
||||||
Once the installation is done, you can use the CLI command `add-new-model` to generate your models:
|
Once the installation is done, you can use the CLI command `add-new-model` to generate your models:
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
@ -133,6 +141,14 @@ cd transformers
|
|||||||
pip install -e ".[dev]"
|
pip install -e ".[dev]"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Depending on your OS, and since the number of optional dependencies of Transformers is growing, you might get a
|
||||||
|
failure with this command. If that's the case make sure to install the Deep Learning framework you are working with
|
||||||
|
(PyTorch, TensorFlow and/or Flax) then do:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -e ".[quality]"
|
||||||
|
```
|
||||||
|
|
||||||
Once the installation is done, you can use the CLI command `add-new-model-like` to generate your models:
|
Once the installation is done, you can use the CLI command `add-new-model-like` to generate your models:
|
||||||
|
|
||||||
```shell script
|
```shell script
|
||||||
|
@ -277,11 +277,20 @@ def check_submodules():
|
|||||||
|
|
||||||
transformers = direct_transformers_import(PATH_TO_TRANSFORMERS)
|
transformers = direct_transformers_import(PATH_TO_TRANSFORMERS)
|
||||||
|
|
||||||
|
import_structure_keys = set(transformers._import_structure.keys())
|
||||||
|
# This contains all the base keys of the _import_structure object defined in the init, but if the user is missing
|
||||||
|
# some optional dependencies, they may not have all of them. Thus we read the init to read all additions and
|
||||||
|
# (potentiall re-) add them.
|
||||||
|
with open(os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"), "r") as f:
|
||||||
|
init_content = f.read()
|
||||||
|
import_structure_keys.update(set(re.findall(r"import_structure\[\"([^\"]*)\"\]", init_content)))
|
||||||
|
|
||||||
module_not_registered = [
|
module_not_registered = [
|
||||||
module
|
module
|
||||||
for module in get_transformers_submodules()
|
for module in get_transformers_submodules()
|
||||||
if module not in IGNORE_SUBMODULES and module not in transformers._import_structure.keys()
|
if module not in IGNORE_SUBMODULES and module not in import_structure_keys
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(module_not_registered) > 0:
|
if len(module_not_registered) > 0:
|
||||||
list_of_modules = "\n".join(f"- {module}" for module in module_not_registered)
|
list_of_modules = "\n".join(f"- {module}" for module in module_not_registered)
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
Reference in New Issue
Block a user