Skip to content
Snippets Groups Projects
Verified Commit 9efef8da authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Export dataset descriptions

parent 13fb5af4
No related branches found
No related tags found
1 merge request!2398Export dataset descriptions
SELECT
dataset.id,
dataset.name,
dataset.description,
dataset.state,
string_agg(datasetset.name, ',')
FROM training_dataset dataset
......
......@@ -171,6 +171,7 @@ CREATE TABLE metadata (
CREATE TABLE dataset (
id VARCHAR(37) NOT NULL,
name VARCHAR(100) NOT NULL,
description TEXT NOT NULL,
state VARCHAR(50) NOT NULL DEFAULT 'open',
sets TEXT NOT NULL,
PRIMARY KEY (id)
......
......@@ -297,7 +297,7 @@ class Command(BaseCommand):
corpus=self.corpus,
name=row["name"],
creator=self.user,
description="Imported dataset",
description=row["description"] if "description" in row.keys() else "Imported dataset",
)]
def convert_dataset_sets(self, row):
......
......@@ -13,7 +13,7 @@ from arkindex.documents.models import Corpus, Element, ElementPath, EntityType,
from arkindex.documents.tasks import corpus_delete
from arkindex.images.models import Image, ImageServer
from arkindex.process.models import ProcessMode, Repository, Worker, WorkerRun, WorkerType, WorkerVersion
from arkindex.project.tests import FixtureTestCase
from arkindex.project.tests import FixtureTestCase, force_constraints_immediate
from arkindex.training.models import Dataset, DatasetElement
BASE_DIR = Path(__file__).absolute().parent
......@@ -211,7 +211,8 @@ class TestLoadExport(FixtureTestCase):
ImageServer.objects.all().delete()
WorkerVersion.objects.filter(id=reco_version.id).delete()
call_command("load_export", db_path, "--email", self.user.email, "--corpus-name", "My corpus")
with force_constraints_immediate():
call_command("load_export", db_path, "--email", self.user.email, "--corpus-name", "My corpus")
# Call dumpdata command after the import
_, dump_path_after = tempfile.mkstemp(suffix=".json")
......@@ -247,7 +248,8 @@ class TestLoadExport(FixtureTestCase):
db.commit()
db.close()
call_command("load_export", temp_file, "--email", self.user.email, "--corpus-name", "My corpus")
with force_constraints_immediate():
call_command("load_export", temp_file, "--email", self.user.email, "--corpus-name", "My corpus")
corpus = Corpus.objects.get(name="My corpus")
self.assertEqual(corpus.types.all().count(), 0)
......@@ -307,7 +309,8 @@ class TestLoadExport(FixtureTestCase):
# meaning the test can only fail.
ElementPath.objects.filter(element__corpus=self.corpus).delete()
call_command("load_export", db_path, "--email", self.user.email, "--corpus-name", "My corpus")
with force_constraints_immediate():
call_command("load_export", db_path, "--email", self.user.email, "--corpus-name", "My corpus")
corpus = Corpus.objects.get(name="My corpus")
self.assertEqual(corpus.types.all().count(), 6)
......
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