Skip to content

Commit

Permalink
fix log level in api container
Browse files Browse the repository at this point in the history
  • Loading branch information
nonnontrivial committed Nov 2, 2024
1 parent 3f20754 commit ddf1cc3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ doing inference of this value.

The approach this project takes is to use pytorch to capture the relationships in the [Globe At Night
dataset](https://globeatnight.org/maps-data/) and use that to predict sky brightness for H3
cells at a configured H3 resoultion (default `0`).
cells at a configured [H3 resoultion](https://h3geo.org/docs/core-library/restable/) (default `0`).

## running with docker

Expand Down Expand Up @@ -77,9 +77,8 @@ stars visible)

## changing the resolution

By default, the producer runs over [resolution 0 cells](https://h3geo.org/docs/core-library/restable/),
but this can be adjusted by setting the environment of the `producer` container in
`docker-compose.yaml`:
By default, the producer runs over all resolution 0 cells, but this can be adjusted
by setting the environment of the `producer` container in `docker-compose.yaml`:

```yaml
producer:
Expand Down
11 changes: 0 additions & 11 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,3 @@ with grpc.insecure_channel(f"{host}:{port}") as channel:
print(response)

```

## model

### building and training

The api depends on a model being trained from csv data.

The following commands will generate a new `model.pth` (i.e. the learned parameters):

- `python -m api.model.build` to write the csv that the model trains on
- `python -m api.model.train` to train on the data in the csv
1 change: 0 additions & 1 deletion api/api/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os

log_level = int(os.getenv("LOG_LEVEL", 20))
service_port = int(os.getenv("SERVICE_PORT", 50051))
6 changes: 3 additions & 3 deletions api/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

import grpc

from .config import service_port
from .stubs import brightness_service_pb2_grpc
from .service.brightness_servicer import BrightnessServicer
from .config import log_level, service_port

log_format = "%(asctime)s [%(levelname)s] %(message)s"
logging.basicConfig(level=log_level, format=log_format)
logging.basicConfig(level=logging.INFO, format=log_format)

log = logging.getLogger(__name__)


def serve():
log.info(f"starting up gRPC server on port {service_port}")
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
brightness_service_pb2_grpc.add_BrightnessServiceServicer_to_server(BrightnessServicer(), server)
server.add_insecure_port(f"[::]:{service_port}")
Expand All @@ -22,5 +23,4 @@ def serve():


if __name__ == "__main__":
log.info(f"starting up gRPC server on port {service_port}")
serve()
8 changes: 8 additions & 0 deletions api/model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# model

## building and training

The api depends on a model being trained from csv data.

1. use `python -m api.model.build` to write the csv that the model trains on
2. use `python -m api.model.train` to generate a new `model.pth` (i.e. to learn new parameters)
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ services:
build: ./api
ports:
- "50051:50051"
environment:
API_VERSION: "v1"
LOG_LEVEL: 30
restart: on-failure
depends_on:
openmeteo:
Expand Down

0 comments on commit ddf1cc3

Please sign in to comment.