Spaces:
Sleeping
Sleeping
Download layout.py from Moises711/mi-asistente: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/Moises711/mi-asistente/resolve/main/layout.py
- Command line
-
hf download hf://spaces/Moises711/mi-asistente/layout.py
-
curl -L -o layout.py https://huggingface.co/spaces/Moises711/mi-asistente/resolve/main/layout.py
1.13 kB
| from pathlib import PurePosixPath | |
| KINDS = ('palabras', 'silabas', 'oraciones', 'cuentos') | |
| def testing(data, collection): | |
| return any(c['id'] == collection and (c.get('is_test') or c['name'].casefold().startswith('prueba')) for c in data['collections']) | |
| def folder(data, collection, kind): | |
| if data.get('storage_layout') == 'types': | |
| return f'pruebas/{kind}/{collection}' if testing(data, collection) else kind | |
| return f'v1/colecciones/{collection}/{kind}' | |
| def manifests(data): | |
| if data.get('storage_layout') != 'types': | |
| return {} | |
| groups = {kind: [] for kind in KINDS} | |
| groups.update({f'pruebas/{kind}': [] for kind in KINDS}) | |
| for record in data['recordings']: | |
| item = data['items'][record['item_id']] | |
| target = f"pruebas/{item['kind']}" if testing(data, record['collection']) else item['kind'] | |
| groups[target].append(dict(record, file_name=PurePosixPath(record['path']).name, | |
| word_id=item['id'], dataset='pruebas' if testing(data, record['collection']) else item['kind'])) | |
| return {f'{path}/manifest.json': records for path, records in groups.items()} | |