def delete_recording(*, feed: kp.Feed, workspace_name: str, recording_id: str):
    recordings_subfeed = feed.get_subfeed(
        dict(workspaceName=workspace_name, key='recordings'))
    le_recordings = _get_recordings_from_subfeed(recordings_subfeed)
    if recording_id not in le_recordings:
        print(f'Cannot remove recording. Recording not found: {recording_id}')
    recordings_subfeed.append_message({
        'action': {
            'type': 'DELETE_RECORDINGS',
            'recordingIds': [recording_id]
        }
    })
    sortings_subfeed = feed.get_subfeed(
        dict(workspaceName=workspace_name, key='sortings'))
    le_sortings = _get_sortings_from_subfeed(sortings_subfeed)
    sorting_ids_to_delete = []
    for k, v in le_sortings.items():
        if v.get('recordingId') == recording_id:
            sorting_ids_to_delete.append(v.get('sortingId'))
    if len(sorting_ids_to_delete) > 0:
        sortings_subfeed.append_message({
            'action': {
                'type': 'DELETE_SORTINGS',
                'sortingIds': sorting_ids_to_delete
            }
        })
def import_sorting(*, feed: kp.Feed, workspace_name: str,
                   recording: se.RecordingExtractor,
                   sorting: se.SortingExtractor, recording_id: str,
                   sorting_label: str):
    sorting_id = 'S-' + random_id()
    x = {
        'sortingId':
        sorting_id,
        'sortingLabel':
        sorting_label,
        'sortingPath':
        ka.store_object(sorting.object(), basename=f'{sorting_label}.json'),
        'sortingObject':
        sorting.object(),
        'recordingId':
        recording_id,
        'recordingPath':
        ka.store_object(recording.object(), basename=f'{recording_id}.json'),
        'recordingObject':
        recording.object(),
        'description':
        f'Imported from Python: {sorting_label}'
    }
    sortings_subfeed = feed.get_subfeed(
        dict(workspaceName=workspace_name, key='sortings'))
    _import_le_sorting(sortings_subfeed, x)
    return x
Esempio n. 3
0
def _delete_sorting(*, feed: kp.Feed, workspace_name: str, sorting_id: str):
    subfeed = feed.get_subfeed(dict(workspaceName=workspace_name))
    le_sortings = _get_recordings_from_subfeed(subfeed)
    if sorting_id not in le_sortings:
        print(f'Cannot remove sorting. Sorting not found: {sorting_id}')
    subfeed.append_message(
        {'action': {
            'type': 'DELETE_SORTINGS',
            'sortingIds': [sorting_id]
        }})
Esempio n. 4
0
def _delete_field_model(*, feed: kp.Feed, workspace_name: str,
                        field_model_id: str):
    subfeed = feed.get_subfeed(dict(workspaceName=workspace_name))
    le_field_models = _get_field_models_from_subfeed(subfeed)
    if field_model_id not in le_field_models:
        print(
            f'Cannot remove field model. Field model not found: {field_model_id}'
        )
    subfeed.append_message({
        'type': 'deleteFieldModelS',
        'fieldModelIds': [field_model_id]
    })