Skip to content

Commit

Permalink
Some fixes and improvements, made composer watch work
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Kamps committed Oct 30, 2024
1 parent 778022c commit 06bd29e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app

# we use 'dev' here so we can sync code changes into the container and
# have the application pick these up without restarting for easy development
CMD ["fastapi", "dev", "app/main.py", "--host", "0.0.0.0"]
CMD ["fastapi", "run", "app/main.py", "--host", "0.0.0.0"]
2 changes: 1 addition & 1 deletion app/dependencies/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlmodel import SQLModel, create_engine
from sqlmodel import SQLModel, create_engine, Session
from os import getenv
from app.models import *

Expand Down
12 changes: 2 additions & 10 deletions app/routers/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,12 @@ def patch_observation(id: int, observation: ObservationUpdate):
with Session(engine) as session:
db_observation = __require_observation(id, session)
db_observation.sqlmodel_update(observation.model_dump(exclude_unset=True))
add_to_session(db_observation)
return db_observation

@router.put("/{id}")
def put_observation(id: int, observation: Observation):
with Session(engine) as session:
db_observation = __require_observation(id, session)
db_observation.sqlmodel_update(observation.model_dump())
add_to_session(db_observation)
add_to_session(db_observation, session)
return db_observation

@router.post("/", status_code=201)
def post_observation(observation: ObservationCreate) -> Observation:
with Session(engine) as session:
db_observation = Observation.model_validate(observation)
add_to_session(db_observation)
add_to_session(db_observation, session)
return db_observation
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
BOSWACHTER_DB_URL: "postgresql://boswachter:highsecurity@database:5432/boswachter"
develop:
watch:
- action: sync
- action: sync+restart
path: ./app
target: /code/app

Expand Down

0 comments on commit 06bd29e

Please sign in to comment.