-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK layer 2 - cover RC1 usecases #4813
Changes from all commits
e34731d
4f1940b
cf759f5
aad0ccc
50959a4
f43d47a
a16d103
38b7d82
7248a7f
4bda27e
e953a23
6d9f43e
e73828e
35b764a
4acffb5
8c5f2fc
aa8d8f0
d69af23
5210bce
aa0a8ff
1e5f915
78eb73e
b580feb
a491203
ac41fd4
03ddd56
122635c
4ca10bc
1519d3a
a123d6f
13e9644
347e414
c9d15d0
97d5beb
c44f6af
611d7fb
6e22c63
17d790c
2b8a460
3784e79
0a991ed
525feb5
af76558
434517b
cd5e1b9
24837d8
b2c362a
e913491
07069c4
31034f1
d0e9075
06481e1
aa8672e
cb3576f
d18271e
0de20f1
63ce027
2af421a
bf57543
3e4e859
905dd92
c27b494
55c120b
e060f53
4a8dc99
e6529cd
64aecbe
db96c6b
11e0ad0
c6349f4
16f09b3
c24dd44
9ef4b47
84cfe84
2f23938
412d0fb
2f31269
c1760fa
f05482a
7bdce47
80b36da
65a3f9d
e1bbc5f
dece1bd
f4333f9
cdb1be3
b776f18
3414a68
4d01fb8
45c02c7
57e4116
10875ab
d9a6e82
ed2ae4b
5b51bb2
8eaaf18
89c2725
1bc7cf6
a05beec
81233fc
c2a5f3e
b17acc5
b8a7087
a4e51d4
fb1e358
a23ff17
39f4715
6798791
9da9436
af6c598
6ef21e3
e3ea337
7a5df89
00fdcf6
e9c3113
db80b3e
ee84cc9
52c3e0f
5acea16
f7d786a
fd3220d
1b66328
a397cbd
dc4b551
2b6e5f3
08c3adf
5aaa323
d696eb6
57620fc
5afa6b5
f7541b8
f023d11
12e5218
2adcaad
3fadfa5
aec4c29
54e415c
a7c03a5
770fa1d
6540888
20a1e1b
af1e15b
75ba69b
7b492ee
f81f982
30b60df
58e4fe5
4f0aac5
b6369f7
24c65cc
edb3a77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
# B406 : import_xml_sax | ||
# B410 : import_lxml | ||
skips: B101,B102,B320,B404,B406,B410 | ||
exclude: **/tests/**,tests |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# Copyright (C) 2020-2022 Intel Corporation | ||
# Copyright (C) 2022 CVAT.ai Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
@@ -11,7 +10,7 @@ | |
import tqdm | ||
from cvat_sdk import Client, models | ||
from cvat_sdk.core.helpers import TqdmProgressReporter | ||
from cvat_sdk.core.types import ResourceType | ||
from cvat_sdk.core.proxies.tasks import ResourceType | ||
|
||
|
||
class CLI: | ||
|
@@ -26,7 +25,7 @@ def __init__(self, client: Client, credentials: Tuple[str, str]): | |
|
||
def tasks_list(self, *, use_json_output: bool = False, **kwargs): | ||
"""List all tasks in either basic or JSON format.""" | ||
results = self.client.list_tasks(return_json=use_json_output, **kwargs) | ||
results = self.client.tasks.list(return_json=use_json_output, **kwargs) | ||
if use_json_output: | ||
print(json.dumps(json.loads(results), indent=2)) | ||
else: | ||
|
@@ -50,7 +49,7 @@ def tasks_create( | |
""" | ||
Create a new task with the given name and labels JSON and add the files to it. | ||
""" | ||
task = self.client.create_task( | ||
task = self.client.tasks.create_from_data( | ||
spec=models.TaskWriteRequest(name=name, labels=labels, **kwargs), | ||
resource_type=resource_type, | ||
resources=resources, | ||
|
@@ -66,7 +65,7 @@ def tasks_create( | |
|
||
def tasks_delete(self, task_ids: Sequence[int]) -> None: | ||
"""Delete a list of tasks, ignoring those which don't exist.""" | ||
self.client.delete_tasks(task_ids=task_ids) | ||
self.client.tasks.remove_by_ids(task_ids=task_ids) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zhiltsov-max , I don't know all use cases, but probably tasks.delete(task_ids) is better. First argument can be array of ids or array of tasks. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its almost just a copy-paste from what CLI had. I can't say I prefer one way over another. Both work well and both are convertible to each other. I can say that your variant is more focused on manual typing, while the other is better for passing a container without the need of unpacking. I'm not sure if |
||
|
||
def tasks_frames( | ||
self, | ||
|
@@ -80,11 +79,11 @@ def tasks_frames( | |
Download the requested frame numbers for a task and save images as | ||
task_<ID>_frame_<FRAME>.jpg. | ||
""" | ||
self.client.retrieve_task(task_id=task_id).download_frames( | ||
self.client.tasks.retrieve(obj_id=task_id).download_frames( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it is possible or not, but it will be great if the first argument is ID. Thus we can just write tasks.retrieve(task_id). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I got the question. It is ID. Did you mean rename id to |
||
frame_ids=frame_ids, | ||
outdir=outdir, | ||
quality=quality, | ||
filename_pattern="task_{task_id}_frame_{frame_id:06d}{frame_ext}", | ||
filename_pattern=f"task_{task_id}" + "_frame_{frame_id:06d}{frame_ext}", | ||
) | ||
|
||
def tasks_dump( | ||
|
@@ -99,7 +98,7 @@ def tasks_dump( | |
""" | ||
Download annotations for a task in the specified format (e.g. 'YOLO ZIP 1.0'). | ||
""" | ||
self.client.retrieve_task(task_id=task_id).export_dataset( | ||
self.client.tasks.retrieve(obj_id=task_id).export_dataset( | ||
format_name=fileformat, | ||
filename=filename, | ||
pbar=self._make_pbar(), | ||
|
@@ -112,7 +111,7 @@ def tasks_upload( | |
) -> None: | ||
"""Upload annotations for a task in the specified format | ||
(e.g. 'YOLO ZIP 1.0').""" | ||
self.client.retrieve_task(task_id=task_id).import_annotations( | ||
self.client.tasks.retrieve(obj_id=task_id).import_annotations( | ||
format_name=fileformat, | ||
filename=filename, | ||
status_check_period=status_check_period, | ||
|
@@ -121,13 +120,13 @@ def tasks_upload( | |
|
||
def tasks_export(self, task_id: str, filename: str, *, status_check_period: int = 2) -> None: | ||
"""Download a task backup""" | ||
self.client.retrieve_task(task_id=task_id).download_backup( | ||
self.client.tasks.retrieve(obj_id=task_id).download_backup( | ||
filename=filename, status_check_period=status_check_period, pbar=self._make_pbar() | ||
) | ||
|
||
def tasks_import(self, filename: str, *, status_check_period: int = 2) -> None: | ||
"""Import a task from a backup file""" | ||
self.client.create_task_from_backup( | ||
self.client.tasks.create_from_backup( | ||
filename=filename, status_check_period=status_check_period, pbar=self._make_pbar() | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,4 +74,4 @@ cvat_sdk/api_client/ | |
requirements/ | ||
docs/ | ||
setup.py | ||
README.md | ||
README.md | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you put setup.py and README.md into .gitignore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are also generated automatically. We decided to remove such files. Moreover, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhiltsov-max , I'm not sure why we have the line in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure either. Probably, we need to review changelog links.