diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 26fed7085..18b9f39b9 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 6.8.0 +current_version = 6.9.0 commit = True tag = False parse = (?P\d+)\.(?P\d+)\.(?P[A-z0-9-]+) diff --git a/api/server.py b/api/server.py index b5d58209b..cdc03e669 100644 --- a/api/server.py +++ b/api/server.py @@ -19,7 +19,7 @@ from db.python.utils import get_logger # This tag is automatically updated by bump2version -_VERSION = '6.8.0' +_VERSION = '6.9.0' logger = get_logger() diff --git a/deploy/python/version.txt b/deploy/python/version.txt index e029aa99b..97f578152 100644 --- a/deploy/python/version.txt +++ b/deploy/python/version.txt @@ -1 +1 @@ -6.8.0 +6.9.0 diff --git a/metamist/graphql/__init__.py b/metamist/graphql/__init__.py index 5696293f7..4a88b5383 100644 --- a/metamist/graphql/__init__.py +++ b/metamist/graphql/__init__.py @@ -4,18 +4,23 @@ - construct queries using the `gql` function (which validates graphql syntax) - validate queries with metamist schema (by fetching the schema) """ + import os +from json.decoder import JSONDecodeError from typing import Any, Dict +import backoff from gql import Client from gql import gql as gql_constructor from gql.transport.aiohttp import AIOHTTPTransport from gql.transport.aiohttp import log as aiohttp_logger +from gql.transport.exceptions import TransportServerError from gql.transport.requests import RequestsHTTPTransport from gql.transport.requests import log as requests_logger # this does not import itself, it imports the module from graphql import DocumentNode # type: ignore +from requests.exceptions import HTTPError from cpg_utils.cloud import get_google_identity_token @@ -137,8 +142,17 @@ def validate(doc: DocumentNode, client=None, use_local_schema=False): # use older style typing to broaden supported Python versions +@backoff.on_exception( + backoff.expo, + exception=(HTTPError, JSONDecodeError, TransportServerError), + max_time=10, + max_tries=3, +) def query( - _query: str | DocumentNode, variables: Dict = None, client: Client = None, log_response: bool = False + _query: str | DocumentNode, + variables: Dict | None = None, + client: Client | None = None, + log_response: bool = False, ) -> Dict[str, Any]: """Query the metamist GraphQL API""" if variables is None: @@ -159,8 +173,17 @@ def query( return response +@backoff.on_exception( + backoff.expo, + exception=(HTTPError, JSONDecodeError, TransportServerError), + max_time=10, + max_tries=3, +) async def query_async( - _query: str | DocumentNode, variables: Dict = None, client: Client = None, log_response: bool = False + _query: str | DocumentNode, + variables: Dict | None = None, + client: Client | None = None, + log_response: bool = False, ) -> Dict[str, Any]: """Asynchronously query the Metamist GraphQL API""" if variables is None: diff --git a/setup.py b/setup.py index 7e6ad5d47..bcd885cad 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name=PKG, # This tag is automatically updated by bump2version - version='6.8.0', + version='6.9.0', description='Python API for interacting with the Sample API system', long_description=readme, long_description_content_type='text/markdown', @@ -27,6 +27,7 @@ license='MIT', packages=all_packages, install_requires=[ + 'backoff>=2.2.1', 'click', 'google-auth', 'google-api-core', # dependency to google-auth that however is not diff --git a/web/package.json b/web/package.json index 1c1527f30..6c247c0eb 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "metamist", - "version": "6.8.0", + "version": "6.9.0", "private": true, "dependencies": { "@apollo/client": "^3.7.3",