Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
0f2528a8
Commit
0f2528a8
authored
3 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Plain Diff
Merge branch 'export-metadata-version' into 'master'
Include worker versions from metadata in corpus export Closes
#818
See merge request
!1449
parents
de9bc10b
156ff2a7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1449
Include worker versions from metadata in corpus export
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/export/worker_version.sql
+5
-0
5 additions, 0 deletions
arkindex/documents/export/worker_version.sql
arkindex/documents/tests/tasks/test_export.py
+36
-1
36 additions, 1 deletion
arkindex/documents/tests/tasks/test_export.py
with
41 additions
and
1 deletion
arkindex/documents/export/worker_version.sql
+
5
−
0
View file @
0f2528a8
...
...
@@ -26,4 +26,9 @@ UNION
FROM
documents_transcriptionentity
te
INNER
JOIN
documents_entity
entity
ON
(
te
.
entity_id
=
entity
.
id
)
WHERE
entity
.
corpus_id
=
'{corpus_id}'
::
uuid
UNION
SELECT
md
.
worker_version_id
FROM
documents_metadata
md
INNER
JOIN
documents_element
element
ON
(
md
.
element_id
=
element
.
id
)
WHERE
element
.
corpus_id
=
'{corpus_id}'
::
uuid
)
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/tasks/test_export.py
+
36
−
1
View file @
0f2528a8
...
...
@@ -4,11 +4,12 @@ import sqlite3
from
datetime
import
datetime
,
timezone
from
textwrap
import
dedent
from
unittest.mock
import
call
,
patch
from
uuid
import
uuid4
from
django.core
import
mail
from
django.test
import
override_settings
from
arkindex.dataimport.models
import
WorkerVersion
from
arkindex.dataimport.models
import
Repository
,
RepositoryType
,
WorkerVersion
,
WorkerVersionState
from
arkindex.documents.export
import
export_corpus
from
arkindex.documents.models
import
(
Classification
,
...
...
@@ -17,15 +18,33 @@ from arkindex.documents.models import (
EntityLink
,
EntityType
,
MetaData
,
MetaType
,
Transcription
,
TranscriptionEntity
,
)
from
arkindex.images.models
import
Image
from
arkindex.project.tests
import
FixtureTestCase
from
ponos.models
import
Artifact
class
TestExport
(
FixtureTestCase
):
@classmethod
def
setUpTestData
(
cls
):
super
().
setUpTestData
()
cls
.
repo
=
Repository
.
objects
.
get
(
type
=
RepositoryType
.
Worker
)
cls
.
revision
=
cls
.
repo
.
revisions
.
first
()
# The fixtures have two worker versions, only one of them is used in existing elements
cls
.
recognizer
=
cls
.
repo
.
workers
.
get
(
slug
=
'
reco
'
).
versions
.
get
()
def
_make_worker_version
(
self
):
return
self
.
revision
.
versions
.
create
(
worker
=
self
.
repo
.
workers
.
create
(
slug
=
str
(
uuid4
())),
configuration
=
{},
state
=
WorkerVersionState
.
Available
,
docker_image
=
Artifact
.
objects
.
first
(),
)
@override_settings
(
PUBLIC_HOSTNAME
=
'
https://darkindex.lol
'
)
@patch
(
'
arkindex.documents.export.datetime
'
)
@patch
(
'
arkindex.documents.export.os.unlink
'
)
...
...
@@ -37,6 +56,15 @@ class TestExport(FixtureTestCase):
transcription
=
Transcription
.
objects
.
first
()
version
=
WorkerVersion
.
objects
.
get
(
worker__slug
=
'
reco
'
)
metadata_version
=
self
.
_make_worker_version
()
element
.
metadatas
.
create
(
type
=
MetaType
.
Numeric
,
name
=
'
Score
'
,
value
=
1
,
index
=
0
,
worker_version
=
metadata_version
,
)
element
.
classifications
.
create
(
ml_class
=
self
.
corpus
.
ml_classes
.
create
(
name
=
'
Blah
'
),
confidence
=
.
55555555
,
...
...
@@ -117,6 +145,13 @@ class TestExport(FixtureTestCase):
version
.
worker
.
slug
,
version
.
worker
.
type
,
version
.
revision
.
hash
),
(
str
(
metadata_version
.
id
),
metadata_version
.
worker
.
name
,
metadata_version
.
worker
.
slug
,
metadata_version
.
worker
.
type
,
metadata_version
.
revision
.
hash
)
]
)
...
...
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