Skip to content
Snippets Groups Projects
Commit 1c04f391 authored by Valentin Rigal's avatar Valentin Rigal Committed by Erwan Rouchet
Browse files

Skip children fetching parameter for thumbnails generation only

parent f996e579
No related branches found
No related tags found
No related merge requests found
......@@ -122,6 +122,11 @@ class DataImport(IndexableModel):
if elements:
command = ' '.join([command, '--dataimport-id {}'.format(str(self.id))])
# Do not retrieve elements children in case there of thumbnails generation only
thumbnails = self.payload.get('thumbnails')
if thumbnails and len(self.ml_tools) == 0:
command = ' '.join([command, '--skip-children'.format(str(self.id))])
tasks = {
import_task_name: {
'image': settings.ARKINDEX_TASKS_IMAGE,
......
......@@ -499,3 +499,31 @@ class TestWorkflows(FixtureAPITestCase):
'python -m arkindex_tasks.init_elements --corpus-id {} --chunks-number 1 --dataimport-id {}'
.format(str(self.corpus.id), str(dataimport.id))
)
def test_thumbnails_generation_only(self, ml_get_mock):
"""
Generating thumbnails without any workflow must generate an import task
which do not to retrieve filtered elements children
"""
self.client.force_login(self.user)
corpus_type = self.corpus.types.first()
response = self.client.post(
reverse('api:corpus-workflow'),
{
'ml_tools': [],
'corpus': str(self.corpus.id),
'chunks': 3,
'type': corpus_type.slug,
'thumbnails': True
},
format='json'
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
data = response.json()
dataimport = DataImport.objects.get(id=data['id'])
workflow = dataimport.workflow
self.assertEqual(
workflow.recipes['initialisation'].command,
'python -m arkindex_tasks.init_elements --corpus-id {} --chunks-number 3 --type {} --skip-children'
.format(str(self.corpus.id), corpus_type.slug)
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment