def data_examples(mode): """ Data examples for editor preview and task upload examples """ global _DATA_EXAMPLES if _DATA_EXAMPLES is None: with open(find_file('data_examples.json')) as f: _DATA_EXAMPLES = json.load(f) roots = ['editor_preview', 'upload'] for root in roots: for key, value in _DATA_EXAMPLES[root].items(): if isinstance(value, str): _DATA_EXAMPLES[root][key] = value.replace('<HOSTNAME>', settings.HOSTNAME) return _DATA_EXAMPLES[mode]
from urllib.parse import urlencode from lxml import etree from collections import defaultdict from django.conf import settings from rest_framework.exceptions import ValidationError from label_studio.core.utils.io import find_file logger = logging.getLogger(__name__) _DATA_EXAMPLES = None _LABEL_TAGS = {'Label', 'Choice'} _NOT_CONTROL_TAGS = { 'Filter', } # TODO: move configs in right place _LABEL_CONFIG_SCHEMA = find_file('label_config_schema.json') with open(_LABEL_CONFIG_SCHEMA) as f: _LABEL_CONFIG_SCHEMA_DATA = json.load(f) def parse_config(config_string): """ :param config_string: Label config string :return: structured config of the form: { "<ControlTag>.name": { "type": "ControlTag", "to_name": ["<ObjectTag1>.name", "<ObjectTag2>.name"], "inputs: [ {"type": "ObjectTag1", "value": "<ObjectTag1>.value"}, {"type": "ObjectTag2", "value": "<ObjectTag2>.value"}