Skip to content

Commit

Permalink
Style: format code with [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed May 25, 2024
1 parent 9c48ee2 commit 283475f
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions agenta-cli/agenta/sdk/agenta_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params:
params (dict(param_name, param_val)): The dictionary of the parameters for the function
"""

def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str, xparam: str):
def find_in_schema(
schema_type_properties: dict, schema: dict, param_name: str, xparam: str
):
"""Finds a parameter in the schema based on its name and x-parameter value"""
for _, value in schema.items():
value_title_lower = str(value.get("title")).lower()
Expand Down Expand Up @@ -465,7 +467,10 @@ def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str,
for param_name, param_val in params.items():
if isinstance(param_val, GroupedMultipleChoiceParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "grouped_choice"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"grouped_choice",
)
assert (
subschema
Expand All @@ -474,7 +479,10 @@ def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str,
subschema["default"] = param_val.default # type: ignore
if isinstance(param_val, MultipleChoiceParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "choice"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"choice",
)
default = str(param_val)
param_choices = param_val.choices # type: ignore
Expand All @@ -487,14 +495,20 @@ def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str,
subschema["default"] = default if default in param_choices else choices[0]
if isinstance(param_val, FloatParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "float"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"float",
)
subschema["minimum"] = param_val.minval # type: ignore
subschema["maximum"] = param_val.maxval # type: ignore
subschema["default"] = param_val
if isinstance(param_val, IntParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "int"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"int",
)
subschema["minimum"] = param_val.minval # type: ignore
subschema["maximum"] = param_val.maxval # type: ignore
Expand All @@ -512,7 +526,10 @@ def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str,
subschema["default"] = param_val.default["default_keys"]
if isinstance(param_val, TextParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "text"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"text",
)
subschema["default"] = param_val
if (
Expand All @@ -539,6 +556,9 @@ def find_in_schema(schema_type_properties: dict, schema: dict, param_name: str,
subschema["default"] = "https://example.com"
if isinstance(param_val, BinaryParam):
subschema = find_in_schema(
param_val.__schema_type_properties__(), schema_to_override, param_name, "bool"
param_val.__schema_type_properties__(),
schema_to_override,
param_name,
"bool",
)
subschema["default"] = param_val.default # type: ignore

0 comments on commit 283475f

Please sign in to comment.