Skip to content

Commit

Permalink
Disentangle develop mode from live_model mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianDAlessandro committed Feb 14, 2024
1 parent 65f56a2 commit 98fc644
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ There is also a requirements to have the OpenVidu server running - see [Deployin

1. Make sure nothing's running
2. Run `bash run_develop.sh` for vis system to run config script and `docker-compose.yml`
- For production, use `run.sh`
- For production, use `run.sh` when using pre-set data, or `run_live.sh` when using the live model.
3. Go to OVE Core at the IP address defined in the `API_URL` environment variable you will now find in `docker-compose.yml`
4. Go to OpenVidu IP address and manually trust website (OPENVIDU_HOST in the `docker-compose.yml`)
5. Log in with username: admin, password: (OPENVIDU_SECRET from docker-compose.yml)
Expand Down
1 change: 1 addition & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
log = logging.getLogger("api_logger")
log.debug("Logging is configured.")

DEVELOP = os.environ.get("DEVELOP", False)
LIVE_MODEL = os.environ.get("LIVE_MODEL", False)
log.debug("Using Live Model" if LIVE_MODEL else "Using Pre-Set Data")
8 changes: 4 additions & 4 deletions app/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dash import Input, Output, callback, dcc # type: ignore
from dash.exceptions import PreventUpdate # type: ignore

from . import LIVE_MODEL, log
from . import DEVELOP, LIVE_MODEL, log
from .datahub_api import get_opal_data, get_wesim_data # , get_dsr_data

N_INTERVALS_DATA = 0
Expand All @@ -13,15 +13,15 @@

WESIM_START_DATE = "2035-01-22 00:00" # corresponding to hour 0 TODO: check

if LIVE_MODEL:
if DEVELOP:
WESIM = {"df": pd.DataFrame({"Col": [0]})}
else:
WESIM = {key: pd.DataFrame(**item) for key, item in get_wesim_data().items()}
for df in WESIM.values():
if "Hour" in df.columns:
df["Time"] = (
pd.Timestamp(WESIM_START_DATE) + pd.to_timedelta(df["Hour"], unit="h")
).astype(str)
else:
WESIM = {"df": pd.DataFrame({"Col": [0]})}

data_interval = dcc.Interval(id="data_interval")

Expand Down
15 changes: 13 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ def get_ip_address() -> str:
return ip


def generate_docker_compose(template_file: str, ip: str, develop: bool = False) -> None:
def generate_docker_compose(
template_file: str,
ip: str,
develop: bool = False,
live_model: bool = False,
) -> None:
"""Generate the docker-compose.yml file.
Uses a template file and the IP address of the machine.
Args:
template_file: Path to the template file.
ip: IP address of the machine.
develop: Flag for when running in develop mode.
develop: Flag for when running in develop mode (localhost for datahub).
live_model: Flag for when running with a live model. This requires an available
connection to a datahub, either in production or local for develop.
Returns:
None
Expand Down Expand Up @@ -81,10 +88,13 @@ def generate_docker_compose(template_file: str, ip: str, develop: bool = False)
docker_compose["services"]["dash"]["volumes"] += ["./app:/app"]
docker_compose["services"]["dash"]["environment"]["DH_URL"] = "http://127.0.0.1"
docker_compose["services"]["dash"]["environment"]["LOG_LEVEL"] = "DEBUG"
docker_compose["services"]["dash"]["environment"]["DEVELOP"] = "true"
else:
docker_compose["services"]["dash"][
"image"
] = "ghcr.io/imperialcollegelondon/gridlington-vis:latest"

if live_model:
docker_compose["services"]["dash"]["environment"]["LIVE_MODEL"] = "true"

# Configure logging for nginx
Expand All @@ -105,4 +115,5 @@ def generate_docker_compose(template_file: str, ip: str, develop: bool = False)
"docker-compose.setup.ove.yml",
ip,
develop="develop" in sys.argv,
live_model="live_model" in sys.argv,
)
2 changes: 2 additions & 0 deletions run_live.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python3 configure.py live_model
docker-compose up -d

0 comments on commit 98fc644

Please sign in to comment.