Skip to content

Commit 81ae563

Browse files
change lib to src
1 parent 752bf66 commit 81ae563

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+177
-177
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ RUN apt-get update && \
1414
apt-get purge -y --auto-remove && \
1515
rm -rf /var/lib/apt/lists/*
1616

17-
COPY ./lib /app/lib
17+
COPY ./src /app/src
1818

19-
CMD ["gunicorn", "-c", "lib/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "uvicorn.workers.UvicornWorker", "lib.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "60"]
19+
CMD ["gunicorn", "-c", "src/settings/gunicorn.py", "-w", "1", "--threads=2", "-k", "uvicorn.workers.UvicornWorker", "src.api:app", "--log-level", "Debug", "-b", "0.0.0.0:3000", "--timeout", "60"]

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@ format: black ruff
22
lint: flake8 pylint
33

44
black:
5-
black ./lib || true
5+
black ./src || true
66
black ./tests || true
77

88
flake8:
9-
flake8 --ignore E501,E402,F401,W503,C0414 ./lib || true
9+
flake8 --ignore E501,E402,F401,W503,C0414 ./src || true
1010
flake8 --ignore E501,E402,F401,W503,C0414 ./tests || true
1111

1212
pylint:
13-
pylint ./lib || true
13+
pylint ./src || true
1414
pylint ./tests || true
1515

1616
ruff:
17-
ruff check --fix ./lib || true
17+
ruff check --fix ./src || true
1818
ruff check --fix ./tests || true
1919

2020
test:
2121
python3 -m pytest .
2222

2323
dev:
24-
python3 -m uvicorn lib:app --reload --port 3000
24+
python3 -m uvicorn src.app --reload --port 3000
2525

2626
clean:
2727
docker stop infinity-api

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ $ touch .env && echo MONGODB_CONNECTION_STRING="$ConnectionString" > .env
2525
- run docker compose: `docker-compose up --build -d`
2626

2727
### Standalone
28-
- Dev: `python3 -m uvicorn lib:app --reload --port 3000`
29-
- Prod: `gunicorn -k uvicorn.workers.UvicornWorker lib:app -b 0.0.0.0:3000`
28+
- Dev: `python3 -m uvicorn src:app --reload --port 3000`
29+
- Prod: `gunicorn -k uvicorn.workers.UvicornWorker src:app -b 0.0.0.0:3000`
3030

3131
## Project structure
3232
```

lib/controllers/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/repositories/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/__init__.py renamed to src/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lib/__init__.py
1+
# src.__init__.py
22
import logging
33
import sys
44

@@ -25,6 +25,6 @@ def parse_error(error):
2525
return f"{exc_type}: {exc_obj}"
2626

2727

28-
from lib.api import ( # pylint: disable=wrong-import-position,cyclic-import,useless-import-alias
28+
from src.api import ( # pylint: disable=wrong-import-position,cyclic-import,useless-import-alias
2929
app as app,
3030
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# __main__.py
2-
from lib.api import app
2+
from src.api import app
33

44
if __name__ == '__main__':
55
app.run() # pylint: disable=no-member

lib/api.py renamed to src/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
77
from opentelemetry.instrumentation.requests import RequestsInstrumentor
88

9-
from lib import logger, parse_error
10-
from lib.routes import flight, environment, motor, rocket
11-
from lib.utils import RocketPyGZipMiddleware
9+
from src import logger, parse_error
10+
from src.routes import flight, environment, motor, rocket
11+
from src.utils import RocketPyGZipMiddleware
1212

1313
app = FastAPI(
1414
swagger_ui_parameters={

src/controllers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# src.controllers/__init__.py

lib/controllers/environment.py renamed to src/controllers/environment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lib.controllers.interface import (
1+
from src.controllers.interface import (
22
ControllerInterface,
33
controller_exception_handler,
44
)
5-
from lib.views.environment import EnvironmentSimulation
6-
from lib.models.environment import EnvironmentModel
7-
from lib.services.environment import EnvironmentService
5+
from src.views.environment import EnvironmentSimulation
6+
from src.models.environment import EnvironmentModel
7+
from src.services.environment import EnvironmentService
88

99

1010
class EnvironmentController(ControllerInterface):

lib/controllers/flight.py renamed to src/controllers/flight.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from lib.controllers.interface import (
1+
from src.controllers.interface import (
22
ControllerInterface,
33
controller_exception_handler,
44
)
5-
from lib.views.flight import FlightSimulation
6-
from lib.models.flight import FlightModel
7-
from lib.models.environment import EnvironmentModel
8-
from lib.models.rocket import RocketModel
9-
from lib.services.flight import FlightService
5+
from src.views.flight import FlightSimulation
6+
from src.models.flight import FlightModel
7+
from src.models.environment import EnvironmentModel
8+
from src.models.rocket import RocketModel
9+
from src.services.flight import FlightService
1010

1111

1212
class FlightController(ControllerInterface):

lib/controllers/interface.py renamed to src/controllers/interface.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from pymongo.errors import PyMongoError
44
from fastapi import HTTPException, status
55

6-
from lib import logger
7-
from lib.models.interface import ApiBaseModel
8-
from lib.views.interface import ApiBaseView
9-
from lib.repositories.interface import RepositoryInterface
6+
from src import logger
7+
from src.models.interface import ApiBaseModel
8+
from src.views.interface import ApiBaseView
9+
from src.repositories.interface import RepositoryInterface
1010

1111

1212
def controller_exception_handler(method):

lib/controllers/motor.py renamed to src/controllers/motor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lib.controllers.interface import (
1+
from src.controllers.interface import (
22
ControllerInterface,
33
controller_exception_handler,
44
)
5-
from lib.views.motor import MotorSimulation
6-
from lib.models.motor import MotorModel
7-
from lib.services.motor import MotorService
5+
from src.views.motor import MotorSimulation
6+
from src.models.motor import MotorModel
7+
from src.services.motor import MotorService
88

99

1010
class MotorController(ControllerInterface):

lib/controllers/rocket.py renamed to src/controllers/rocket.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from lib.controllers.interface import (
1+
from src.controllers.interface import (
22
ControllerInterface,
33
controller_exception_handler,
44
)
5-
from lib.views.rocket import RocketSimulation
6-
from lib.models.rocket import RocketModel
7-
from lib.services.rocket import RocketService
5+
from src.views.rocket import RocketSimulation
6+
from src.models.rocket import RocketModel
7+
from src.services.rocket import RocketService
88

99

1010
class RocketController(ControllerInterface):

lib/models/environment.py renamed to src/models/environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22
from typing import Optional, ClassVar, Self, Literal
3-
from lib.models.interface import ApiBaseModel
3+
from src.models.interface import ApiBaseModel
44

55

66
class EnvironmentModel(ApiBaseModel):
@@ -34,13 +34,13 @@ def DELETED():
3434

3535
@staticmethod
3636
def CREATED(model_id: str):
37-
from lib.views.environment import EnvironmentCreated
37+
from src.views.environment import EnvironmentCreated
3838

3939
return EnvironmentCreated(environment_id=model_id)
4040

4141
@staticmethod
4242
def RETRIEVED(model_instance: type(Self)):
43-
from lib.views.environment import EnvironmentRetrieved, EnvironmentView
43+
from src.views.environment import EnvironmentRetrieved, EnvironmentView
4444

4545
return EnvironmentRetrieved(
4646
environment=EnvironmentView(

lib/models/flight.py renamed to src/models/flight.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional, Self, ClassVar, Literal
2-
from lib.models.interface import ApiBaseModel
3-
from lib.models.rocket import RocketModel
4-
from lib.models.environment import EnvironmentModel
2+
from src.models.interface import ApiBaseModel
3+
from src.models.rocket import RocketModel
4+
from src.models.environment import EnvironmentModel
55

66

77
class FlightModel(ApiBaseModel):
@@ -54,13 +54,13 @@ def DELETED():
5454

5555
@staticmethod
5656
def CREATED(model_id: str):
57-
from lib.views.flight import FlightCreated
57+
from src.views.flight import FlightCreated
5858

5959
return FlightCreated(flight_id=model_id)
6060

6161
@staticmethod
6262
def RETRIEVED(model_instance: type(Self)):
63-
from lib.views.flight import FlightRetrieved, FlightView
63+
from src.views.flight import FlightRetrieved, FlightView
6464

6565
return FlightRetrieved(
6666
flight=FlightView(
File renamed without changes.

lib/models/motor.py renamed to src/models/motor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from typing import Optional, Tuple, List, Union, Self, ClassVar, Literal
33
from pydantic import PrivateAttr, model_validator, computed_field
44

5-
from lib.models.interface import ApiBaseModel
6-
from lib.models.sub.tanks import MotorTank
5+
from src.models.interface import ApiBaseModel
6+
from src.models.sub.tanks import MotorTank
77

88

99
class MotorKinds(str, Enum):
@@ -90,13 +90,13 @@ def DELETED():
9090

9191
@staticmethod
9292
def CREATED(model_id: str):
93-
from lib.views.motor import MotorCreated
93+
from src.views.motor import MotorCreated
9494

9595
return MotorCreated(motor_id=model_id)
9696

9797
@staticmethod
9898
def RETRIEVED(model_instance: type(Self)):
99-
from lib.views.motor import MotorRetrieved, MotorView
99+
from src.views.motor import MotorRetrieved, MotorView
100100

101101
return MotorRetrieved(
102102
motor=MotorView(

lib/models/rocket.py renamed to src/models/rocket.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Optional, Tuple, List, Union, Self, ClassVar, Literal
2-
from lib.models.interface import ApiBaseModel
3-
from lib.models.motor import MotorModel
4-
from lib.models.sub.aerosurfaces import (
2+
from src.models.interface import ApiBaseModel
3+
from src.models.motor import MotorModel
4+
from src.models.sub.aerosurfaces import (
55
Fins,
66
NoseCone,
77
Tail,
@@ -47,13 +47,13 @@ def DELETED():
4747

4848
@staticmethod
4949
def CREATED(model_id: str):
50-
from lib.views.rocket import RocketCreated
50+
from src.views.rocket import RocketCreated
5151

5252
return RocketCreated(rocket_id=model_id)
5353

5454
@staticmethod
5555
def RETRIEVED(model_instance: type(Self)):
56-
from lib.views.rocket import RocketRetrieved, RocketView
56+
from src.views.rocket import RocketRetrieved, RocketView
5757

5858
return RocketRetrieved(
5959
rocket=RocketView(
File renamed without changes.
File renamed without changes.

src/repositories/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# src/controllers/__init__.py

lib/repositories/environment.py renamed to src/repositories/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
2-
from lib.models.environment import EnvironmentModel
3-
from lib.repositories.interface import (
2+
from src.models.environment import EnvironmentModel
3+
from src.repositories.interface import (
44
RepositoryInterface,
55
repository_exception_handler,
66
)

lib/repositories/flight.py renamed to src/repositories/flight.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
2-
from lib.models.flight import FlightModel
3-
from lib.repositories.interface import (
2+
from src.models.flight import FlightModel
3+
from src.repositories.interface import (
44
RepositoryInterface,
55
repository_exception_handler,
66
)

lib/repositories/interface.py renamed to src/repositories/interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
from fastapi import HTTPException, status
1717
from bson import ObjectId
1818

19-
from lib import logger
20-
from lib.secrets import Secrets
21-
from lib.models.interface import ApiBaseModel
19+
from src import logger
20+
from src.secrets import Secrets
21+
from src.models.interface import ApiBaseModel
2222

2323

2424
def not_implemented(*args, **kwargs):

lib/repositories/motor.py renamed to src/repositories/motor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
2-
from lib.models.motor import MotorModel
3-
from lib.repositories.interface import (
2+
from src.models.motor import MotorModel
3+
from src.repositories.interface import (
44
RepositoryInterface,
55
repository_exception_handler,
66
)

lib/repositories/rocket.py renamed to src/repositories/rocket.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional
2-
from lib.models.rocket import RocketModel
3-
from lib.repositories.interface import (
2+
from src.models.rocket import RocketModel
3+
from src.repositories.interface import (
44
RepositoryInterface,
55
repository_exception_handler,
66
)

lib/routes/environment.py renamed to src/routes/environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from fastapi import APIRouter, Response
66
from opentelemetry import trace
77

8-
from lib.views.environment import (
8+
from src.views.environment import (
99
EnvironmentSimulation,
1010
EnvironmentCreated,
1111
EnvironmentRetrieved,
1212
)
13-
from lib.models.environment import EnvironmentModel
14-
from lib.controllers.environment import EnvironmentController
13+
from src.models.environment import EnvironmentModel
14+
from src.controllers.environment import EnvironmentController
1515

1616
router = APIRouter(
1717
prefix="/environments",

lib/routes/flight.py renamed to src/routes/flight.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
from fastapi import APIRouter, Response
66
from opentelemetry import trace
77

8-
from lib.views.flight import (
8+
from src.views.flight import (
99
FlightSimulation,
1010
FlightCreated,
1111
FlightRetrieved,
1212
)
13-
from lib.models.environment import EnvironmentModel
14-
from lib.models.flight import FlightModel
15-
from lib.models.rocket import RocketModel
16-
from lib.models.motor import MotorKinds
17-
from lib.controllers.flight import FlightController
13+
from src.models.environment import EnvironmentModel
14+
from src.models.flight import FlightModel
15+
from src.models.rocket import RocketModel
16+
from src.models.motor import MotorKinds
17+
from src.controllers.flight import FlightController
1818

1919
router = APIRouter(
2020
prefix="/flights",

lib/routes/motor.py renamed to src/routes/motor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from fastapi import APIRouter, Response
66
from opentelemetry import trace
77

8-
from lib.views.motor import (
8+
from src.views.motor import (
99
MotorSimulation,
1010
MotorCreated,
1111
MotorRetrieved,
1212
)
13-
from lib.models.motor import MotorModel, MotorKinds
14-
from lib.controllers.motor import MotorController
13+
from src.models.motor import MotorModel, MotorKinds
14+
from src.controllers.motor import MotorController
1515

1616
router = APIRouter(
1717
prefix="/motors",

0 commit comments

Comments
 (0)