Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Code refactoring to patch broken local dev setup #646

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading