Skip to content

Commit

Permalink
chore: sensible logging config (Unstructured-IO#64)
Browse files Browse the repository at this point in the history
* chore: add sensible logging config

* version bump

* add to Dockerfile

* add to non-docker Makefile target

* make generate-api
  • Loading branch information
cragwolfe authored Mar 29, 2023
1 parent 6be1bf4 commit ab008bf
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.8

* Sensible logging config

## 0.0.7

* Minor version bump
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ USER root
RUN ln -s /home/notebook-user/.local/bin/pip /usr/local/bin/pip
USER ${NB_USER}

COPY --chown=${NB_USER}:${NB_USER} logger_config.yaml logger_config.yaml
COPY --chown=${NB_USER}:${NB_USER} prepline_${PIPELINE_PACKAGE}/ prepline_${PIPELINE_PACKAGE}/
COPY --chown=${NB_USER}:${NB_USER} exploration-notebooks exploration-notebooks
COPY --chown=${NB_USER}:${NB_USER} pipeline-notebooks pipeline-notebooks

EXPOSE 5000

ENTRYPOINT ["uvicorn", "prepline_general.api.app:app", \
"--log-config", "logger_config.yaml", \
"--host", "0.0.0.0"]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ docker-build:

.PHONY: docker-start-api
docker-start-api:
docker run -p 8000:8000 --mount type=bind,source=$(realpath .),target=/home/notebook-user/local -t --rm pipeline-family-${PIPELINE_FAMILY}-dev:latest
docker run -p 8000:8000 --mount type=bind,source=$(realpath .),target=/home/notebook-user/local -t --rm pipeline-family-${PIPELINE_FAMILY}-dev:latest --log-config logger_config.yaml --host 0.0.0.0 --port 8000

# Note(austin) we need to install the dev dependencies for this to work
# Do we want to build separate dev images?
Expand All @@ -100,7 +100,7 @@ run-jupyter:
## run-web-app: runs the FastAPI api with hot reloading
.PHONY: run-web-app
run-web-app:
PYTHONPATH=$(realpath .) uvicorn ${PACKAGE_NAME}.api.app:app --reload
PYTHONPATH=$(realpath .) uvicorn ${PACKAGE_NAME}.api.app:app --reload --log-config logger_config.yaml

#################
# Test and Lint #
Expand Down
42 changes: 42 additions & 0 deletions logger_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 1
disable_existing_loggers: False
formatters:
default_format:
"()": uvicorn.logging.DefaultFormatter
format: '%(asctime)s %(name)s %(levelname)s %(message)s'
access:
"()": uvicorn.logging.AccessFormatter
format: '%(asctime)s %(client_addr)s %(request_line)s - %(status_code)s'
handlers:
access_handler:
formatter: access
class: logging.StreamHandler
stream: ext://sys.stderr
standard_handler:
formatter: default_format
class: logging.StreamHandler
stream: ext://sys.stderr
loggers:
uvicorn.error:
level: INFO
handlers:
- standard_handler
propagate: no
# disable logging for uvicorn.error by not having a handler
uvicorn.access:
level: INFO
handlers:
- access_handler
propagate: no
# disable logging for uvicorn.access by not having a handler
unstructured:
level: INFO
handlers:
- standard_handler
propagate: no
unstructured_inference:
level: DEBUG
handlers:
- standard_handler
propagate: no

2 changes: 1 addition & 1 deletion prepline_general/api/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async def stream_response(self, send: Send) -> None:


@router.post("/general/v0/general")
@router.post("/general/v0.0.7/general")
@router.post("/general/v0.0.8/general")
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
Expand Down
2 changes: 1 addition & 1 deletion preprocessing-pipeline-family.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name: general
version: 0.0.7
version: 0.0.8

0 comments on commit ab008bf

Please sign in to comment.