Commit
·
98ef152
1
Parent(s):
b652f9c
fix issues in description
Browse files- app/services/base.py +5 -4
app/services/base.py
CHANGED
@@ -27,7 +27,7 @@ def cf_style_to_pydantic_percentage_shema(
|
|
27 |
else:
|
28 |
multiple = False
|
29 |
class_name = "Class_" + attribute.capitalize()
|
30 |
-
multiple_desc = "multi-label classification" if multiple else "classification"
|
31 |
attribute_desc = attribute_info.description
|
32 |
attribute_line = f'{attribute}: {class_name} = Field("", description="{multiple_desc}, {attribute_desc}")'
|
33 |
|
@@ -146,24 +146,25 @@ class BaseAttributionService(ABC):
|
|
146 |
init_reevaluate_data = {}
|
147 |
for field_name, field in attributes_percentage_model.model_fields.items(): # type: ignore
|
148 |
print(f"{field_name}: {field.description}")
|
149 |
-
if "single
|
150 |
max_percentage = 0
|
151 |
for k, v in reevaluate_data[field_name].items():
|
152 |
if v > max_percentage:
|
153 |
max_percentage = v
|
154 |
init_reevaluate_data[field_name] = k
|
155 |
-
elif "
|
156 |
init_list = []
|
157 |
for k, v in reevaluate_data[field_name].items():
|
158 |
if v >= 60:
|
159 |
init_list.append(k)
|
160 |
init_reevaluate_data[field_name] = init_list
|
|
|
|
|
161 |
|
162 |
# reverse the key mapping to the original keys
|
163 |
reverse_data = {}
|
164 |
for key, value in init_reevaluate_data.items():
|
165 |
reverse_data[reverse_mapping[key]] = value
|
166 |
-
|
167 |
return data, reverse_data
|
168 |
|
169 |
async def follow_schema_with_validation(
|
|
|
27 |
else:
|
28 |
multiple = False
|
29 |
class_name = "Class_" + attribute.capitalize()
|
30 |
+
multiple_desc = "multi-label classification" if multiple else "single-label classification"
|
31 |
attribute_desc = attribute_info.description
|
32 |
attribute_line = f'{attribute}: {class_name} = Field("", description="{multiple_desc}, {attribute_desc}")'
|
33 |
|
|
|
146 |
init_reevaluate_data = {}
|
147 |
for field_name, field in attributes_percentage_model.model_fields.items(): # type: ignore
|
148 |
print(f"{field_name}: {field.description}")
|
149 |
+
if "single-label" in field.description.lower():
|
150 |
max_percentage = 0
|
151 |
for k, v in reevaluate_data[field_name].items():
|
152 |
if v > max_percentage:
|
153 |
max_percentage = v
|
154 |
init_reevaluate_data[field_name] = k
|
155 |
+
elif "multi-label" in field.description.lower():
|
156 |
init_list = []
|
157 |
for k, v in reevaluate_data[field_name].items():
|
158 |
if v >= 60:
|
159 |
init_list.append(k)
|
160 |
init_reevaluate_data[field_name] = init_list
|
161 |
+
else:
|
162 |
+
assert False, f"The description does not contain 'single-label' or 'multi-label': {field.description}"
|
163 |
|
164 |
# reverse the key mapping to the original keys
|
165 |
reverse_data = {}
|
166 |
for key, value in init_reevaluate_data.items():
|
167 |
reverse_data[reverse_mapping[key]] = value
|
|
|
168 |
return data, reverse_data
|
169 |
|
170 |
async def follow_schema_with_validation(
|