Skip to content

Commit

Permalink
Handle multiple participant external_ids in create_test_subset.py (#825)
Browse files Browse the repository at this point in the history
Fix previous oversight: transfer_participants() needs adjustment as
Participant and ParticipantUpsert now have an `external_ids` field.
We future-proof the two maps being built by adding all external ids,
even though at present only the primary one is returned by the
GraphQL queries.

[TODO] In future we will represent the extra external ids
in GraphQLParticipant too and revisit the initialisation of
transfer_participant's `external_ids` field.
  • Loading branch information
jmarshall authored Jun 17, 2024
1 parent 71dddbe commit aa08309
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/create_test_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,9 @@ def transfer_participants(
)

target_project_pid_map = {
participant['external_id']: participant['id']
external_id: participant['id']
for participant in existing_participants
for external_id in participant['external_ids'].values()
}

participants_to_transfer = []
Expand All @@ -715,7 +716,7 @@ def transfer_participants(
else:
del participant['id']
transfer_participant = {
'external_id': participant['externalId'],
'external_ids': {PRIMARY_EXTERNAL_ORG: participant['externalId']},
'meta': participant.get('meta') or {},
'karyotype': participant.get('karyotype'),
'reported_gender': participant.get('reportedGender'),
Expand All @@ -733,9 +734,9 @@ def transfer_participants(
external_to_internal_participant_id_map: dict[str, int] = {}

for participant in upserted_participants:
external_to_internal_participant_id_map[participant['external_id']] = (
participant['id']
)
for external_id in participant['external_ids'].values():
external_to_internal_participant_id_map[external_id] = participant['id']

return external_to_internal_participant_id_map


Expand Down

0 comments on commit aa08309

Please sign in to comment.