Skip to content

Commit

Permalink
🐛 Dont assume sample_id exists, since fk is optional on BS
Browse files Browse the repository at this point in the history
  • Loading branch information
znatty22 committed Jun 4, 2024
1 parent ff6c83f commit cf58921
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ def query_target_ids(cls, host, key_components):

@classmethod
def build_entity(cls, record, get_target_id_from_record):
# sample foreign key is optional
try:
sample_id = get_target_id_from_record(Sample, record)
except Exception:
sample_id = None

secondary_components = {
"kf_id": get_target_id_from_record(cls, record),
"sequencing_center_id": record.get(
Expand Down Expand Up @@ -677,7 +683,7 @@ def build_entity(cls, record, get_target_id_from_record):
CONCEPT.BIOSPECIMEN.DBGAP_STYLE_CONSENT_CODE
),
"consent_type": record.get(CONCEPT.BIOSPECIMEN.CONSENT_SHORT_NAME),
"sample_id": get_target_id_from_record(Sample, record),
"sample_id": sample_id,
}
return {
**cls.get_key_components(record, get_target_id_from_record),
Expand Down

0 comments on commit cf58921

Please sign in to comment.