Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06fca71

Browse files
authored
Fix file utils and add tests (#68)
* Fix file-utils for gcv* Add file-utils tests* fix ci* fix dep* separately install effdet* Add additional extra_requires
1 parentb4b4fea commit06fca71

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

‎.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
run:|
2222
python -m pip install --upgrade pip
2323
pip install .
24-
pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.1.3#egg=detectron2'
2524
2625
-name:Lint with flake8
2726
run:|
@@ -30,9 +29,16 @@ jobs:
3029
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --ignore F821
3130
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3231
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
33-
32+
33+
-name:Test Dependency Support
34+
run:|
35+
# Install additional requirements when running tests
36+
pip install pytest
37+
pytest tests_deps
38+
3439
-name:Test with pytest
3540
run:|
3641
# Install additional requirements when running tests
42+
pip install .[effdet]
3743
pip install -r dev-requirements.txt
38-
pytest
44+
pytest tests

‎setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"pandas",
2525
"pillow",
2626
"pyyaml>=5.1",
27-
"torchvision",
2827
"iopath",
2928
],
3029
extras_require={
@@ -34,7 +33,14 @@
3433
],
3534
"effdet": [
3635
"torch",
36+
"torchvision",
3737
"effdet"
38+
],
39+
"detectron2": [
40+
"detectron2@git+https://github.com/facebookresearch/detectron2.git@v0.4#egg=detectron2"
41+
],
42+
"paddledetection": [
43+
"paddlepaddle==2.1.0"
3844
]
3945
},
4046
include_package_data=True

‎src/layoutparser/file_utils.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@
6262
exceptimportlib_metadata.PackageNotFoundError:
6363
_pytesseract_available=False
6464

65-
_gcv_available=importlib.util.find_spec("google.cloud.vision")isnotNone
6665
try:
67-
_gcv_version=importlib_metadata.version(
68-
"google-cloud-vision"
69-
)# This is slightly different
70-
logger.debug(f"Google Cloud Vision Utils version{_gcv_version} available.")
71-
exceptimportlib_metadata.PackageNotFoundError:
66+
_gcv_available=importlib.util.find_spec("google.cloud.vision")isnotNone
67+
try:
68+
_gcv_version=importlib_metadata.version(
69+
"google-cloud-vision"
70+
)# This is slightly different
71+
logger.debug(f"Google Cloud Vision Utils version{_gcv_version} available.")
72+
exceptimportlib_metadata.PackageNotFoundError:
73+
_gcv_available=False
74+
exceptModuleNotFoundError:
7275
_gcv_available=False
7376

7477

@@ -142,7 +145,7 @@ def is_gcv_available():
142145
("torch", (is_torch_available,PYTORCH_IMPORT_ERROR)),
143146
("detectron2", (is_detectron2_available,DETECTRON2_IMPORT_ERROR)),
144147
("paddle", (is_paddle_available,PADDLE_IMPORT_ERROR)),
145-
("effdet", (is_effdet_available, )),
148+
("effdet", (is_effdet_available,EFFDET_IMPORT_ERROR)),
146149
("pytesseract", (is_pytesseract_available,PYTESSERACT_IMPORT_ERROR)),
147150
("google-cloud-vision", (is_gcv_available,GCV_IMPORT_ERROR)),
148151
]

‎tests_deps/test_file_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
importpytest
2+
3+
fromlayoutparserimportrequires_backends
4+
5+
deftest_when_backends_are_not_loaded():
6+
7+
# When all the backeds are not installed, it should
8+
# elicit only ImportErrors
9+
10+
forbackend_namein ["torch","detectron2","paddle","effdet","pytesseract","google-cloud-vision"]:
11+
withpytest.raises(ImportError):
12+
requires_backends("a",backend_name)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp