Skip to content

Commit

Permalink
feat: allow running review app to validate PR from external contribution
Browse files Browse the repository at this point in the history
* create a review app to access to different basic streamsync application
  • Loading branch information
FabienArcellier committed Feb 19, 2024
1 parent 5242575 commit 7ff972b
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: streamsync --port $PORT --host 0.0.0.0 --enable-remote-edit edit apps/hello
web: python apps/reviewapp.py
40 changes: 40 additions & 0 deletions apps/reviewapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os

import uvicorn
import streamsync.serve
from fastapi import FastAPI, Response

def app_path(app_name: str) -> str:
return os.path.join(os.path.dirname(__file__), app_name)

root_asgi_app = FastAPI(lifespan=streamsync.serve.lifespan)
sub_asgi_app_1 = streamsync.serve.get_asgi_app(app_path("hello"), "edit", enable_remote_edit=True)
sub_asgi_app_2 = streamsync.serve.get_asgi_app(app_path("default"), "edit", enable_remote_edit=True)
sub_asgi_app_3 = streamsync.serve.get_asgi_app(app_path("quickstart"), "edit", enable_remote_edit=True)

root_asgi_app.mount("/hello/", sub_asgi_app_1)
root_asgi_app.mount("/default/", sub_asgi_app_2)
root_asgi_app.mount("/quickstart/", sub_asgi_app_3)



@root_asgi_app.get("/")
async def init():
links = [
f'<li><a href="/hello">hello</a></li>',
f'<li><a href="/default"">default</a></li>',
f'<li><a href="/quickstart">quickstart</a></li>',
]

return Response("""
<h1>Streamsync review app</h1>
<ul>
""" + "\n".join(links) + """
</ul>
""")

uvicorn.run(root_asgi_app,
host="0.0.0.0",
port=os.getenv('PORT', 8000),
log_level="warning",
ws_max_size=streamsync.serve.MAX_WEBSOCKET_MESSAGE_SIZE)
108 changes: 107 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ watchdog = ">= 3.0.0, < 4"
pandas = {version = ">= 2.2.0, < 3", optional = true}
pyarrow = {version = ">= 15.0.0, < 16.0.0",optional = true}
plotly = {version = ">= 5.18.0, < 6", optional = true}
scikit-learn = {version = "^1.4.1.post1", optional = true}


[tool.poetry.group.build]
Expand Down
1 change: 1 addition & 0 deletions src/streamsync/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ async def stream(websocket: WebSocket):

server_path = os.path.dirname(__file__)
server_static_path = pathlib.Path(server_path) / "static"

if server_static_path.exists():
asgi_app.mount(
"/", StaticFiles(directory=str(server_static_path), html=True), name="server_static")
Expand Down

0 comments on commit 7ff972b

Please sign in to comment.