add cli kwargs for image_quality and frame_step when creating task (#3176)

* add cli kwargs for image_quality and frame_step when creating task

* add **kwargs to the tasks_data function call

* add the corresponding options into argument parser

* Update core.py

update license header

* update license header

* fix definition.py help text
main
qztseng 5 years ago committed by GitHub
parent d14c26a32f
commit 11d967d208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
# Copyright (C) 2020 Intel Corporation # Copyright (C) 2020-2021 Intel Corporation
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
@ -23,7 +23,7 @@ class CLI():
self.session = session self.session = session
self.login(credentials) self.login(credentials)
def tasks_data(self, task_id, resource_type, resources): def tasks_data(self, task_id, resource_type, resources, **kwargs):
""" Add local, remote, or shared files to an existing task. """ """ Add local, remote, or shared files to an existing task. """
url = self.api.tasks_id_data(task_id) url = self.api.tasks_id_data(task_id)
data = {} data = {}
@ -35,6 +35,13 @@ class CLI():
elif resource_type == ResourceType.SHARE: elif resource_type == ResourceType.SHARE:
data = {'server_files[{}]'.format(i): f for i, f in enumerate(resources)} data = {'server_files[{}]'.format(i): f for i, f in enumerate(resources)}
data['image_quality'] = 50 data['image_quality'] = 50
## capture additional kwargs
if 'image_quality' in kwargs:
data['image_quality'] = kwargs.get('image_quality')
if 'frame_step' in kwargs:
data['frame_filter'] = f"step={kwargs.get('frame_step')}"
response = self.session.post(url, data=data, files=files) response = self.session.post(url, data=data, files=files)
response.raise_for_status() response.raise_for_status()
@ -85,7 +92,7 @@ class CLI():
response_json = response.json() response_json = response.json()
log.info('Created task ID: {id} NAME: {name}'.format(**response_json)) log.info('Created task ID: {id} NAME: {name}'.format(**response_json))
task_id = response_json['id'] task_id = response_json['id']
self.tasks_data(task_id, resource_type, resources) self.tasks_data(task_id, resource_type, resources, **kwargs)
if annotation_path != '': if annotation_path != '':
url = self.api.tasks_id_status(task_id) url = self.api.tasks_id_status(task_id)

@ -181,7 +181,20 @@ task_create_parser.add_argument(
action='store_true', action='store_true',
help='using lfs for dataset repository (default: %(default)s)' help='using lfs for dataset repository (default: %(default)s)'
) )
task_create_parser.add_argument(
'--image_quality',
default=70,
type=int,
help='''set the image quality option in the advanced configuration
when creating tasks.(default: %(default)s)'''
)
task_create_parser.add_argument(
'--frame_step',
default=1,
type=int,
help='''set the frame step option in the advanced configuration
when uploading image series or videos (default: %(default)s)'''
)
####################################################################### #######################################################################
# Delete # Delete
####################################################################### #######################################################################

Loading…
Cancel
Save