Skip to content

Commit 297d87f

Browse files
committed
And blacken
1 parent 80cbe12 commit 297d87f

Some content is hidden

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

51 files changed

+2726
-1224
lines changed

flowkit_ui_backend/apis/accounts_api.py

+179-70
Large diffs are not rendered by default.

flowkit_ui_backend/apis/data_api.py

+660-251
Large diffs are not rendered by default.

flowkit_ui_backend/apis/general_api.py

+117-44
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,29 @@
3939
@router.get(
4040
"/setup",
4141
responses={
42-
200: {"model": Config, "description": "OK: The results for this request were retrieved successfully."},
43-
429: {"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."},
44-
500: {"description": "Internal Server Error: Something went wrong on the server while retrieving the data."},
45-
503: {"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."},
42+
200: {
43+
"model": Config,
44+
"description": "OK: The results for this request were retrieved successfully.",
45+
},
46+
429: {
47+
"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."
48+
},
49+
500: {
50+
"description": "Internal Server Error: Something went wrong on the server while retrieving the data."
51+
},
52+
503: {
53+
"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."
54+
},
4655
},
4756
tags=["general"],
48-
response_class=ORJSONResponse
57+
response_class=ORJSONResponse,
4958
)
50-
async def get_setup(
51-
request: Request = None
52-
) -> Config:
59+
async def get_setup(request: Request = None) -> Config:
5360
"""Get the current config for this flowkit-ui-backend server."""
5461

55-
if not hasattr(general_api_impl, 'get_setup') or not callable(getattr(general_api_impl, 'get_setup')):
62+
if not hasattr(general_api_impl, "get_setup") or not callable(
63+
getattr(general_api_impl, "get_setup")
64+
):
5665
raise NotImplementedError("The /get_setup endpoint is not yet implemented")
5766

