Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
makseq committed Nov 14, 2024
1 parent fcd6235 commit 1c53029
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions label_studio/data_manager/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def preprocess_filter(_filter, *_):
return _filter


def preprocess_field_name(raw_field_name, only_undefined_field=False) -> Tuple[str, bool]:
def preprocess_field_name(raw_field_name, project) -> Tuple[str, bool]:
"""Transform a field name (as specified in the datamanager views endpoint) to
a django ORM field name. Also handle dotted accesses to task.data.
Expand Down Expand Up @@ -389,7 +389,9 @@ def preprocess_field_name(raw_field_name, only_undefined_field=False) -> Tuple[s
field_name = field_name[1:]

if field_name.startswith('data.'):
if only_undefined_field:
# process as $undefined$ only if real_name is from labeling config, not from task.data
real_name = field_name.replace('data.', '')
if project.only_undefined_field and real_name not in project.data_types.keys():
field_name = f'data__{settings.DATA_UNDEFINED_NAME}'
else:
field_name = field_name.replace('data.', 'data__')
Expand Down
13 changes: 8 additions & 5 deletions label_studio/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,14 @@ def one_object_in_label_config(self):

@property
def only_undefined_field(self):
"""This property is true when there is only one column - $undefined$ - in this project.
This is useful for cases when labeling config has one field only (e.g. `image` or `text`)
and task data does not contain any other columns.
E.g. it allows to use data manager filters with `image` (or `text`) in the filter expression,
however, in fact task data does not contain `image` (or `text`) columns, it contains `$undefined$` only.
"""This property is true when
1. there is only one object tag in labeling config,
2. there is only one common column for all tasks and it's $undefined$,
This is useful for cases when the labeling configuration has only one field,
such as `image` or `text`. For example, it allows to force a data manager
to filter `image` as `$undefined$`, because the task data, in reality,
does not contain `image`; it contains only `$undefined$`.
"""
return (
self.one_object_in_label_config
Expand Down

0 comments on commit 1c53029

Please sign in to comment.