Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
5370608e
Commit
5370608e
authored
3 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Support giving a CachedElement in create_classification
parent
f2530289
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/classification.py
+3
-2
3 additions, 2 deletions
arkindex_worker/worker/classification.py
tests/test_elements_worker/test_classifications.py
+8
-2
8 additions, 2 deletions
tests/test_elements_worker/test_classifications.py
with
11 additions
and
4 deletions
arkindex_worker/worker/classification.py
+
3
−
2
View file @
5370608e
...
...
@@ -4,6 +4,7 @@ import os
from
apistar.exceptions
import
ErrorResponse
from
arkindex_worker
import
logger
from
arkindex_worker.cache
import
CachedElement
from
arkindex_worker.models
import
Element
...
...
@@ -65,8 +66,8 @@ class ClassificationMixin(object):
Create a classification on the given element through API
"""
assert
element
and
isinstance
(
element
,
Element
),
"
element shouldn
'
t be null and should be
of type
Element
"
element
,
(
Element
,
CachedElement
)
),
"
element shouldn
'
t be null and should be
an Element or Cached
Element
"
assert
ml_class
and
isinstance
(
ml_class
,
str
),
"
ml_class shouldn
'
t be null and should be of type str
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_classifications.py
+
8
−
2
View file @
5370608e
...
...
@@ -159,7 +159,10 @@ def test_create_classification_wrong_element(mock_elements_worker):
confidence
=
0.42
,
high_confidence
=
True
,
)
assert
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be of type Element
"
assert
(
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be an Element or CachedElement
"
)
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
create_classification
(
...
...
@@ -168,7 +171,10 @@ def test_create_classification_wrong_element(mock_elements_worker):
confidence
=
0.42
,
high_confidence
=
True
,
)
assert
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be of type Element
"
assert
(
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be an Element or CachedElement
"
)
def
test_create_classification_wrong_ml_class
(
mock_elements_worker
,
responses
):
...
...
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