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
e2c1047b
Commit
e2c1047b
authored
4 years ago
by
Eva Bardou
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Retrieve transcriptions from local cache in list_transcriptions
parent
41204d06
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/cache.py
+2
-0
2 additions, 0 deletions
arkindex_worker/cache.py
arkindex_worker/worker.py
+24
-3
24 additions, 3 deletions
arkindex_worker/worker.py
with
26 additions
and
3 deletions
arkindex_worker/cache.py
+
2
−
0
View file @
e2c1047b
...
...
@@ -36,6 +36,8 @@ CachedTranscription = namedtuple(
def
convert_table_tuple
(
table
):
if
table
==
"
elements
"
:
return
CachedElement
elif
table
==
"
transcriptions
"
:
return
CachedTranscription
else
:
raise
NotImplementedError
...
...
This diff is collapsed.
Click to expand it.
arkindex_worker/worker.py
+
24
−
3
View file @
e2c1047b
...
...
@@ -901,9 +901,30 @@ class ElementsWorker(BaseWorker):
),
"
worker_version should be of type str
"
query_params
[
"
worker_version
"
]
=
worker_version
transcriptions
=
self
.
api_client
.
paginate
(
"
ListTranscriptions
"
,
id
=
element
.
id
,
**
query_params
)
if
self
.
cache
and
recursive
is
None
:
# Checking that we only received query_params handled by the cache
assert
set
(
query_params
.
keys
())
<=
{
"
worker_version
"
,
},
"
When using the local cache, you can only filter by
'
worker_version
'"
conditions
=
[(
"
element_id
"
,
"
=
"
,
convert_str_uuid_to_hex
(
element
.
id
))]
if
worker_version
:
conditions
.
append
(
(
"
worker_version_id
"
,
"
=
"
,
convert_str_uuid_to_hex
(
worker_version
))
)
transcriptions
=
self
.
cache
.
fetch
(
"
transcriptions
"
,
where
=
conditions
,
)
else
:
if
self
.
cache
:
logger
.
warning
(
"'
recursive
'
filter was set, results will be retrieved from the API since the local cache doesn
'
t handle this filter.
"
)
transcriptions
=
self
.
api_client
.
paginate
(
"
ListTranscriptions
"
,
id
=
element
.
id
,
**
query_params
)
return
transcriptions
...
...
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