Skip to content

Commit

Permalink
surface callable params in openapi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed Aug 2, 2024
1 parent 36f590a commit 8a67076
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions runhouse/resources/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,15 +1153,21 @@ def openapi_spec(self, spec_name: Optional[str] = None):
param.default if param.default != inspect.Parameter.empty else ...,
)

for k, v in params.items():
if isinstance(v[0], Callable):
logger.warning(
f"Callable detected in openapi spec params: {k} of type {v[0]}"
)

# Filter out any callables which are not compatible for generating the schema
filtered_params = {
k: (v[0], v[1])
for k, v in params.items()
if not isinstance(v[0], Callable)
}
# filtered_params = {
# k: (v[0], v[1])
# for k, v in params.items()
# if not isinstance(v[0], Callable)
# }

module_method_params = create_model(
f"{method_name}_schema", **filtered_params
f"{method_name}_schema", **params
).schema()
module_method_params["title"] = "kwargs"

Expand Down

0 comments on commit 8a67076

Please sign in to comment.