Пример #1
0
def load_tag_groups(dr: DataRiver, tag_group_dir: str):
    tgr = JSonTagGroupRegistry()

    for entry in os.scandir(tag_group_dir):
        if entry.is_file() and entry.path.endswith('.json'):
            log.info(f'Loading tag group: {entry.path}')
            try:
                tgr.register_tag_groups_from_uri(f'file://{entry.path}')
            except Exception as e:
                log.error(f'Unable to load tag group: {entry.path} : {e}')
                pass
    dr.add_tag_group_registry(tgr)
Пример #2
0
def register_tag_groups(dr: DataRiver, tag_group_dir: str,
                        tag_groups: List[str]):
    '''
    For each of the Tag Groups listed in tag_groups and whose definition is in tag_groups_dir register them with
    the provided instance of the Data River; dr.

    The tag_groups list should be the name of the file without the .json extension
    '''
    tgr = JSonTagGroupRegistry()

    for tg in tag_groups:
        logging.info(f'Loading Tag Group: {tg}.json from {tag_group_dir}')
        tgr.register_tag_groups_from_uri(
            get_abs_file_uri(str(os.path.join(tag_group_dir, f'{tg}.json'))))

    dr.add_tag_group_registry(tgr)