Skip to content

Commit 0022655

Browse files
committed
make upstreams optional for during reverse proxy startup
1 parent c9544fc commit 0022655

File tree

14 files changed

+114
-38
lines changed

14 files changed

+114
-38
lines changed

app/api/routers/training_operations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
tags=[Tags.Training.name],
3131
dependencies=[Depends(cms_globals.props.current_active_user)],
3232
description="Get the training or evaluation job information by its ID")
33-
def train_eval_info(request: Request,
34-
train_eval_id: Annotated[str, Query(description="The training or evaluation ID")],
35-
model_service: AbstractModelService = Depends(cms_globals.model_service_dep)) -> JSONResponse:
33+
async def train_eval_info(request: Request,
34+
train_eval_id: Annotated[str, Query(description="The training or evaluation ID")],
35+
model_service: AbstractModelService = Depends(cms_globals.model_service_dep)) -> JSONResponse:
3636
tracker_client = model_service.get_tracker_client()
3737
if tracker_client is None:
3838
return JSONResponse(status_code=HTTP_503_SERVICE_UNAVAILABLE,

app/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ $ cms build [OPTIONS]
132132

133133
* `--dockerfile-path TEXT`: The path to the Dockerfile [required]
134134
* `--context-dir TEXT`: The directory containing the set of files accessible to the build [required]
135-
* `--model-name TEXT`: The string representation of the model name [default: cms_model]
135+
* `--model-name TEXT`: The string representation of the model name [default: CMS model]
136136
* `--user-id INTEGER`: The ID for the non-root user [default: 1000]
137137
* `--group-id INTEGER`: The group ID for the non-root user [default: 1000]
138138
* `--http-proxy TEXT`: The string representation of the HTTP proxy
139139
* `--https-proxy TEXT`: The string representation of the HTTPS proxy
140140
* `--no-proxy TEXT`: The string representation of addresses by-passing proxies [default: localhost,127.0.0.1]
141-
* `--tag TEXT`: The tag of the built image
141+
* `--version-tag TEXT`: The version tag of the built image [default: latest]
142142
* `--backend [docker build|docker buildx build]`: The backend used for building the image [default: docker build]
143143
* `--help`: Show this message and exit.
144144

app/cli/cli.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,20 @@ def package_dataset(hf_dataset_id: str = typer.Option("", help="The repository I
388388
@cmd_app.command("build", help="This builds an OCI-compliant image to containerise CMS")
389389
def build_image(dockerfile_path: str = typer.Option(..., help="The path to the Dockerfile"),
390390
context_dir: str = typer.Option(..., help="The directory containing the set of files accessible to the build"),
391-
model_name: Optional[str] = typer.Option("cms_model", help="The string representation of the model name"),
392-
user_id: Optional[int] = typer.Option(1000, help="The ID for the non-root user"),
393-
group_id: Optional[int] = typer.Option(1000, help="The group ID for the non-root user"),
394-
http_proxy: Optional[str] = typer.Option("", help="The string representation of the HTTP proxy"),
395-
https_proxy: Optional[str] = typer.Option("", help="The string representation of the HTTPS proxy"),
396-
no_proxy: Optional[str] = typer.Option("localhost,127.0.0.1", help="The string representation of addresses by-passing proxies"),
397-
tag: str = typer.Option(None, help="The tag of the built image"),
398-
backend: Optional[BuildBackend] = typer.Option(BuildBackend.DOCKER, help="The backend used for building the image")) -> None:
391+
model_name: str = typer.Option("CMS model", help="The string representation of the model name"),
392+
user_id: int = typer.Option(1000, help="The ID for the non-root user"),
393+
group_id: int = typer.Option(1000, help="The group ID for the non-root user"),
394+
http_proxy: str = typer.Option("", help="The string representation of the HTTP proxy"),
395+
https_proxy: str = typer.Option("", help="The string representation of the HTTPS proxy"),
396+
no_proxy: str = typer.Option("localhost,127.0.0.1", help="The string representation of addresses by-passing proxies"),
397+
version_tag: str = typer.Option("latest", help="The version tag of the built image"),
398+
backend: BuildBackend = typer.Option(BuildBackend.DOCKER.value, help="The backend used for building the image")) -> None:
399399
assert backend is not None
400400
cmd = [
401401
*backend.value.split(),
402402
'-f', dockerfile_path,
403403
'--progress=plain',
404-
'-t', f'{model_name}:{tag}',
404+
'-t', f'{model_name.replace(" ", "-").lower()}:{version_tag}',
405405
'--build-arg', f'CMS_MODEL_NAME={model_name}',
406406
'--build-arg', f'CMS_UID={str(user_id)}',
407407
'--build-arg', f'CMS_GID={str(group_id)}',

docker/nginx/etc/nginx/sites-enabled/de-identification

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_de-identification.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://de-identification:8000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "de-identification:8000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/grafana

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_grafana.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://grafana:3000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "grafana:3000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/graylog

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_graylog.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://graylog:9000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "graylog:9000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/huggingface-ner

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_huggingface-ner.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://huggingface-ner:8000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "huggingface-ner:8000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/medcat-deid

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_medcat-deid.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://medcat-deid:8000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "medcat-deid:8000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/medcat-icd10

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ server {
2323
error_log /var/log/nginx/error_medcat-icd10.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://medcat-icd10:8000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "medcat-icd10:8000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
32+
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
2936
}
3037
}

docker/nginx/etc/nginx/sites-enabled/medcat-snomed

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ server {
2323
error_log /var/log/nginx/error_medcat-snomed.log;
2424

2525
location / {
26-
include cors.conf;
27-
proxy_pass http://medcat-snomed:8000/;
26+
include cors.conf;
27+
resolver 127.0.0.11 valid=30s;
28+
set $backend "medcat-snomed:8000";
29+
proxy_pass http://$backend;
2830
proxy_set_header Host $host;
31+
error_page 502 503 504 = @fallback;
2932
}
33+
34+
location @fallback {
35+
return 503 "Service is temporarily unavailable. Please try again later.";
36+
}
37+
3038
}

0 commit comments

Comments
 (0)