Skip to content
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

CLI: make the output of create commands machine-readable #8833

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Changed

- \[CLI\] The output of the `task create`, `task create-from-backup` and
`project create` commands is now just the created resource ID,
making it machine-readable
(<https://github.com/cvat-ai/cvat/pull/8833>)
2 changes: 1 addition & 1 deletion cvat-cli/src/cvat_cli/_internal/commands_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def execute(
dataset_format=dataset_format,
status_check_period=status_check_period,
)
print(f"Created project ID {project.id}")
print(project.id)


@COMMANDS.command_class("delete")
Expand Down
4 changes: 2 additions & 2 deletions cvat-cli/src/cvat_cli/_internal/commands_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def execute(
status_check_period=status_check_period,
pbar=DeferredTqdmProgressReporter(),
)
print("Created task id", task.id)
print(task.id)


@COMMANDS.command_class("delete")
Expand Down Expand Up @@ -406,7 +406,7 @@ def execute(self, client: Client, *, filename: str, status_check_period: int) ->
status_check_period=status_check_period,
pbar=DeferredTqdmProgressReporter(),
)
print(f"Created task ID", task.id)
print(task.id)


@COMMANDS.command_class("auto-annotate")
Expand Down
4 changes: 2 additions & 2 deletions tests/python/cli/test_cli_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_can_create_project(self):
"https://bugs.example/",
)

project_id = int(stdout.split()[-1])
project_id = int(stdout.rstrip("\n"))
created_project = self.client.projects.retrieve(project_id)
assert created_project.name == "new_project"
assert created_project.bug_tracker == "https://bugs.example/"
Expand All @@ -52,7 +52,7 @@ def test_can_create_project_from_dataset(self, fxt_coco_dataset):
"COCO 1.0",
)

project_id = int(stdout.split()[-1])
project_id = int(stdout.rstrip("\n"))
created_project = self.client.projects.retrieve(project_id)
assert created_project.name == "new_project"
assert {label.name for label in created_project.get_labels()} == {"car", "person"}
Expand Down
6 changes: 3 additions & 3 deletions tests/python/cli/test_cli_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_can_create_task_from_local_images(self):
"0.01",
)

task_id = int(stdout.split()[-1])
task_id = int(stdout.rstrip("\n"))
assert self.client.tasks.retrieve(task_id).size == 5

def test_can_create_task_from_local_images_with_parameters(self):
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_can_create_task_from_local_images_with_parameters(self):
"http://localhost/bug",
)

task_id = int(stdout.split()[-1])
task_id = int(stdout.rstrip("\n"))
task = self.client.tasks.retrieve(task_id)
frames = task.get_frames_info()
assert [f.name for f in frames] == [
Expand Down Expand Up @@ -191,7 +191,7 @@ def test_can_upload_annotations(self, fxt_new_task: Task, fxt_coco_file: Path):
def test_can_create_from_backup(self, fxt_new_task: Task, fxt_backup_file: Path):
stdout = self.run_cli("task", "create-from-backup", str(fxt_backup_file))

task_id = int(stdout.split()[-1])
task_id = int(stdout.rstrip("\n"))
assert task_id
assert task_id != fxt_new_task.id
assert self.client.tasks.retrieve(task_id).size == fxt_new_task.size
Expand Down
Loading