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
acc5b8bf
Commit
acc5b8bf
authored
4 days ago
by
Erwan Rouchet
Committed by
Bastien Abadie
4 days ago
Browse files
Options
Downloads
Patches
Plain Diff
Start CorpusExport after committing it in CreateExportProcess
parent
5bad6691
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2539
Start CorpusExport after committing it in CreateExportProcess
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/process/serializers/imports.py
+4
-1
4 additions, 1 deletion
arkindex/process/serializers/imports.py
arkindex/process/tests/process/test_export_process.py
+29
-3
29 additions, 3 deletions
arkindex/process/tests/process/test_export_process.py
with
33 additions
and
4 deletions
arkindex/process/serializers/imports.py
+
4
−
1
View file @
acc5b8bf
...
...
@@ -600,7 +600,10 @@ class ExportProcessSerializer(ProcessDetailsSerializer):
# https://docs.djangoproject.com/en/5.1/ref/models/instances/#state
if
export
.
_state
.
adding
:
export
.
save
()
export
.
start
()
# We must only start after the transaction completes, as the task might be started very quickly by an RQ worker
# before the transaction completes and the CorpusExport does not fully exist in DB yet
transaction
.
on_commit
(
export
.
start
)
# Get or create the worker configuration
worker_configuration
,
_
=
worker_version
.
worker
.
configurations
.
get_or_create
(
configuration
=
{
**
validated_data
[
"
configuration
"
],
"
export_id
"
:
str
(
export
.
id
)},
...
...
This diff is collapsed.
Click to expand it.
arkindex/process/tests/process/test_export_process.py
+
29
−
3
View file @
acc5b8bf
...
...
@@ -426,7 +426,7 @@ class TestExportProcess(FixtureAPITestCase):
def
test_create_export_process_new_sql_export
(
self
,
delay_mock
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
26
):
with
self
.
assertNumQueries
(
26
)
,
self
.
captureOnCommitCallbacks
(
execute
=
True
)
:
response
=
self
.
client
.
post
(
reverse
(
"
api:export-process
"
,
kwargs
=
{
"
corpus_id
"
:
str
(
self
.
corpus
.
id
)}),
{
...
...
@@ -438,6 +438,7 @@ class TestExportProcess(FixtureAPITestCase):
},
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
created_process
=
Process
.
objects
.
get
(
mode
=
ProcessMode
.
Export
)
created_run
=
created_process
.
worker_runs
.
get
()
new_export
=
self
.
corpus
.
exports
.
order_by
(
"
-created
"
).
first
()
...
...
@@ -455,11 +456,19 @@ class TestExportProcess(FixtureAPITestCase):
"
page_type
"
:
"
page
"
})
# The new SQLite export has been started
self
.
assertEqual
(
delay_mock
.
call_count
,
1
)
self
.
assertEqual
(
delay_mock
.
call_args
,
call
(
corpus_export
=
new_export
,
user_id
=
self
.
user
.
id
,
description
=
"
Export of corpus Unit Tests
"
,
))
@patch
(
"
arkindex.project.triggers.export.local_export.delay
"
)
def
test_create_export_process_new_sql_export_with_element
(
self
,
delay_mock
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
30
):
with
self
.
assertNumQueries
(
30
)
,
self
.
captureOnCommitCallbacks
(
execute
=
True
)
:
response
=
self
.
client
.
post
(
reverse
(
"
api:export-process
"
,
kwargs
=
{
"
corpus_id
"
:
str
(
self
.
corpus
.
id
)}),
{
...
...
@@ -472,6 +481,7 @@ class TestExportProcess(FixtureAPITestCase):
},
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
created_process
=
Process
.
objects
.
get
(
mode
=
ProcessMode
.
Export
)
created_run
=
created_process
.
worker_runs
.
get
()
new_export
=
self
.
corpus
.
exports
.
order_by
(
"
-created
"
).
first
()
...
...
@@ -490,13 +500,21 @@ class TestExportProcess(FixtureAPITestCase):
"
page_type
"
:
"
page
"
})
# The new SQLite export has been started
self
.
assertEqual
(
delay_mock
.
call_count
,
1
)
self
.
assertEqual
(
delay_mock
.
call_args
,
call
(
corpus_export
=
new_export
,
user_id
=
self
.
user
.
id
,
description
=
"
Export of corpus Unit Tests
"
,
))
@patch
(
"
arkindex.project.triggers.export.local_export.delay
"
)
def
test_create_export_process_new_sql_export_with_selection
(
self
,
delay_mock
):
self
.
client
.
force_login
(
self
.
user
)
self
.
user
.
selected_elements
.
add
(
self
.
corpus_element
)
self
.
user
.
selected_elements
.
add
(
self
.
other_element
)
with
self
.
assertNumQueries
(
29
):
with
self
.
assertNumQueries
(
29
)
,
self
.
captureOnCommitCallbacks
(
execute
=
True
)
:
response
=
self
.
client
.
post
(
reverse
(
"
api:export-process
"
,
kwargs
=
{
"
corpus_id
"
:
str
(
self
.
corpus
.
id
)}),
{
...
...
@@ -527,6 +545,14 @@ class TestExportProcess(FixtureAPITestCase):
"
page_type
"
:
"
page
"
})
# The new SQLite export has been started
self
.
assertEqual
(
delay_mock
.
call_count
,
1
)
self
.
assertEqual
(
delay_mock
.
call_args
,
call
(
corpus_export
=
new_export
,
user_id
=
self
.
user
.
id
,
description
=
"
Export of corpus Unit Tests
"
,
))
def
test_farm
(
self
):
farm
=
Farm
.
objects
.
get
()
self
.
client
.
force_login
(
self
.
user
)
...
...
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