Add tags to Dataset listing

This commit is contained in:
allegroai 2021-03-11 09:40:31 +02:00
parent b33ac21764
commit 532010c93d
2 changed files with 11 additions and 6 deletions

View File

@ -330,11 +330,12 @@ def ds_search(args):
dataset_project=args.project or None, partial_name=args.name or None,
tags=args.tags or None, ids=args.ids or None
)
formatting = '{:16} | {:32} | {:19} | {:32}'
print(formatting.format('project', 'name', 'created', 'id'))
print('-' * len(formatting.format('-', '-', '-', '-')))
formatting = '{:16} | {:32} | {:19} | {:19} | {:32}'
print(formatting.format('project', 'name', 'tags', 'created', 'id'))
print('-' * len(formatting.format('-', '-', '-', '-', '-')))
for d in datasets:
print(formatting.format(d['project'], d['name'], str(d['created']).split('.')[0], d['id']))
print(formatting.format(
d['project'], d['name'], str(d['tags'] or [])[1:-1], str(d['created']).split('.')[0], d['id']))
return 0

View File

@ -890,13 +890,17 @@ class Dataset(object):
type=[str(Task.TaskTypes.data_processing)],
tags=tags or None,
status=['stopped', 'published', 'completed', 'closed'] if only_completed else None,
only_fields=['created', 'id', 'name', 'project']
only_fields=['created', 'id', 'name', 'project', 'tags']
)
project_ids = {d.project for d in datasets}
# noinspection PyProtectedMember
project_id_lookup = {d: Task._get_project_name(d) for d in project_ids}
return [
{'name': d.name, 'created': d.created, 'project': project_id_lookup[d.project], 'id': d.id}
{'name': d.name,
'created': d.created,
'project': project_id_lookup[d.project],
'id': d.id,
'tags': d.tags}
for d in datasets
]