From 5b5329dace50451df388cbf5032bc51b3f2701a1 Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Mon, 30 Sep 2019 15:34:54 +0300 Subject: [PATCH] Slightly enhance command line interface feature. Added README.md, run tests using travis, run CLI tests from VS code. --- .travis.yml | 4 ++-- .vscode/launch.json | 1 + utils/cli/README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ utils/cli/cli.py | 2 +- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 utils/cli/README.md diff --git a/.travis.yml b/.travis.yml index f4218109b96..c75681e0da6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,10 @@ python: services: - docker - + before_script: - docker-compose -f docker-compose.yml -f docker-compose.ci.yml up --build -d script: - - docker exec -it cvat /bin/bash -c 'python3 manage.py test cvat/apps/engine' + - docker exec -it cvat /bin/bash -c 'python3 manage.py test cvat/apps/engine utils/cli' - docker exec -it cvat /bin/bash -c 'cd cvat-core && npm install && npm run test && npm run coveralls' diff --git a/.vscode/launch.json b/.vscode/launch.json index ee8bb4fb3d2..069fe74d589 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -135,6 +135,7 @@ "--settings", "cvat.settings.testing", "cvat/apps/engine", + "utils/cli" ], "django": true, "cwd": "${workspaceFolder}", diff --git a/utils/cli/README.md b/utils/cli/README.md new file mode 100644 index 00000000000..ac42718620e --- /dev/null +++ b/utils/cli/README.md @@ -0,0 +1,44 @@ +# Command line interface (CLI) +**Description** +A simple command line interface for working with CVAT tasks. At the moment it +implements a basic feature set but may serve as the starting point for a more +comprehensive CVAT administration tool in the future. + +Overview of functionality: + +- Create a new task (supports name, bug tracker, labels JSON, local/share/remote files) +- Delete tasks (supports deleting a list of task IDs) +- List all tasks (supports basic CSV or JSON output) +- Download JPEG frames (supports a list of frame IDs) +- Dump annotations (supports all formats via format string) + +**Usage** +```bash +usage: cli.py [-h] [--auth USER:[PASS]] [--server-host SERVER_HOST] + [--server-port SERVER_PORT] [--debug] + {create,delete,ls,frames,dump} ... + +Perform common operations related to CVAT tasks. + +positional arguments: + {create,delete,ls,frames,dump} + +optional arguments: + -h, --help show this help message and exit + --auth USER:[PASS] defaults to the current user and supports the PASS + environment variable or password prompt. + --server-host SERVER_HOST + host (default: localhost) + --server-port SERVER_PORT + port (default: 8080) + --debug show debug output +``` +**Examples** +- List all tasks +`cli.py --auth user:pass --server-host localhost --server-port 8080 ls` +- Create a task +`cli.py create --name "new task" --labels labels.json local file1.jpg file2.jpg` +- Delete some tasks +`cli.py delete 100 101 102` +- Dump annotations +`cli.py dump --format "CVAT XML 1.1 for images" 103 output.xml` diff --git a/utils/cli/cli.py b/utils/cli/cli.py index 3407b23b4b8..96b6881fdf8 100755 --- a/utils/cli/cli.py +++ b/utils/cli/cli.py @@ -35,7 +35,7 @@ def main(): except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError, requests.exceptions.RequestException) as e: - log.info(e) + log.critical(e) if __name__ == '__main__':