5867
try:
@@ -65,38 +74,61 @@ async def get_setup(
6574
# default to status 200/204 but give the impl the option to define a different status code when returning content
6675
status_code = impl_result[1] if isinstance(impl_result, tuple) else None
6776
if content is not None:
68-
return ORJSONResponse(status_code=status_code if status_code is not None else HTTPStatus.OK, content=jsonable_encoder(content))
77+
return ORJSONResponse(
78+
status_code=status_code if status_code is not None else HTTPStatus.OK,
79+
content=jsonable_encoder(content),
80+
)
6981
else:
70-
return Response(status_code=status_code if status_code is not None else HTTPStatus.NO_CONTENT)
82+
return Response(
83+
status_code=status_code
84+
if status_code is not None
85+
else HTTPStatus.NO_CONTENT
86+
)
7187

7288
# This is where we handle status codes via exceptions as raised by the impl methods
7389
except HTTPException as e:
74-
logger.debug("Request failed", code=e.status_code, content=e.detail, traceback=traceback.print_exception(type(e), e, e.__traceback__))
90+
logger.debug(
91+
"Request failed",
92+
code=e.status_code,
93+
content=e.detail,
94+
traceback=traceback.print_exception(type(e), e, e.__traceback__),
95+
)
7596
return JSONResponse(status_code=e.status_code, content=e.detail)
7697
except Exception as e:
7798
logger.error(e)
7899
traceback.print_exception(type(e), e, e.__traceback__)
79-
return JSONResponse(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, content=f"Something went wrong: {e}")
80-
100+
return JSONResponse(
101+
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
102+
content=f"Something went wrong: {e}",
103+
)
81104

82105

83106
@router.get(
84107
"/heartbeat",
85108
responses={
86-
200: {"model": Heartbeat, "description": "OK: The results for this request were retrieved successfully."},
87-
429: {"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."},
88-
500: {"description": "Internal Server Error: Something went wrong on the server while retrieving the data."},
89-
503: {"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."},
109+
200: {
110+
"model": Heartbeat,
111+
"description": "OK: The results for this request were retrieved successfully.",
112+
},
113+
429: {
114+
"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."
115+
},
116+
500: {
117+
"description": "Internal Server Error: Something went wrong on the server while retrieving the data."
118+
},
119+
503: {
120+
"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."
121+
},
90122
},
91123
tags=["general"],
92-
response_class=ORJSONResponse
124+
response_class=ORJSONResponse,
93125
)
94-
async def heartbeat(
95-
request: Request = None
96-
) -> Heartbeat:
126+
async def heartbeat(request: Request = None) -> Heartbeat:
97127
"""Checks whether the API is up and running"""
98128

99-
if not hasattr(general_api_impl, 'heartbeat') or not callable(getattr(general_api_impl, 'heartbeat')):
129+
if not hasattr(general_api_impl, "heartbeat") or not callable(
130+
getattr(general_api_impl, "heartbeat")
131+
):
100132
raise NotImplementedError("The /heartbeat endpoint is not yet implemented")
101133

102134
try:
@@ -109,60 +141,101 @@ async def heartbeat(
109141
# default to status 200/204 but give the impl the option to define a different status code when returning content
110142
status_code = impl_result[1] if isinstance(impl_result, tuple) else None
111143
if content is not None:
112-
return ORJSONResponse(status_code=status_code if status_code is not None else HTTPStatus.OK, content=jsonable_encoder(content))
144+
return ORJSONResponse(
145+
status_code=status_code if status_code is not None else HTTPStatus.OK,
146+
content=jsonable_encoder(content),
147+
)
113148
else:
114-
return Response(status_code=status_code if status_code is not None else HTTPStatus.NO_CONTENT)
149+
return Response(
150+
status_code=status_code
151+
if status_code is not None
152+
else HTTPStatus.NO_CONTENT
153+
)
115154

116155
# This is where we handle status codes via exceptions as raised by the impl methods
117156
except HTTPException as e:
118-
logger.debug("Request failed", code=e.status_code, content=e.detail, traceback=traceback.print_exception(type(e), e, e.__traceback__))
157+
logger.debug(
158+
"Request failed",
159+
code=e.status_code,
160+
content=e.detail,
161+
traceback=traceback.print_exception(type(e), e, e.__traceback__),
162+
)
119163
return JSONResponse(status_code=e.status_code, content=e.detail)
120164
except Exception as e:
121165
logger.error(e)
122166
traceback.print_exception(type(e), e, e.__traceback__)
123-
return JSONResponse(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, content=f"Something went wrong: {e}")
124-
167+
return JSONResponse(
168+
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
169+
content=f"Something went wrong: {e}",
170+
)
125171

126172

127173
@router.get(
128174
"/data_providers",
129175
responses={
130-
200: {"model": DataProviders, "description": "OK: The results for this request were retrieved successfully."},
131-
429: {"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."},
132-
500: {"description": "Internal Server Error: Something went wrong on the server while retrieving the data."},
133-
503: {"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."},
176+
200: {
177+
"model": DataProviders,
178+
"description": "OK: The results for this request were retrieved successfully.",
179+
},
180+
429: {
181+
"description": "Too Many Requests: The user has exceeded the limit of allowed simultaneous requests."
182+
},
183+
500: {
184+
"description": "Internal Server Error: Something went wrong on the server while retrieving the data."
185+
},
186+
503: {
187+
"description": "Service Unavailable: The server is currently down, e.g. for maintenance. Please try again later."
188+
},
134189
},
135190
tags=["general"],
136-
response_class=ORJSONResponse
191+
response_class=ORJSONResponse,
137192
)
138-
async def list_data_providers(
139-
request: Request = None
140-
) -> DataProviders:
193+
async def list_data_providers(request: Request = None) -> DataProviders:
141194
"""Gets a list of all data providers configured for this flowkit-ui-backend instance"""
142195

143-
if not hasattr(general_api_impl, 'list_data_providers') or not callable(getattr(general_api_impl, 'list_data_providers')):
144-
raise NotImplementedError("The /list_data_providers endpoint is not yet implemented")
196+
if not hasattr(general_api_impl, "list_data_providers") or not callable(
197+
getattr(general_api_impl, "list_data_providers")
198+
):
199+
raise NotImplementedError(
200+
"The /list_data_providers endpoint is not yet implemented"
201+
)
145202

146203
try:
147204
logger.debug("Starting request")
148-
impl_result = await general_api_impl.list_data_providers(pool=request.app.state.pool)
205+
impl_result = await general_api_impl.list_data_providers(
206+
pool=request.app.state.pool
207+
)
149208
logger.debug("Request ready")
150209
content = impl_result[0] if isinstance(impl_result, tuple) else impl_result
151210
if isinstance(impl_result, Response):
152211
return impl_result
153212
# default to status 200/204 but give the impl the option to define a different status code when returning content
154213
status_code = impl_result[1] if isinstance(impl_result, tuple) else None
155214
if content is not None:
156-
return ORJSONResponse(status_code=status_code if status_code is not None else HTTPStatus.OK, content=jsonable_encoder(content))
215+
return ORJSONResponse(
216+
status_code=status_code if status_code is not None else HTTPStatus.OK,
217+
content=jsonable_encoder(content),
218+
)
157219
else:
158-
return Response(status_code=status_code if status_code is not None else HTTPStatus.NO_CONTENT)
220+
return Response(
221+
status_code=status_code
222+
if status_code is not None
223+
else HTTPStatus.NO_CONTENT
224+
)
159225

160226
# This is where we handle status codes via exceptions as raised by the impl methods
161227
except HTTPException as e:
162-
logger.debug("Request failed", code=e.status_code, content=e.detail, traceback=traceback.print_exception(type(e), e, e.__traceback__))
228+
logger.debug(
229+
"Request failed",
230+
code=e.status_code,
231+
content=e.detail,
232+
traceback=traceback.print_exception(type(e), e, e.__traceback__),
233+
)
163234
return JSONResponse(status_code=e.status_code, content=e.detail)
164235
except Exception as e:
165236
logger.error(e)
166237
traceback.print_exception(type(e), e, e.__traceback__)
167-
return JSONResponse(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, content=f"Something went wrong: {e}")
168-
238+
return JSONResponse(
239+
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
240+
content=f"Something went wrong: {e}",
241+
)

0 commit comments

Comments
 (0)