System Info
transformers version: 4.29.2
- Platform: macOS-13.3.1-arm64-arm-64bit
- Python version: 3.10.11
- Huggingface_hub version: 0.14.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.0.1 (False)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: N/A
- Using distributed or parallel set-up in script?: N/A
Who can help?
@sgugger
Reproduction
The minimal repro is to just call https://github.com/huggingface/transformers/blob/v4.29.2/src/transformers/dynamic_module_utils.py#L118-L134 on a file that has a multiline try import, e.g.
try:
from package import function
from package2 import function
except:
pass
and run the get_imports function on it. The output will be ['package', 'package2'], when it should be []
Expected behavior
Imports in multiline try blocks should be ignored when determining what packages a modeling file requires. I believe
|
content = re.sub(r"\s*try\s*:\s*.*?\s*except\s*:", "", content, flags=re.MULTILINE) |
just needs to be modified to include
flags=re.MULTILINE | re.DOTALL.
System Info
transformersversion: 4.29.2Who can help?
@sgugger
Reproduction
The minimal repro is to just call https://github.com/huggingface/transformers/blob/v4.29.2/src/transformers/dynamic_module_utils.py#L118-L134 on a file that has a multiline try import, e.g.
and run the
get_importsfunction on it. The output will be['package', 'package2'], when it should be[]Expected behavior
Imports in multiline try blocks should be ignored when determining what packages a modeling file requires. I believe
transformers/src/transformers/dynamic_module_utils.py
Line 126 in ba70545
flags=re.MULTILINE | re.DOTALL.