Skip to content

Commit

Permalink
Merge pull request #1290 from Sage-Bionetworks/develop-bug-adding-ann…
Browse files Browse the repository at this point in the history
…otations-to-files-file-only-FDS-1028

Bug Fix: Adding annotations to files with -mrt file_only parameter
  • Loading branch information
mialy-defelice authored Sep 15, 2023
2 parents 1610a40 + 7dae788 commit ca5f293
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions schematic/store/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ def _create_entity_id(self, idx, row, manifest, datasetId):
manifest.loc[idx, "entityId"] = entityId
return manifest, entityId

def add_entities(
def add_annotations_to_entities_files(
self,
se,
schemaGenerator,
Expand Down Expand Up @@ -1457,12 +1457,13 @@ def add_entities(
manifest.loc[idx, "entityId"] = manifest_synapse_table_id
entityId = ''
else:
# get the entity id corresponding to this row
# get the file id of the file to annotate, collected in above step.
entityId = row["entityId"]

# Adding annotations to connected files.
if entityId:
self._add_annotations(se, schemaGenerator, row, entityId, hideBlanks)
logger.info(f"Added annotations to entity: {entityId}")
return manifest

def upload_manifest_as_table(
Expand Down Expand Up @@ -1506,7 +1507,7 @@ def upload_manifest_as_table(
useSchemaLabel,
table_manipulation)

manifest = self.add_entities(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks, manifest_synapse_table_id)
manifest = self.add_annotations_to_entities_files(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks, manifest_synapse_table_id)
# Load manifest to synapse as a CSV File
manifest_synapse_file_id = self.upload_manifest_file(manifest, metadataManifestPath, datasetId, restrict, component_name = component_name)

Expand Down Expand Up @@ -1540,8 +1541,7 @@ def upload_manifest_as_csv(
restrict,
manifest_record_type,
hideBlanks,
component_name,
with_entities = False,):
component_name):
"""Upload manifest to Synapse as a csv only.
Args:
se: SchemaExplorer object
Expand All @@ -1557,8 +1557,8 @@ def upload_manifest_as_csv(
Return:
manifest_synapse_file_id (str): SynID of manifest csv uploaded to synapse.
"""
if with_entities:
manifest = self.add_entities(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks)
# remove with_entities parameter and rename add_annotations, as add_annototaions_to_files_entities.
manifest = self.add_annotations_to_entities_files(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks)

# Load manifest to synapse as a CSV File
manifest_synapse_file_id = self.upload_manifest_file(manifest,
Expand Down Expand Up @@ -1613,7 +1613,7 @@ def upload_manifest_combo(
useSchemaLabel=useSchemaLabel,
table_manipulation=table_manipulation,)

manifest = self.add_entities(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks, manifest_synapse_table_id)
manifest = self.add_annotations_to_entities_files(se, schemaGenerator, manifest, manifest_record_type, datasetId, hideBlanks, manifest_synapse_table_id)

# Load manifest to synapse as a CSV File
manifest_synapse_file_id = self.upload_manifest_file(manifest, metadataManifestPath, datasetId, restrict, component_name)
Expand Down Expand Up @@ -1690,7 +1690,6 @@ def associateMetadataWithFiles(
hideBlanks=hideBlanks,
manifest_record_type=manifest_record_type,
component_name = component_name,
with_entities = False,
)
elif manifest_record_type == "table_and_file":
manifest_synapse_file_id = self.upload_manifest_as_table(
Expand Down Expand Up @@ -1718,7 +1717,6 @@ def associateMetadataWithFiles(
hideBlanks=hideBlanks,
manifest_record_type=manifest_record_type,
component_name = component_name,
with_entities=True,
)
elif manifest_record_type == "table_file_and_entities":
manifest_synapse_file_id = self.upload_manifest_combo(
Expand Down

0 comments on commit ca5f293

Please sign in to comment.