Skip to content

Commit

Permalink
Sort workspaces before concatenating study names
Browse files Browse the repository at this point in the history
The get_workspace_for_phenotype_inventory helper function had a bug
when workspaces were not properly sorted before calling itertools.groupby.
This was only apparent on the stage/prod servers, and not in mariadb.
I couldn't reproduce the bug in CI (possibly because the charset was
different between prod and stage?), and I'm not entirely sure why.
However, this fix to the code makes an interactive check in stage
work correctly.
  • Loading branch information
amstilp committed Jul 29, 2024
1 parent fdca4df commit 7f60a52
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions primed/primed_anvil/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ def get_workspaces_for_phenotype_inventory():

# Combine all querysets and process into the expected output for the AnVIL workflow.
workspaces = dbgap_workspaces.union(cdsa_workspaces).union(open_access_workspaces)
# Sort by workspace_name so that itertools.groupby works as expected.
workspaces = sorted(workspaces, key=lambda x: x["workspace_name"])
json = {}
for key, group in groupby(workspaces, lambda x: x["workspace_name"]):
study_names = [x["study_names"] if x["study_names"] else "" for x in group]
Expand Down

0 comments on commit 7f60a52

Please sign in to comment.