Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export 4CAT datasets and analyses as ZIP file... and import them elsewhere! #452

Merged
merged 14 commits into from
Oct 1, 2024
16 changes: 15 additions & 1 deletion common/lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from common.config_manager import config
from common.lib.job import Job, JobNotFoundException
from common.lib.module_loader import ModuleCollector
from common.lib.helpers import get_software_commit, NullAwareTextIOWrapper, convert_to_int
from common.lib.helpers import get_software_commit, NullAwareTextIOWrapper, convert_to_int, get_software_version
from common.lib.item_mapping import MappedItem, MissingMappedField, DatasetItem
from common.lib.fourcat_module import FourcatModule
from common.lib.exceptions import (ProcessorInterruptedException, DataSetException, DataSetNotFoundException,
Expand Down Expand Up @@ -1586,6 +1586,20 @@ def get_media_type(self):
# Default to text
return self.parameters.get("media_type", "text")

def get_metadata(self):
"""
Get dataset metadata

This consists of all the data stored in the database for this dataset, plus the current 4CAT version (appended
as 'current_4CAT_version'). This is useful for exporting datasets, as it can be used by another 4CAT instance to
update its database (and ensure compatibility with the exporting version of 4CAT).
"""
metadata = self.db.fetchone("SELECT * FROM datasets WHERE key = %s", (self.key,))

# get 4CAT version (presumably to ensure export is compatible with import)
metadata["current_4CAT_version"] = get_software_version()
return metadata

def get_result_url(self):
"""
Gets the 4CAT frontend URL of a dataset file.
Expand Down
Loading