Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LSDV-5222: custom weights reset following labeling interface changes #4611

Merged
merged 6 commits into from
Aug 14, 2023
19 changes: 17 additions & 2 deletions label_studio/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,29 @@ def get_updated_weights(self):
outputs = self.get_parsed_config(autosave_cache=False)
control_weights = {}
exclude_control_types = ('Filter',)

def get_label(label):
label_value = self.control_weights.get(control_name, {}).get('labels', {}).get(label)
return label_value if label_value is not None else 1.0

def get_overall(name):
weights = self.control_weights.get(name, None)
if not weights:
return 1.0
else:
weight = weights.get('overall', None)
return weight if weight is not None else 1.0


for control_name in outputs:
control_type = outputs[control_name]['type']
if control_type in exclude_control_types:
continue

control_weights[control_name] = {
'overall': self.control_weights.get(control_name, {}).get('overall') or 1.0,
'overall': get_overall(control_name),
'type': control_type,
'labels': {label: self.control_weights.get(control_name, {}).get('labels', {}).get(label) or 1.0 for label in outputs[control_name].get('labels', [])},
'labels': {label: get_label(label) for label in outputs[control_name].get('labels', [])},
}
return control_weights

Expand Down
Loading