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
c54146a0
Commit
c54146a0
authored
3 years ago
by
ml bonhomme
Committed by
Erwan Rouchet
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
do not send confidence=None in the payload
parent
e518d9e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!142
do not send confidence=None in the payload
Pipeline
#78956
failed
3 years ago
Stage: test
Stage: build
Changes
2
Pipelines
59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/entity.py
+10
-7
10 additions, 7 deletions
arkindex_worker/worker/entity.py
tests/test_elements_worker/test_entities.py
+78
-3
78 additions, 3 deletions
tests/test_elements_worker/test_entities.py
with
88 additions
and
10 deletions
arkindex_worker/worker/entity.py
+
10
−
7
View file @
c54146a0
...
...
@@ -109,16 +109,19 @@ class EntityMixin(object):
)
return
body
=
{
"
entity
"
:
entity
,
"
length
"
:
length
,
"
offset
"
:
offset
,
"
worker_version_id
"
:
self
.
worker_version_id
,
}
if
confidence
is
not
None
:
body
[
"
confidence
"
]
=
confidence
transcription_ent
=
self
.
request
(
"
CreateTranscriptionEntity
"
,
id
=
transcription
,
body
=
{
"
entity
"
:
entity
,
"
length
"
:
length
,
"
offset
"
:
offset
,
"
worker_version_id
"
:
self
.
worker_version_id
,
"
confidence
"
:
confidence
,
},
body
=
body
,
)
# TODO: Report transcription entity creation
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_entities.py
+
78
−
3
View file @
c54146a0
...
...
@@ -418,7 +418,7 @@ def test_create_transcription_entity_api_error(responses, mock_elements_worker):
]
def
test_create_transcription_entity
(
responses
,
mock_elements_worker
):
def
test_create_transcription_entity
_no_confidence
(
responses
,
mock_elements_worker
):
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/transcription/11111111-1111-1111-1111-111111111111/entity/
"
,
...
...
@@ -451,7 +451,83 @@ def test_create_transcription_entity(responses, mock_elements_worker):
"
offset
"
:
5
,
"
length
"
:
10
,
"
worker_version_id
"
:
"
12341234-1234-1234-1234-123412341234
"
,
"
confidence
"
:
None
,
}
def
test_create_transcription_entity_with_confidence
(
responses
,
mock_elements_worker
):
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/transcription/11111111-1111-1111-1111-111111111111/entity/
"
,
status
=
200
,
json
=
{
"
entity
"
:
"
11111111-1111-1111-1111-111111111111
"
,
"
offset
"
:
5
,
"
length
"
:
10
,
"
confidence
"
:
0.33
,
},
)
mock_elements_worker
.
create_transcription_entity
(
transcription
=
"
11111111-1111-1111-1111-111111111111
"
,
entity
=
"
11111111-1111-1111-1111-111111111111
"
,
offset
=
5
,
length
=
10
,
confidence
=
0.33
,
)
assert
len
(
responses
.
calls
)
==
len
(
BASE_API_CALLS
)
+
1
assert
[
(
call
.
request
.
method
,
call
.
request
.
url
)
for
call
in
responses
.
calls
]
==
BASE_API_CALLS
+
[
(
"
POST
"
,
"
http://testserver/api/v1/transcription/11111111-1111-1111-1111-111111111111/entity/
"
,
),
]
assert
json
.
loads
(
responses
.
calls
[
-
1
].
request
.
body
)
==
{
"
entity
"
:
"
11111111-1111-1111-1111-111111111111
"
,
"
offset
"
:
5
,
"
length
"
:
10
,
"
worker_version_id
"
:
"
12341234-1234-1234-1234-123412341234
"
,
"
confidence
"
:
0.33
,
}
def
test_create_transcription_entity_confidence_none
(
responses
,
mock_elements_worker
):
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/transcription/11111111-1111-1111-1111-111111111111/entity/
"
,
status
=
200
,
json
=
{
"
entity
"
:
"
11111111-1111-1111-1111-111111111111
"
,
"
offset
"
:
5
,
"
length
"
:
10
,
"
confidence
"
:
None
,
},
)
mock_elements_worker
.
create_transcription_entity
(
transcription
=
"
11111111-1111-1111-1111-111111111111
"
,
entity
=
"
11111111-1111-1111-1111-111111111111
"
,
offset
=
5
,
length
=
10
,
confidence
=
None
,
)
assert
len
(
responses
.
calls
)
==
len
(
BASE_API_CALLS
)
+
1
assert
[
(
call
.
request
.
method
,
call
.
request
.
url
)
for
call
in
responses
.
calls
]
==
BASE_API_CALLS
+
[
(
"
POST
"
,
"
http://testserver/api/v1/transcription/11111111-1111-1111-1111-111111111111/entity/
"
,
),
]
assert
json
.
loads
(
responses
.
calls
[
-
1
].
request
.
body
)
==
{
"
entity
"
:
"
11111111-1111-1111-1111-111111111111
"
,
"
offset
"
:
5
,
"
length
"
:
10
,
"
worker_version_id
"
:
"
12341234-1234-1234-1234-123412341234
"
,
}
...
...
@@ -509,7 +585,6 @@ def test_create_transcription_entity_with_cache(
"
offset
"
:
5
,
"
length
"
:
10
,
"
worker_version_id
"
:
"
12341234-1234-1234-1234-123412341234
"
,
"
confidence
"
:
None
,
}
# Check that created transcription entity was properly stored in SQLite cache
...
...
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