Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/routers/openml/tasktype.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,33 @@ async def get_task_type(
creator.strip(' "') for creator in cast("str", contributors).split(",")
]
task_type["creation_date"] = task_type.pop("creationDate")

task_type_inputs = await get_input_for_task_type(task_type_id, expdb)
input_types = []
for task_type_input in task_type_inputs:
input_ = {}
if task_type_input.requirement == "required":
input_["requirement"] = task_type_input.requirement
input_["name"] = task_type_input.name
# api_constraints is for one input only in the test database (TODO: patch db)
if isinstance(task_type_input.api_constraints, str):
constraint = json.loads(task_type_input.api_constraints)
input_["data_type"] = constraint["data_type"]

# Accept either legacy JSON string or already parsed dict
constraint = None
ac = task_type_input.api_constraints
if isinstance(ac, str):
try:
constraint = json.loads(ac)
except json.JSONDecodeError:
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
# Keep response stable for malformed legacy values
constraint = None
elif isinstance(ac, dict):
constraint = ac
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated

if isinstance(constraint, dict):
data_type = constraint.get("data_type")
if data_type is not None:
input_["data_type"] = data_type
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

input_types.append(input_)

task_type["input"] = input_types
return {"task_type": task_type}
Loading