mirror of
https://github.com/clearml/clearml-server
synced 2025-04-27 17:31:25 +00:00
Add request model detection in endpoint decorator
This commit is contained in:
parent
f879f6924f
commit
f9f2f0ccf0
@ -28,7 +28,13 @@ def endpoint(
|
|||||||
# Backwards compatibility: support endpoints with both old-style signature (call) and new-style signature
|
# Backwards compatibility: support endpoints with both old-style signature (call) and new-style signature
|
||||||
# (call, company, request_model)
|
# (call, company, request_model)
|
||||||
func = f
|
func = f
|
||||||
if len(signature(f).parameters) == 1:
|
sig = signature(f)
|
||||||
|
nonlocal request_data_model
|
||||||
|
if len(sig.parameters) == 3 and request_data_model is None:
|
||||||
|
last_arg = list(sig.parameters.items())[-1][1]
|
||||||
|
if last_arg.annotation != last_arg.empty:
|
||||||
|
request_data_model = last_arg.annotation
|
||||||
|
elif len(sig.parameters) == 1:
|
||||||
# old-style
|
# old-style
|
||||||
def adapter(call, *_, **__):
|
def adapter(call, *_, **__):
|
||||||
return f(call)
|
return f(call)
|
||||||
|
Loading…
Reference in New Issue
Block a user