Skip to content

Commit

Permalink
Add consumer-side robustness to gql/Metamist (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattWellie authored Oct 24, 2024
1 parent dcc2f18 commit 1126264
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpg_workflows/metamist.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from enum import Enum
from typing import Any, Callable, Optional

from gql.transport.exceptions import TransportServerError
from tenacity import (
retry,
retry_if_exception_type,
Expand Down Expand Up @@ -333,6 +334,12 @@ def get_sgs_by_project_from_cohort(self, cohort_id: str) -> dict:
# TODO (mwelland): return all the SequencingGroups in the Cohort, no need for stratification
return sort_sgs_by_project(sequencing_groups)

@retry(
stop=stop_after_attempt(3),
wait=wait_exponential(multiplier=3, min=8, max=30),
retry=retry_if_exception_type(TransportServerError),
reraise=True,
)
def get_sg_entries(self, dataset_name: str) -> list[dict]:
"""
Retrieve sequencing group entries for a dataset, in the context of access level
Expand All @@ -358,8 +365,7 @@ def get_sg_entries(self, dataset_name: str) -> list[dict]:
},
)

sequencing_groups = sequencing_group_entries['project']['sequencingGroups']
return sequencing_groups
return sequencing_group_entries['project']['sequencingGroups']

def update_analysis(self, analysis: Analysis, status: AnalysisStatus):
"""
Expand Down

0 comments on commit 1126264

Please sign in to comment.