Skip to content

Commit

Permalink
Address comments from review by @DanielMarchand
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Jan 15, 2024
1 parent 82440ae commit 0f88732
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,28 @@ RUN python -m pip install -U pip && \
mkdir -p logs && \
touch -a logs/dlite_entities_service.log

## DEVELOPMENT target

FROM base as development

ENV PORT=80
EXPOSE ${PORT}

# Set debug mode, since we're running in development mode
ENV ENTITY_SERVICE_DEBUG=1

ENTRYPOINT uvicorn --host 0.0.0.0 --port ${PORT} --log-level debug --no-server-header --header "Server:DLiteEntitiesService" --reload dlite_entities_service.main:APP

## PRODUCTION target

FROM base as production

RUN pip install -U --upgrade-strategy=eager -e .[production]

ENV PORT=80
EXPOSE ${PORT}

# Force debug mode to be off, since we're running in production mode
ENV ENTITY_SERVICE_DEBUG=0

ENTRYPOINT gunicorn --bind "0.0.0.0:${PORT}" --workers 1 --worker-class dlite_entities_service.uvicorn.UvicornWorker dlite_entities_service.main:APP
17 changes: 3 additions & 14 deletions dlite_entities_service/cli/_utils/global_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,10 @@ def global_options(
CONTEXT["dotenv_path"] = dotenv_path

if token:
access_token = Token(access_token=token)

# I cannot come up with a scenario where this would not validate.
# I cannot come up with a scenario where the following line would not validate.
# The only scenario in which it would happen is if `token` is not a string.
# But it can never not be a string due to the way the input is parsed.
# Even the `if token:` sentence ensures that it will never be an empty string at
# that...
# However, should a case ever come up, the following lines should be the
# 'except' part of a 'try/except'-block for generating the `Token()`:

# except ValidationError as exc:
# raise typer.BadParameter(
# f"Invalid token: {token}",
# param=token,
# param_hint="Token should be given as a string.",
# ) from exc
# Even the `if token:` line above ensures that it will never be an empty string.
access_token = Token(access_token=token)

CONTEXT["token"] = access_token

0 comments on commit 0f88732

Please sign in to comment.