From d698dcef50bdbf3e9b701babf89b7fa6b6b69b41 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Wed, 28 Dec 2022 13:48:13 +0100 Subject: [PATCH 1/6] Add cloud_storage_id and filename_pattern args to cli --- cvat-cli/src/cvat_cli/parser.py | 13 +++++++++++++ cvat-sdk/cvat_sdk/core/proxies/tasks.py | 2 ++ 2 files changed, 15 insertions(+) diff --git a/cvat-cli/src/cvat_cli/parser.py b/cvat-cli/src/cvat_cli/parser.py index 5a5410a4a5c9..e1e017521f99 100644 --- a/cvat-cli/src/cvat_cli/parser.py +++ b/cvat-cli/src/cvat_cli/parser.py @@ -201,6 +201,19 @@ def make_cmdline_parser() -> argparse.ArgumentParser: action="store_true", # automatically sets default=False help="""zip chunks before sending them to the server""", ) + task_create_parser.add_argument( + "--cloud_storage_id", default=None, type=int, + help="cloud storage ID if you would like to use data from cloud storage", + ) + task_create_parser.add_argument( + "--filename_pattern", type=str, + help="""pattern for filtering data from the manifest file for the upload. + Only shell-style wildcards are supported: + * - matches everything + ? - matches any single character + [seq] - matches any character in 'seq' + [!seq] - matches any character not in seq""", + ) ####################################################################### # Delete diff --git a/cvat-sdk/cvat_sdk/core/proxies/tasks.py b/cvat-sdk/cvat_sdk/core/proxies/tasks.py index c734131a8f39..330a6ab94ec1 100644 --- a/cvat-sdk/cvat_sdk/core/proxies/tasks.py +++ b/cvat-sdk/cvat_sdk/core/proxies/tasks.py @@ -90,6 +90,8 @@ def upload_data( "stop_frame", "use_cache", "use_zip_chunks", + "filename_pattern", + "cloud_storage_id", ], ) ) From bd43a16886b5ffbbe78d378f479faa641229e641 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Wed, 28 Dec 2022 13:49:51 +0100 Subject: [PATCH 2/6] Add examples of usage --- site/content/en/docs/api_sdk/cli/_index.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/site/content/en/docs/api_sdk/cli/_index.md b/site/content/en/docs/api_sdk/cli/_index.md index 03da4a9e7672..0a5be3763a80 100644 --- a/site/content/en/docs/api_sdk/cli/_index.md +++ b/site/content/en/docs/api_sdk/cli/_index.md @@ -146,6 +146,18 @@ by using the [label constructor](/docs/manual/basics/creating_an_annotation_task --dataset_repository_url https://github.com/user/dataset/blob/main/annotation/anno_file_name.zip \ --lfs share //share/large_dataset/images/ ``` +- Create a task named "task with filtered cloud storage data", with filename_pattern `test_images/*.jpeg` + and using the data from the cloud storage resource described in the manifest.jsonl: + ```bash + cvat-cli create "task with filtered cloud storage data" --labels '[{"name": "car"}]'\ + --use_cache --cloud_storage_id 1 --filename_pattern "test_images/*.jpeg" share manifest.jsonl + ``` +- Create a task named "task with filtered cloud storage data" using all data from the cloud storage resource + described in the manifest.jsonl by specifying filename_pattern `*`: + ```bash + cvat-cli create "task with filtered cloud storage data" --labels '[{"name": "car"}]'\ + --use_cache --cloud_storage_id 1 --filename_pattern "*" share manifest.jsonl + ``` ### Delete From 05a4eb4172f9a9ad6aea23377a1bf23a03e1bf93 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Wed, 28 Dec 2022 13:58:02 +0100 Subject: [PATCH 3/6] Fix black issue --- cvat-cli/src/cvat_cli/parser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cvat-cli/src/cvat_cli/parser.py b/cvat-cli/src/cvat_cli/parser.py index e1e017521f99..f578401284e3 100644 --- a/cvat-cli/src/cvat_cli/parser.py +++ b/cvat-cli/src/cvat_cli/parser.py @@ -202,11 +202,14 @@ def make_cmdline_parser() -> argparse.ArgumentParser: help="""zip chunks before sending them to the server""", ) task_create_parser.add_argument( - "--cloud_storage_id", default=None, type=int, + "--cloud_storage_id", + default=None, + type=int, help="cloud storage ID if you would like to use data from cloud storage", ) task_create_parser.add_argument( - "--filename_pattern", type=str, + "--filename_pattern", + type=str, help="""pattern for filtering data from the manifest file for the upload. Only shell-style wildcards are supported: * - matches everything From 7f93f23d1dbef99137ecadb585d3bdb86c5ee715 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Wed, 28 Dec 2022 23:31:40 +0100 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf82b1b731b..d7990304c6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## \[2.4.0] - Unreleased ### Added -- Filename pattern to simplify uploading cloud storage data for a task () +- Filename pattern to simplify uploading cloud storage data for a task (, ) ### Changed - TDB From 4f381d2762cf998059ce31beaa7222d21734fd23 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Fri, 30 Dec 2022 12:21:31 +0100 Subject: [PATCH 5/6] Update text formatting --- cvat-cli/src/cvat_cli/parser.py | 50 +++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/cvat-cli/src/cvat_cli/parser.py b/cvat-cli/src/cvat_cli/parser.py index f578401284e3..621acf2e07d1 100644 --- a/cvat-cli/src/cvat_cli/parser.py +++ b/cvat-cli/src/cvat_cli/parser.py @@ -8,6 +8,7 @@ import json import logging import os +import textwrap from distutils.util import strtobool from cvat_sdk.core.proxies.tasks import ResourceType @@ -90,10 +91,13 @@ def make_cmdline_parser() -> argparse.ArgumentParser: ####################################################################### task_create_parser = task_subparser.add_parser( "create", - description="""Create a new CVAT task. To create a task, you need - to specify labels using the --labels argument or - attach the task to an existing project using the - --project_id argument.""", + description=textwrap.dedent("""\ + Create a new CVAT task. To create a task, you need + to specify labels using the --labels argument or + attach the task to an existing project using the + --project_id argument. + """), + formatter_class=argparse.RawTextHelpFormatter, ) task_create_parser.add_argument("name", type=str, help="name of the task") task_create_parser.add_argument( @@ -124,38 +128,46 @@ def make_cmdline_parser() -> argparse.ArgumentParser: dest="status_check_period", default=2, type=float, - help="""number of seconds to wait until checking - if data compression finished (necessary before uploading annotations)""", + help=textwrap.dedent("""\ + number of seconds to wait until checking + if data compression finished (necessary before uploading annotations) + """), ) task_create_parser.add_argument( "--copy_data", default=False, action="store_true", - help="""set the option to copy the data, only used when resource type is - share (default: %(default)s)""", + help=textwrap.dedent("""\ + set the option to copy the data, only used when resource type is + share (default: %(default)s) + """), ) 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/]" - ), + help=textwrap.dedent("""\ + git repository to store annotations e.g. + https://github.com/user/repos [annotation/] + """), ) task_create_parser.add_argument( "--frame_step", default=None, type=int, - help="""set the frame step option in the advanced configuration - when uploading image series or videos (default: %(default)s)""", + help=textwrap.dedent("""\ + set the frame step option in the advanced configuration + when uploading image series or videos (default: %(default)s) + """), ) task_create_parser.add_argument( "--image_quality", default=70, type=int, - help="""set the image quality option in the advanced configuration - when creating tasks.(default: %(default)s)""", + help=textwrap.dedent("""\ + set the image quality option in the advanced configuration + when creating tasks.(default: %(default)s) + """), ) task_create_parser.add_argument( "--labels", @@ -210,12 +222,14 @@ def make_cmdline_parser() -> argparse.ArgumentParser: task_create_parser.add_argument( "--filename_pattern", type=str, - help="""pattern for filtering data from the manifest file for the upload. + help=textwrap.dedent("""\ + pattern for filtering data from the manifest file for the upload. Only shell-style wildcards are supported: * - matches everything ? - matches any single character [seq] - matches any character in 'seq' - [!seq] - matches any character not in seq""", + [!seq] - matches any character not in seq + """), ) ####################################################################### From 2001b95c34b3f171b13bab3af0e2a98719c45193 Mon Sep 17 00:00:00 2001 From: Maria Khrustaleva Date: Fri, 30 Dec 2022 12:25:55 +0100 Subject: [PATCH 6/6] black --- cvat-cli/src/cvat_cli/parser.py | 42 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/cvat-cli/src/cvat_cli/parser.py b/cvat-cli/src/cvat_cli/parser.py index 621acf2e07d1..a1d6a3f78df9 100644 --- a/cvat-cli/src/cvat_cli/parser.py +++ b/cvat-cli/src/cvat_cli/parser.py @@ -91,12 +91,14 @@ def make_cmdline_parser() -> argparse.ArgumentParser: ####################################################################### task_create_parser = task_subparser.add_parser( "create", - description=textwrap.dedent("""\ + description=textwrap.dedent( + """\ Create a new CVAT task. To create a task, you need to specify labels using the --labels argument or attach the task to an existing project using the --project_id argument. - """), + """ + ), formatter_class=argparse.RawTextHelpFormatter, ) task_create_parser.add_argument("name", type=str, help="name of the task") @@ -128,46 +130,56 @@ def make_cmdline_parser() -> argparse.ArgumentParser: dest="status_check_period", default=2, type=float, - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ number of seconds to wait until checking if data compression finished (necessary before uploading annotations) - """), + """ + ), ) task_create_parser.add_argument( "--copy_data", default=False, action="store_true", - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ set the option to copy the data, only used when resource type is share (default: %(default)s) - """), + """ + ), ) task_create_parser.add_argument( "--dataset_repository_url", default="", type=str, - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ git repository to store annotations e.g. https://github.com/user/repos [annotation/] - """), + """ + ), ) task_create_parser.add_argument( "--frame_step", default=None, type=int, - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ set the frame step option in the advanced configuration when uploading image series or videos (default: %(default)s) - """), + """ + ), ) task_create_parser.add_argument( "--image_quality", default=70, type=int, - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ set the image quality option in the advanced configuration when creating tasks.(default: %(default)s) - """), + """ + ), ) task_create_parser.add_argument( "--labels", @@ -222,14 +234,16 @@ def make_cmdline_parser() -> argparse.ArgumentParser: task_create_parser.add_argument( "--filename_pattern", type=str, - help=textwrap.dedent("""\ + help=textwrap.dedent( + """\ pattern for filtering data from the manifest file for the upload. Only shell-style wildcards are supported: * - matches everything ? - matches any single character [seq] - matches any character in 'seq' [!seq] - matches any character not in seq - """), + """ + ), ) #######################################################################