Skip to content

Commit

Permalink
add the 'portal_metadata_only' field to computed file serializer and …
Browse files Browse the repository at this point in the history
…viewsert's filterset_fileds attribute to make it filter-able, and prepare the date output directory in create_portal_metadata management command
  • Loading branch information
nozomione committed Sep 11, 2024
1 parent b623c08 commit 7eb7b46
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/scpca_portal/management/commands/create_portal_metadata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import shutil
from argparse import BooleanOptionalAction

from django.conf import settings
Expand Down Expand Up @@ -28,7 +29,14 @@ def handle(self, *args, **kwargs):
self.create_portal_metadata(**kwargs)

def create_portal_metadata(self, clean_up_output_data: bool, update_s3: bool, **kwargs):
# Purge the pre-existing portal metadata file from the database and s3
# Prepare the data output directory
output_directory = common.OUTPUT_DATA_PATH
# Remove the existing data output directory if any
shutil.rmtree(output_directory, ignore_errors=True)
logger.info("Creating the data output directory")
output_directory.mkdir(exist_ok=True, parents=True)

# Purge the existing portal metadata file from the database and s3 if any
if old_computed_file := ComputedFile.objects.filter(portal_metadata_only=True).first():
self.purge_computed_file(old_computed_file, update_s3=update_s3)

Expand Down
1 change: 1 addition & 0 deletions api/scpca_portal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Meta:
"id",
"includes_merged",
"metadata_only",
"portal_metadata_only",
"modality",
"project",
"s3_bucket",
Expand Down
2 changes: 2 additions & 0 deletions api/scpca_portal/views/computed_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Meta:
"has_multiplexed_data",
"id",
"metadata_only",
"portal_metadata_only",
"modality",
"project",
"s3_bucket",
Expand Down Expand Up @@ -58,6 +59,7 @@ class ComputedFileViewSet(NestedViewSetMixin, viewsets.ReadOnlyModelViewSet):
"project__id",
"sample__id",
"id",
"portal_metadata_only",
"format",
"modality",
"includes_celltype_report",
Expand Down

0 comments on commit 7eb7b46

Please sign in to comment.