未验证 提交 61e112e2 编写于 作者: A André Aquilina 提交者: GitHub

Add dataset URI to Task from CLI (#2983)

* Add option to include git repository for annotation synchronisation.

* Add arge parser for git dataset repository in task create.

* Update changelog.

* Add API for git.

* Add verification procedure for dataset repository creation.
Co-authored-by: NAndré Aquilina <andre.aquilina@dysismedical.com>
上级 af416f6f
......@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- CLI: Add support for saving annotations in a git repository when creating a task.
- CVAT-3D: support lidar data on the server side (<https://github.com/openvinotoolkit/cvat/pull/2534>)
- GPU support for Mask-RCNN and improvement in its deployment time (<https://github.com/openvinotoolkit/cvat/pull/2714>)
- CVAT-3D: Load all frames corresponding to the job instance
......
......@@ -63,7 +63,10 @@ class CLI():
def tasks_create(self, name, labels, overlap, segment_size, bug, resource_type, resources,
annotation_path='', annotation_format='CVAT XML 1.1',
completion_verification_period=20, **kwargs):
completion_verification_period=20,
git_completion_verification_period=2,
dataset_repository_url='',
lfs=False, **kwargs):
""" Create a new task with the given name and labels JSON and
add the files to it. """
url = self.api.tasks
......@@ -97,6 +100,29 @@ class CLI():
log.info(logger_string)
self.tasks_upload(task_id, annotation_format, annotation_path, **kwargs)
if dataset_repository_url:
response = self.session.post(
self.api.git_create(task_id),
json={
'path': dataset_repository_url,
'lfs': lfs,
'tid': task_id})
response_json = response.json()
rq_id = response_json['rq_id']
log.info(f"Create RQ ID: {rq_id}")
check_url = self.api.git_check(rq_id)
response = self.session.get(check_url)
response_json = response.json()
log.info('''Awaiting dataset repository for task. Status: {}'''.format(
response_json['status']))
while response_json['status'] != 'finished':
sleep(git_completion_verification_period)
response = self.session.get(check_url)
response_json = response.json()
if response_json['status'] == 'Failed':
log.error(f'Dataset repository creation request for task {task_id} failed.')
log.info(f"Dataset repository creation completed with status: {response_json['status']}.")
def tasks_delete(self, task_ids, **kwargs):
""" Delete a list of tasks, ignoring those which don't exist. """
......@@ -192,6 +218,7 @@ class CVAT_API_V1():
host = host.replace('https://', '')
scheme = 'https' if https else 'http'
self.base = '{}://{}/api/v1/'.format(scheme, host)
self.git = f'{scheme}://{host}/git/repository/'
@property
def tasks(self):
......@@ -220,6 +247,12 @@ class CVAT_API_V1():
return self.tasks_id(task_id) + '/annotations?format={}&filename={}' \
.format(fileformat, name)
def git_create(self, task_id):
return self.git + f'create/{task_id}'
def git_check(self, rq_id):
return self.git + f'check/{rq_id}'
@property
def login(self):
return self.base + 'auth/login'
......@@ -162,7 +162,19 @@ task_create_parser.add_argument(
help='''number of seconds to wait until checking
if data compression finished (necessary before uploading annotations)'''
)
task_create_parser.add_argument(
'--dataset_repository_url',
default='',
type=str,
help=('git repository to store annotations e.g.'
' https://github.com/user/repos [annotation/<anno_file_name.zip>]')
)
task_create_parser.add_argument(
'--lfs',
default=False,
action='store_true',
help='using lfs for dataset repository (default: %(default)s)'
)
#######################################################################
# Delete
#######################################################################
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册