Skip to content

Commit d002f2c

Browse files
committed
Remove unneeded comments
1 parent cb2cf03 commit d002f2c

4 files changed

Lines changed: 3 additions & 66 deletions

File tree

mflix/server/python-fastapi/src/database/mongo_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
client = AsyncMongoClient(os.getenv("MONGO_URI"))
99
db = client[os.getenv("MONGO_DB")]
1010

11-
# Set the API key but don't instantiate the client here
1211
voyage_api_key = os.getenv("VOYAGE_API_KEY")
1312
if voyage_api_key:
1413
voyageai.api_key = voyage_api_key

mflix/server/python-fastapi/src/models/models.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ class Movie(BaseModel):
3838
"populate_by_name" : True
3939
}
4040

41-
42-
'''
43-
So this an interesting conversion. Pydanic doesn't cleanly support constructing
44-
models that have MongoDB query operators as field names. This becomes an issue when
45-
we want to convert the validated model back to a dictionary to use as a MongoDB query filter.
46-
For example, if a user leaves the 'q' parameter blank, we don't want to include the '$text' operator
47-
in the filter at all but validation will send an empty value for it and that causes errors. So
48-
I am handling the validation in the query router itself, but leaving this here as an example of how
49-
it could be done, if I am wrong about Pydantic's capabilities.
50-
'''
51-
5241
class TextFilter(BaseModel):
5342
search: str = Field(..., alias="$search")
5443

mflix/server/python-fastapi/src/routers/movies.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ async def search_movies(
300300
- plot: Movie plot text
301301
- score: Vector search similarity score (0.0 to 1.0, higher = more similar)
302302
"""
303-
# Specify your Voyage API key and embedding model
303+
# Specify your Voyage AI embedding model
304304
model = "voyage-3-large"
305305
outputDimension = 2048 #Set to 2048 to match the dimensions of the collection's embeddings
306306

@@ -403,10 +403,6 @@ async def vector_search_movies(
403403
details=str(e)
404404
)
405405

406-
#------------------------------------
407-
# Place get_movie_by_id endpoint here
408-
#------------------------------------
409-
410406
"""
411407
GET /api/movies/{id}
412408
Retrieve a single movie by its ID.
@@ -539,10 +535,6 @@ async def get_all_movies(
539535
# Return the results wrapped in a SuccessResponse
540536
return create_success_response(movies, f"Found {len(movies)} movies.")
541537

542-
#------------------------------------
543-
# Place create_movie endpoint here
544-
#------------------------------------
545-
546538
"""
547539
POST /api/movies/
548540
Create a new movie.
@@ -600,10 +592,6 @@ async def create_movie(movie: CreateMovieRequest):
600592

601593
return create_success_response(created_movie, f"Movie '{movie_data['title']}' created successfully")
602594

603-
#------------------------------------
604-
# Place create_movies_batch endpoint here
605-
#------------------------------------
606-
607595
"""
608596
POST /api/movies/batch
609597
@@ -670,10 +658,6 @@ async def create_movies_batch(movies: List[CreateMovieRequest]) ->SuccessRespons
670658
details=str(e)
671659
)
672660

673-
#------------------------------------
674-
# Place update_movie endpoint here
675-
#------------------------------------
676-
677661
"""
678662
PATCH /api/movies/{id}
679663
@@ -744,10 +728,6 @@ async def update_movie(
744728

745729
return create_success_response(updatedMovie, f"Movie updated successfully. Modified {len(update_dict)} fields.")
746730

747-
#------------------------------------
748-
# Place update_movies_by_batch endpoint here
749-
#------------------------------------
750-
751731
"""
752732
PATCH /api/movies
753733
@@ -810,10 +790,6 @@ async def update_movies_batch(
810790
f"Update operation completed. Matched {result.matched_count} movie(s), modified {result.modified_count} movie(s)."
811791
)
812792

813-
#------------------------------------
814-
# Place delete_movie endpoint here
815-
#------------------------------------
816-
817793
"""
818794
DELETE /api/movies/{id}
819795
Delete a single movie by its ID.
@@ -860,9 +836,6 @@ async def delete_movie_by_id(id: str):
860836
"Movie deleted successfully"
861837
)
862838

863-
#------------------------------------
864-
# Place delete_movies_by_batch endpoint here
865-
#------------------------------------
866839
"""
867840
DELETE /api/movies/
868841
@@ -922,10 +895,6 @@ async def delete_movies_batch(request_body: dict = Body(...)) -> SuccessResponse
922895
f'Delete operation completed. Removed {result.deleted_count} movies.'
923896
)
924897

925-
#------------------------------------
926-
# Place find_and_delete_movie endpoint here
927-
#------------------------------------
928-
929898
"""
930899
DELETE /api/movies/{id}/find-and-delete
931900
Finds and deletes a movie in a single atomic operation.

mflix/server/python-fastapi/src/utils/errorHandler.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@
22
from fastapi.responses import JSONResponse
33
from pymongo.errors import PyMongoError, DuplicateKeyError, WriteError
44
from datetime import datetime, timezone
5-
from typing import Any, Dict, Optional
5+
from typing import Any, Optional
66
from src.models.models import ErrorDetails, ErrorResponse, SuccessResponse, T
77

8-
9-
'''
10-
Open to having a conversation about parity in the code. From my understanding exception handeling, validation errors and enforcement(Pydantic),
11-
and error response formatting are all handled natively by FastAPI. So I don't believe I need to create the ValidationError
12-
class, middleware, or exception handlers present in the TS code.
13-
14-
'''
15-
16-
178
'''
189
Creates a standardized success response.
1910
@@ -26,8 +17,6 @@
2617
SuccessResponse[T]: A standardized success response object.
2718
'''
2819

29-
30-
# TODO: Verify the timestamp format is acceptable.
3120
def create_success_response(data:T, message: Optional[str] = None) -> SuccessResponse[T]:
3221
return SuccessResponse(
3322
message=message or "Operation completed successfully.",
@@ -36,7 +25,6 @@ def create_success_response(data:T, message: Optional[str] = None) -> SuccessRes
3625

3726
)
3827

39-
4028
'''
4129
Creates a standardized error response.
4230
@@ -50,7 +38,6 @@ def create_success_response(data:T, message: Optional[str] = None) -> SuccessRes
5038
5139
'''
5240

53-
# TODO: Verify the timestamp format is acceptable.
5441
def create_error_response(message: str, code: Optional[str]=None, details: Optional[Any]=None) -> ErrorResponse:
5542
return ErrorResponse(
5643
message=message,
@@ -63,13 +50,6 @@ def create_error_response(message: str, code: Optional[str]=None, details: Optio
6350
)
6451

6552

66-
67-
'''
68-
This is interesting, I am not sure if this is worth explaining that compared to Node, you are
69-
not going to get exceptions thrown from MongoDB operations in the same way. You are not getting
70-
error codes back from operations, you are getting exceptions.
71-
'''
72-
7353
def parse_mongo_exception(exc: Exception) -> dict:
7454
if isinstance(exc, DuplicateKeyError):
7555
return{
@@ -126,4 +106,4 @@ async def generic_exception_handler(request: Request, exc: Exception):
126106
code="INTERNAL_SERVER_ERROR",
127107
details=getattr(exc, 'detail', None) or getattr(exc, 'args', None)
128108
).model_dump()
129-
)
109+
)

0 commit comments

Comments
 (0)