59
59
stepfunctions = boto3 .client ("stepfunctions" , region_name = os .environ ["AWS_REGION" ], config = retry_config )
60
60
61
61
62
- @app .exception_handler (ModelNotFoundError ) # type: ignore
62
+ @app .exception_handler (ModelNotFoundError )
63
63
async def model_not_found_handler (request : Request , exc : ModelNotFoundError ) -> JSONResponse :
64
64
"""Handle exception when model cannot be found and translate to a 404 error."""
65
65
return JSONResponse (status_code = 404 , content = {"message" : str (exc )})
66
66
67
67
68
- @app .exception_handler (RequestValidationError ) # type: ignore
69
- async def validation_exception_handler (request : Request , exc : RequestValidationError ):
68
+ @app .exception_handler (RequestValidationError )
69
+ async def validation_exception_handler (request : Request , exc : RequestValidationError ) -> JSONResponse :
70
70
"""Handle exception when request fails validation and and translate to a 422 error."""
71
71
return JSONResponse (
72
72
status_code = 422 , content = {"detail" : jsonable_encoder (exc .errors ()), "type" : "RequestValidationError" }
73
73
)
74
74
75
75
76
- @app .exception_handler (InvalidStateTransitionError ) # type: ignore
77
- @app .exception_handler (ModelAlreadyExistsError ) # type: ignore
78
- @app .exception_handler (ValueError ) # type: ignore
76
+ @app .exception_handler (InvalidStateTransitionError )
77
+ @app .exception_handler (ModelAlreadyExistsError )
78
+ @app .exception_handler (ValueError )
79
79
async def user_error_handler (
80
80
request : Request , exc : Union [InvalidStateTransitionError , ModelAlreadyExistsError , ValueError ]
81
81
) -> JSONResponse :
82
82
"""Handle errors when customer requests options that cannot be processed."""
83
83
return JSONResponse (status_code = 400 , content = {"message" : str (exc )})
84
84
85
85
86
- @app .post (path = "" , include_in_schema = False ) # type: ignore
87
- @app .post (path = "/" ) # type: ignore
86
+ @app .post (path = "" , include_in_schema = False )
87
+ @app .post (path = "/" )
88
88
async def create_model (create_request : CreateModelRequest ) -> CreateModelResponse :
89
89
"""Endpoint to create a model."""
90
90
create_handler = CreateModelHandler (
@@ -95,8 +95,8 @@ async def create_model(create_request: CreateModelRequest) -> CreateModelRespons
95
95
return create_handler (create_request = create_request )
96
96
97
97
98
- @app .get (path = "" , include_in_schema = False ) # type: ignore
99
- @app .get (path = "/" ) # type: ignore
98
+ @app .get (path = "" , include_in_schema = False )
99
+ @app .get (path = "/" )
100
100
async def list_models () -> ListModelsResponse :
101
101
"""Endpoint to list models."""
102
102
list_handler = ListModelsHandler (
@@ -107,7 +107,7 @@ async def list_models() -> ListModelsResponse:
107
107
return list_handler ()
108
108
109
109
110
- @app .get (path = "/{model_id}" ) # type: ignore
110
+ @app .get (path = "/{model_id}" )
111
111
async def get_model (
112
112
model_id : Annotated [str , Path (title = "The unique model ID of the model to get" )], request : Request
113
113
) -> GetModelResponse :
@@ -120,7 +120,7 @@ async def get_model(
120
120
return get_handler (model_id = model_id )
121
121
122
122
123
- @app .put (path = "/{model_id}" ) # type: ignore
123
+ @app .put (path = "/{model_id}" )
124
124
async def update_model (
125
125
model_id : Annotated [str , Path (title = "The unique model ID of the model to update" )],
126
126
update_request : UpdateModelRequest ,
@@ -134,7 +134,7 @@ async def update_model(
134
134
return update_handler (model_id = model_id , update_request = update_request )
135
135
136
136
137
- @app .delete (path = "/{model_id}" ) # type: ignore
137
+ @app .delete (path = "/{model_id}" )
138
138
async def delete_model (
139
139
model_id : Annotated [str , Path (title = "The unique model ID of the model to delete" )], request : Request
140
140
) -> DeleteModelResponse :
@@ -147,7 +147,7 @@ async def delete_model(
147
147
return delete_handler (model_id = model_id )
148
148
149
149
150
- @app .get (path = "/metadata/instances" ) # type: ignore
150
+ @app .get (path = "/metadata/instances" )
151
151
async def get_instances () -> list [str ]:
152
152
"""Endpoint to list available instances in this region."""
153
153
return list (sess .get_service_model ("ec2" ).shape_for ("InstanceType" ).enum )
0 commit comments