Skip to content

Commit

Permalink
fix!: Code refactoring to patch broken local dev setup (#646)
Browse files Browse the repository at this point in the history
* refactored to allow proper local use

* added a default for environment

* Bump version: 6.6.0 → 6.7.0

* Revert "Bump version: 6.6.0 → 6.7.0"

This reverts commit c9b4b6e. Going to use 'patch' instead

* Bump version: 6.6.0 → 6.6.1

* Fixed linting errors
  • Loading branch information
nevoodoo authored Jan 10, 2024
1 parent 7087297 commit 674d1f1
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 6.6.0
current_version = 6.6.1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>[A-z0-9-]+)
Expand Down
2 changes: 1 addition & 1 deletion api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from api.settings import PROFILE_REQUESTS, SKIP_DATABASE_CONNECTION

# This tag is automatically updated by bump2version
_VERSION = '6.6.0'
_VERSION = '6.6.1'

logger = get_logger()

Expand Down
2 changes: 1 addition & 1 deletion deploy/python/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.0
6.6.1
38 changes: 24 additions & 14 deletions metamist/graphql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ def configure_sync_client(
if _sync_client and not force_recreate:
return _sync_client

token = auth_token or get_google_identity_token(
target_audience=metamist.configuration.sm_url
)
transport = RequestsHTTPTransport(
url=url or get_sm_url(),
headers={'Authorization': f'Bearer {token}'},
)
env = os.getenv('SM_ENVIRONMENT', 'PRODUCTION').lower()
if env == 'local':
transport = RequestsHTTPTransport(url=url or get_sm_url())
else:
token = auth_token or get_google_identity_token(
target_audience=metamist.configuration.sm_url
)
transport = RequestsHTTPTransport(
url=url or get_sm_url(),
headers={'Authorization': f'Bearer {token}'},
)

_sync_client = Client(
transport=transport, schema=schema, fetch_schema_from_transport=schema is None
)
Expand All @@ -78,13 +83,18 @@ async def configure_async_client(
if _async_client and not force_recreate:
return _async_client

token = auth_token or get_google_identity_token(
target_audience=metamist.configuration.sm_url
)
transport = AIOHTTPTransport(
url=url or get_sm_url(),
headers={'Authorization': f'Bearer {token}'},
)
env = os.getenv('SM_ENVIRONMENT', 'PRODUCTION').lower()
if env == 'local':
transport = AIOHTTPTransport(url=url or get_sm_url())
else:
token = auth_token or get_google_identity_token(
target_audience=metamist.configuration.sm_url
)
transport = AIOHTTPTransport(
url=url or get_sm_url(),
headers={'Authorization': f'Bearer {token}'},
)

_async_client = Client(
transport=transport, schema=schema, fetch_schema_from_transport=schema is None
)
Expand Down
11 changes: 7 additions & 4 deletions openapi-templates/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ JSON_SCHEMA_VALIDATION_KEYWORDS = {

sm_url = getenv('SM_URL')
if not sm_url:
env = getenv('SM_ENVIRONMENT', 'PRODUCTION')
if 'local' in env.lower():
env = getenv('SM_ENVIRONMENT', 'PRODUCTION').lower()
if 'local' in env:
sm_url = "http://localhost:8000"
elif 'dev' in env.lower():
elif 'dev' in env:
sm_url = 'https://sample-metadata-api-dev-mnrpw3mdza-ts.a.run.app'
else:
sm_url = 'https://sample-metadata-api-mnrpw3mdza-ts.a.run.app'
Expand Down Expand Up @@ -192,7 +192,7 @@ conf = {{{packageName}}}.Configuration(
):
"""Constructor
"""
env = getenv('SM_ENVIRONMENT', 'PRODUCTION')
self.env = getenv('SM_ENVIRONMENT', 'PRODUCTION').lower()
self._base_path = host or sm_url

"""Default Base url
Expand Down Expand Up @@ -491,6 +491,9 @@ conf = {{{packageName}}}.Configuration(

:return: The Auth Settings information dict.
"""
if self.env == 'local':
return {}

auth = {
'HTTPBearer': {
'type': 'bearer',
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
setup(
name=PKG,
# This tag is automatically updated by bump2version
version='6.6.0',
version='6.6.1',
description='Python API for interacting with the Sample API system',
long_description=readme,
long_description_content_type='text/markdown',
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metamist",
"version": "6.6.0",
"version": "6.6.1",
"private": true,
"dependencies": {
"@apollo/client": "^3.7.3",
Expand Down

0 comments on commit 674d1f1

Please sign in to comment.