mirror of
https://github.com/clearml/clearml
synced 2025-03-03 18:52:12 +00:00
Add "clearml-data publish" to allow publishing a dataset task
This commit is contained in:
parent
1600101f94
commit
0c017a7331
@ -148,6 +148,10 @@ def cli():
|
|||||||
finalize.add_argument('--verbose', action='store_true', default=False, help='Verbose reporting')
|
finalize.add_argument('--verbose', action='store_true', default=False, help='Verbose reporting')
|
||||||
finalize.set_defaults(func=ds_close)
|
finalize.set_defaults(func=ds_close)
|
||||||
|
|
||||||
|
publish = subparsers.add_parser('publish', help='Publish dataset task')
|
||||||
|
publish.add_argument('--id', type=str, required=True, help='The dataset task id to be published.')
|
||||||
|
publish.set_defaults(func=ds_publish)
|
||||||
|
|
||||||
delete = subparsers.add_parser('delete', help='Delete a dataset')
|
delete = subparsers.add_parser('delete', help='Delete a dataset')
|
||||||
delete.add_argument('--id', type=str, required=False,
|
delete.add_argument('--id', type=str, required=False,
|
||||||
help='Previously created dataset id. Default: previously created/accessed dataset')
|
help='Previously created dataset id. Default: previously created/accessed dataset')
|
||||||
@ -372,6 +376,20 @@ def ds_close(args):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def ds_publish(args):
|
||||||
|
print('Publishing dataset id {}'.format(args.id))
|
||||||
|
check_null_id(args)
|
||||||
|
print_args(args)
|
||||||
|
ds = Dataset.get(dataset_id=args.id)
|
||||||
|
if not ds.is_final():
|
||||||
|
raise ValueError("Cannot publish dataset. Please finalize it first, run `clearml-data close`")
|
||||||
|
|
||||||
|
ds.publish()
|
||||||
|
print('Dataset published')
|
||||||
|
clear_state() # just to verify the state is clear
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def ds_upload(args):
|
def ds_upload(args):
|
||||||
print('uploading local files to dataset id {}'.format(args.id))
|
print('uploading local files to dataset id {}'.format(args.id))
|
||||||
check_null_id(args)
|
check_null_id(args)
|
||||||
|
@ -406,6 +406,21 @@ class Dataset(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def publish(self, raise_on_error=True):
|
||||||
|
# type: (bool) -> bool
|
||||||
|
"""
|
||||||
|
Publish the dataset
|
||||||
|
If dataset is not finalize, throw exception
|
||||||
|
|
||||||
|
:param raise_on_error: If True raise exception if dataset publishing failed
|
||||||
|
"""
|
||||||
|
# check we can publish this dataset
|
||||||
|
if not self.is_final():
|
||||||
|
raise ValueError("Cannot publish dataset, dataset in status {}.".format(self._task.get_status()))
|
||||||
|
|
||||||
|
self._task.publish(ignore_errors=raise_on_error)
|
||||||
|
return True
|
||||||
|
|
||||||
def is_final(self):
|
def is_final(self):
|
||||||
# type: () -> bool
|
# type: () -> bool
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user