Skip to content

Commit

Permalink
Merge pull request #2 from lalithkota/develop
Browse files Browse the repository at this point in the history
Fixed run_server method call. Fixed openapi push
  • Loading branch information
lalithkota authored Feb 12, 2025
2 parents 7e73556 + 12f38f0 commit 5745718
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/openapi-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
openapi-publish:
name: OpenAPI Generate and Publish
runs-on: ubuntu-latest
env:
BRANCH_NAME: ''
OPENAPI_CHANGED: false
STOPLIGHT_PROJECT_TOKEN: ${{ secrets.STOPLIGHT_PROJECT_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Get branch name (merge)
Expand Down Expand Up @@ -41,10 +45,10 @@ jobs:
add: "api-docs/generated/openapi.json"
- name: Setup nodejs
uses: actions/setup-node@v4
if: env.OPENAPI_CHANGED == 'true'
if: env.STOPLIGHT_PROJECT_TOKEN != '' && env.OPENAPI_CHANGED == 'true'
with:
node-version: '18'
- name: Publish to stoplight
if: env.OPENAPI_CHANGED == 'true'
if: env.STOPLIGHT_PROJECT_TOKEN != '' && env.OPENAPI_CHANGED == 'true'
run: |
npx @stoplight/cli@5 push --ci-token ${{ secrets.STOPLIGHT_PROJECT_TOKEN }} --url https://openg2p.stoplight.io --branch ${{ env.BRANCH_NAME }} --directory api-docs/generated
npx @stoplight/cli@5 push --ci-token ${{ env.STOPLIGHT_PROJECT_TOKEN }} --url https://openg2p.stoplight.io --branch ${{ env.BRANCH_NAME }} --directory api-docs/generated
6 changes: 5 additions & 1 deletion src/openg2p_websub_print_listener/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .config import Settings

_config = Settings.get_config()
_config: Settings = Settings.get_config()

from openg2p_fastapi_common.app import Initializer

Expand All @@ -27,3 +27,7 @@ def init_app(self):
app = super().init_app()
app.router.redirect_slashes = False
return app

def run_server(self, args):
_config._server_running = True
return super().run_server(args)
3 changes: 3 additions & 0 deletions src/openg2p_websub_print_listener/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Settings(Settings):
"""
openapi_version: str = __version__

# Internal Variable
_server_running: bool = False

websub_hub_url: str = "http://localhost:9191/hub"
websub_subscribe_lease_seconds: int | None = None
websub_partner_id: str = ""
Expand Down
3 changes: 2 additions & 1 deletion src/openg2p_websub_print_listener/services/file_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class FileStoreService(BaseService):
def __init__(self, **kw):
super().__init__(**kw)
self.aws_session = aioboto3.Session()
asyncio.run(self.get_or_create_bucket(_config.s3_bucket_name))
if _config._server_running:
asyncio.run(self.get_or_create_bucket(_config.s3_bucket_name))

async def save_file(self, name, data: bytes, mimetype=None, **kw):
file_io = io.BytesIO()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def __init__(self, **kwargs):

self._unsafe_eval = None

self.check_if_templates_exist()
if _config._server_running:
self.check_if_templates_exist()

def get_unsafe_eval(self):
if not self._unsafe_eval:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from openg2p_websub_print_listener.app import Initializer as WebSubPrintListenerApp

WebSubPrintListenerApp()

def test_init():
WebSubPrintListenerApp()

0 comments on commit 5745718

Please sign in to comment.