Skip to content

Commit

Permalink
add api package
Browse files Browse the repository at this point in the history
  • Loading branch information
nonnontrivial committed May 3, 2024
1 parent 413d9dd commit aecac6a
Show file tree
Hide file tree
Showing 44 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ RUN pip install --no-cache-dir --upgrade -r ./requirements.txt

COPY . .

CMD python -m uvicorn ctts.api:app --host 0.0.0.0 --port 80
CMD python -m uvicorn api.main:app --host 0.0.0.0 --port 8000
8 changes: 3 additions & 5 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

## Building and training the sky brightness model

> Note that `globe_at_night.tar.gz` will need to unpacked into `./data/globe_at_night`
- `python -m ctts.model.build` to write the csv that the model trains on
- `python -m ctts.model.train` to train on the data in the csv
- `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

## HTTP APIs

Expand All @@ -15,7 +13,7 @@
```sh
pip install -r requirements.txt
python -m uvicorn ctts.api:app --reload
python -m uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload
```

- artificial sky brightness (light pollution)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions api/model/train.py → api/api/model/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
raise FileNotFoundError()

df = pd.read_csv(path_to_gan_dataframe)
print(f"read csv with {len(df)} rows")

torch.set_printoptions(sci_mode=False)
feature_tensor = torch.tensor(df[features].values.astype(np.float32))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added api/api/tests/__init__.py
Empty file.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from fastapi.testclient import TestClient

from .api import app
from api import app

client = TestClient(app)
API_PREFIX = "/api/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from fastapi.testclient import TestClient

from .api import app
from api import app

client = TestClient(app)
API_PREFIX = "/api/v1"
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
api:
build: ./api
ports:
- "8000:8000"
rabbitmq:
image: "rabbitmq:management"
ports:
- "5672:5672"
- "15672:15672"
environment:
RABBITMQ_DEFAULT_USER: "guest"
RABBITMQ_DEFAULT_PASS: "guest"

0 comments on commit aecac6a

Please sign in to comment.