Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
afdf1261
"tests/git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "c390e327fa2c35dfbb57252758cd2798074159ce"
Unverified
Commit
afdf1261
authored
Jan 19, 2022
by
Philip Meier
Committed by
GitHub
Jan 19, 2022
Browse files
remove get_bool_env_var (#5222)
parent
f4fd1933
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
22 deletions
+8
-22
test/common_utils.py
test/common_utils.py
+3
-18
test/test_prototype_models.py
test/test_prototype_models.py
+5
-4
No files found.
test/common_utils.py
View file @
afdf1261
...
@@ -4,10 +4,8 @@ import os
...
@@ -4,10 +4,8 @@ import os
import
random
import
random
import
shutil
import
shutil
import
tempfile
import
tempfile
from
distutils.util
import
strtobool
import
numpy
as
np
import
numpy
as
np
import
pytest
import
torch
import
torch
from
PIL
import
Image
from
PIL
import
Image
from
torchvision
import
io
from
torchvision
import
io
...
@@ -15,18 +13,9 @@ from torchvision import io
...
@@ -15,18 +13,9 @@ from torchvision import io
import
__main__
# noqa: 401
import
__main__
# noqa: 401
def
get_bool_env_var
(
name
,
*
,
exist_ok
=
False
,
default
=
False
):
IN_CIRCLE_CI
=
os
.
getenv
(
"CIRCLECI"
,
False
)
==
"true"
value
=
os
.
getenv
(
name
)
IN_RE_WORKER
=
os
.
environ
.
get
(
"INSIDE_RE_WORKER"
)
is
not
None
if
value
is
None
:
IN_FBCODE
=
os
.
environ
.
get
(
"IN_FBCODE_TORCHVISION"
)
==
"1"
return
default
if
exist_ok
:
return
True
return
bool
(
strtobool
(
value
))
IN_CIRCLE_CI
=
get_bool_env_var
(
"CIRCLECI"
)
IN_RE_WORKER
=
get_bool_env_var
(
"INSIDE_RE_WORKER"
,
exist_ok
=
True
)
IN_FBCODE
=
get_bool_env_var
(
"IN_FBCODE_TORCHVISION"
)
CUDA_NOT_AVAILABLE_MSG
=
"CUDA device not available"
CUDA_NOT_AVAILABLE_MSG
=
"CUDA device not available"
CIRCLECI_GPU_NO_CUDA_MSG
=
"We're in a CircleCI GPU machine, and this test doesn't need cuda."
CIRCLECI_GPU_NO_CUDA_MSG
=
"We're in a CircleCI GPU machine, and this test doesn't need cuda."
...
@@ -213,7 +202,3 @@ def _test_fn_on_batch(batch_tensors, fn, scripted_fn_atol=1e-8, **fn_kwargs):
...
@@ -213,7 +202,3 @@ def _test_fn_on_batch(batch_tensors, fn, scripted_fn_atol=1e-8, **fn_kwargs):
# scriptable function test
# scriptable function test
s_transformed_batch
=
scripted_fn
(
batch_tensors
,
**
fn_kwargs
)
s_transformed_batch
=
scripted_fn
(
batch_tensors
,
**
fn_kwargs
)
torch
.
testing
.
assert_close
(
transformed_batch
,
s_transformed_batch
,
rtol
=
1e-5
,
atol
=
scripted_fn_atol
)
torch
.
testing
.
assert_close
(
transformed_batch
,
s_transformed_batch
,
rtol
=
1e-5
,
atol
=
scripted_fn_atol
)
def
run_on_env_var
(
name
,
*
,
skip_reason
=
None
,
exist_ok
=
False
,
default
=
False
):
return
pytest
.
mark
.
skipif
(
not
get_bool_env_var
(
name
,
exist_ok
=
exist_ok
,
default
=
default
),
reason
=
skip_reason
)
test/test_prototype_models.py
View file @
afdf1261
import
importlib
import
importlib
import
os
import
pytest
import
pytest
import
test_models
as
TM
import
test_models
as
TM
import
torch
import
torch
from
common_utils
import
cpu_and_gpu
,
run_on_env_var
,
needs_cuda
from
common_utils
import
cpu_and_gpu
,
needs_cuda
from
torchvision.prototype
import
models
from
torchvision.prototype
import
models
from
torchvision.prototype.models._api
import
WeightsEnum
,
Weights
from
torchvision.prototype.models._api
import
WeightsEnum
,
Weights
from
torchvision.prototype.models._utils
import
handle_legacy_interface
from
torchvision.prototype.models._utils
import
handle_legacy_interface
run_if_test_with_prototype
=
run_on_env_var
(
run_if_test_with_prototype
=
pytest
.
mark
.
skipif
(
"PYTORCH_TEST_WITH_PROTOTYPE"
,
os
.
getenv
(
"PYTORCH_TEST_WITH_PROTOTYPE"
)
!=
"1"
,
skip_
reason
=
"Prototype tests are disabled by default. Set PYTORCH_TEST_WITH_PROTOTYPE=1 to run them."
,
reason
=
"Prototype tests are disabled by default. Set PYTORCH_TEST_WITH_PROTOTYPE=1 to run them."
,
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment