Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
7a534ced
Commit
7a534ced
authored
7 months ago
by
James Briggs
Browse files
Options
Downloads
Patches
Plain Diff
fix: tests and errors messages
parent
567e4c9f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
semantic_router/encoders/vit.py
+3
-3
3 additions, 3 deletions
semantic_router/encoders/vit.py
tests/unit/encoders/test_vit.py
+10
-9
10 additions, 9 deletions
tests/unit/encoders/test_vit.py
with
13 additions
and
12 deletions
semantic_router/encoders/vit.py
+
3
−
3
View file @
7a534ced
...
...
@@ -27,7 +27,7 @@ class VitEncoder(BaseEncoder):
from
transformers
import
ViTImageProcessor
,
ViTModel
except
ImportError
:
raise
ImportError
(
"
Please install transformers to use
HuggingFace
Encoder.
"
"
Please install transformers to use
Vit
Encoder.
"
"
You can install it with:
"
"
`pip install semantic-router[vision]`
"
)
...
...
@@ -37,7 +37,7 @@ class VitEncoder(BaseEncoder):
import
torchvision.transforms
as
T
except
ImportError
:
raise
ImportError
(
"
Please install Pytorch to use
HuggingFace
Encoder.
"
"
Please install Pytorch to use
Vit
Encoder.
"
"
You can install it with:
"
"
`pip install semantic-router[vision]`
"
)
...
...
@@ -46,7 +46,7 @@ class VitEncoder(BaseEncoder):
from
PIL
import
Image
except
ImportError
:
raise
ImportError
(
"
Please install PIL to use
HuggingFace
Encoder.
"
"
Please install PIL to use
Vit
Encoder.
"
"
You can install it with:
"
"
`pip install semantic-router[vision]`
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/unit/encoders/test_vit.py
+
10
−
9
View file @
7a534ced
from
unittest.mock
import
patch
import
os
import
numpy
as
np
import
pytest
...
...
@@ -33,15 +35,14 @@ def misshaped_pil_image():
class
TestVitEncoder
:
def
test_vit_encoder__import_errors_transformers
(
self
,
mocker
):
mocker
.
patch
.
dict
(
"
sys.modules
"
,
{
"
transformers
"
:
None
})
with
pytest
.
raises
(
ImportError
):
VitEncoder
()
def
test_vit_encoder__import_errors_torch
(
self
,
mocker
):
mocker
.
patch
.
dict
(
"
sys.modules
"
,
{
"
torch
"
:
None
})
with
pytest
.
raises
(
ImportError
):
VitEncoder
()
def
test_vit_encoder__import_errors_transformers
(
self
):
with
patch
.
dict
(
"
sys.modules
"
,
{
"
transformers
"
:
None
}):
with
pytest
.
raises
(
ImportError
)
as
error
:
VitEncoder
()
assert
"
Please install transformers to use VitEncoder
"
in
str
(
error
.
value
)
@pytest.mark.skipif
(
os
.
environ
.
get
(
"
RUN_HF_TESTS
"
)
is
None
,
reason
=
"
Set RUN_HF_TESTS=1 to run
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment