Skip to content
Snippets Groups Projects
Commit 32318ed4 authored by Valentin Rigal's avatar Valentin Rigal
Browse files

Support version 8 exports in load_export

parent da737565
No related branches found
No related tags found
1 merge request!2317Support exports version 8 in the load_export command
This commit is part of merge request !2317. Comments created here will be created in the context of that merge request.
......@@ -38,7 +38,8 @@ from arkindex.process.models import (
from arkindex.training.models import Dataset, DatasetElement, DatasetSet, Model
from arkindex.users.models import Role, User
EXPORT_VERSION = 9
EXPORT_VERSION_MIN = 8
EXPORT_VERSION_MAX = 9
TABLE_NAMES = {
"export_version",
......@@ -519,13 +520,16 @@ class Command(BaseCommand):
# Check database tables
db_results = self.db.execute(SQL_TABLES_QUERY).fetchall()
if not set([table["name"] for table in db_results]) == TABLE_NAMES:
raise CommandError(f"The SQLite database {db_path} is not a correct Arkindex export")
# Database's tables must be a superset of TABLE_NAMES, so we keep compatibility when removing things
if (missing := TABLE_NAMES - set([table["name"] for table in db_results])):
raise CommandError(f"The SQLite database {db_path} miss some expected tables: {sorted(missing)}")
# Check export version
db_results = self.db.execute(SQL_VERSION_QUERY).fetchall()
if len(db_results) != 1 or db_results[0]["version"] != EXPORT_VERSION:
raise CommandError(f"The SQLite database {db_path} does not have the correct export version")
if len(db_results) != 1 or not (
EXPORT_VERSION_MIN <= db_results[0]["version"] <= EXPORT_VERSION_MAX
):
raise CommandError(f"The SQLite database {db_path} does not have a supported export version")
# Retrieve corpus name
date = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M")
......
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