Skip to content

Commit

Permalink
Automate the building of the OVE sections
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianDAlessandro committed Sep 21, 2023
1 parent f56fc43 commit 569f467
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import dash # type: ignore
from dash import Dash, dcc, html # type: ignore

from .core_api import create_all

app = Dash(__name__, use_pages=True, update_title=None)

app.layout = html.Div(
Expand All @@ -25,5 +27,9 @@

server = app.server

# Create the OVE Sections
create_all()


if __name__ == "__main__":
app.run_server(debug=True)
18 changes: 14 additions & 4 deletions app/core_api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""Interacts with the OVE Core API."""
import json
import logging
import os
import time

import requests

"""
Constants for API URLs.
"""
APP_URL = "http://146.179.34.13:8080/app/html"
API_URL = "http://liionsden.rcs.ic.ac.uk:8080"
PLOT_URL = "http://liionsden.rcs.ic.ac.uk:8050"
APP_URL = os.environ.get("APP_URL", "http://146.179.34.13:8080/app/html")
API_URL = os.environ.get("API_URL", "http://liionsden.rcs.ic.ac.uk:8080")
PLOT_URL = os.environ.get("PLOT_URL", "http://liionsden.rcs.ic.ac.uk:8050")

"""
Initial config for sections.
Expand Down Expand Up @@ -89,11 +92,18 @@
]


def wait_for_ove() -> None:
"""Function to wait for the OVE Core API to be available after startup."""
while requests.get(API_URL).status_code != 200:
time.sleep(5)


def create_all() -> None:
"""Function for creating all initial sections."""
wait_for_ove()
for section in INIT_SECTIONS:
response = requests.post(f"{API_URL}/section", json=section)
print(response.text)
logging.info(response.text)


def move_section(id_num: int, space: str) -> None:
Expand Down
6 changes: 6 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def generate_docker_compose(template_file: str, ip: str, develop: bool = False)
"OVE_HOST": f"{ip}:8080",
# TODO: Point to the on-prem openvidu (keep as port 4443)
"OPENVIDU_HOST": "https://146.179.34.13:4443",
"PLOT_URL": f"{ip}:8050",
}

# Read the template file
Expand All @@ -68,6 +69,11 @@ def generate_docker_compose(template_file: str, ip: str, develop: bool = False)
docker_compose["services"]["dash"] = {
"ports": ["8050:8050"],
"volumes": ["./app:/app"],
"environment": {
"APP_URL": f"http://{lines_to_replace['OVE_HOST']}/app/html",
"API_URL": f"http://{lines_to_replace['OVE_HOST']}",
"PLOT_URL": f"http://{lines_to_replace['PLOT_URL']}",
},
}
if develop:
docker_compose["services"]["dash"]["build"] = "."
Expand Down

0 comments on commit 569f467

Please sign in to comment.