Skip to content

Commit

Permalink
Slightly enhance command line interface feature.
Browse files Browse the repository at this point in the history
Added README.md, run tests using travis, run CLI tests from VS code.
  • Loading branch information
Nikita Manovich committed Sep 30, 2019
1 parent db19cbf commit 5b5329d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"--settings",
"cvat.settings.testing",
"cvat/apps/engine",
"utils/cli"
],
"django": true,
"cwd": "${workspaceFolder}",
Expand Down
44 changes: 44 additions & 0 deletions utils/cli/README.md
Original file line number Diff line number Diff line change
@@ -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`
2 changes: 1 addition & 1 deletion utils/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down

0 comments on commit 5b5329d

Please sign in to comment.