Pre 3.13.0 Variant Migration
Prior to the 3.13.0 release, variants were "add only" and had the variant contents stored in the top level variant
folder. Since the 3.13.0 release, variants now also support modifications and deletions.
These new features resulted in the variant contents being stored in "new" and "original" subdirectories. The following script will move the variant sqlite databases from the old folder structure to new folder structure:
variant-migration.py
import os
import shutil
import sys
from pathlib import Path
# Remove this check and replace the source_folder below if you will be running directly in the python interpreter.
if len(sys.argv) < 2:
print("Error: Please provide the EWB data path as an argument.")
print()
print("Usage: python variant-migration.py <EWB_DATA_PATH>")
sys.exit(1)
# Replace with a hard coded <EWB_DATA_PATH> and remove the above check if you will be running directly in the python interpreter.
source_folder = sys.argv[1]
print(f"Migrating {source_folder}")
for file_path in Path(source_folder).rglob("**/variants/**/*.sqlite"):
print(f" {file_path}...", end="")
if file_path.is_file():
# Leave the top level "variants" database, and anything already in the "new" or "original" folders.
if "-variants" not in file_path.name and file_path.parent.name != "new" and file_path.parent.name != "original":
new_folder = file_path.parent / "new"
destination = new_folder / file_path.name
new_folder.mkdir(parents=True, exist_ok=True)
try:
shutil.move(str(file_path), str(destination))
print(f"moved to {destination}")
except Exception as e:
print(f"Error moving {file_path.name}: {e}")
else:
print("skipped")
else:
print("skipped")
The migration can be run with the EWB data path as an argument:
python variant-migration.py <EWB_DATA_PATH>