From cfca87353e14897378ca4b5a96e651be2c3acce2 Mon Sep 17 00:00:00 2001 From: Tony Lampada Date: Tue, 17 Oct 2023 21:55:00 +0000 Subject: [PATCH 1/3] CLI to login/upload/download --- roboflowpy.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 roboflowpy.py diff --git a/roboflowpy.py b/roboflowpy.py new file mode 100644 index 00000000..ff3ca8a0 --- /dev/null +++ b/roboflowpy.py @@ -0,0 +1,55 @@ +import argparse +import roboflow + +def login(args): + roboflow.login() + +def download(args): + rf = roboflow.Roboflow() + w, p, v = args.datasetUrl.split("/") + format, location = args.f, args.l + project = rf.workspace(w).project(p) + project.version(int(v)).download(format, location=location, overwrite=True) + +def upload(args): + rf = roboflow.Roboflow() + f, w, p, folder = args.f, args.w, args.p, args.folder + workspace = rf.workspace(w) + workspace.upload_dataset( + dataset_path=folder, + dataset_format=f, + project_name=p, + ) + + +def main(): + parser = argparse.ArgumentParser(description="main description") + subparsers = parser.add_subparsers(title="subcommands") + + login_parser = subparsers.add_parser("login", help="Log in to Roboflow") + login_parser.set_defaults(func=login) + + download_parser = subparsers.add_parser("download", help="Download a dataset version from your workspace or Roboflow Universe.") + download_parser.add_argument("datasetUrl", help="Dataset URL (e.g., `roboflow-100/cells-uyemf/2`)") + download_parser.add_argument("-f", + choices=["coco", "yolov5pytorch", "yolov7pytorch", "my-yolov6", "darknet", "voc", "tfrecord", + "createml", "clip", "multiclass", "coco-segmentation", "yolo5-obb", "png-mask-semantic"], + help="Specify the format to download the version in (default: interactive prompt)") + download_parser.add_argument("-l", help="Location to download the dataset") + download_parser.set_defaults(func=download) + + upload_parser = subparsers.add_parser("upload", help="Upload a dataset") + upload_parser.add_argument("folder", help="filesystem path to a folder that contains your dataset") + upload_parser.add_argument("-w", help="workspace url") + upload_parser.add_argument("-p", help="Project name") + upload_parser.add_argument("-f", choices=["voc", "yolov8", "yolov5"], help="format") + upload_parser.set_defaults(func=upload) + + args = parser.parse_args() + if hasattr(args, 'func'): + args.func(args) + else: + parser.print_help() + +if __name__ == "__main__": + main() From 33a50d524205809bd69964864e3b465f4354bdc6 Mon Sep 17 00:00:00 2001 From: Tony Lampada Date: Tue, 17 Oct 2023 21:55:13 +0000 Subject: [PATCH 2/3] manual test scripts --- .gitignore | 1 + tests/manual/download.sh | 3 +++ tests/manual/login.sh | 2 ++ tests/manual/upload.sh | 2 ++ 4 files changed, 8 insertions(+) create mode 100755 tests/manual/download.sh create mode 100755 tests/manual/login.sh create mode 100755 tests/manual/upload.sh diff --git a/.gitignore b/.gitignore index 96a5f151..e4bf7f46 100644 --- a/.gitignore +++ b/.gitignore @@ -142,6 +142,7 @@ cython_debug/ #config stuff tests/config.json +tests/manual/data #dataset download stuff diff --git a/tests/manual/download.sh b/tests/manual/download.sh new file mode 100755 index 00000000..63a5c93d --- /dev/null +++ b/tests/manual/download.sh @@ -0,0 +1,3 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f voc -l ./data/cultura-pepino-voc + diff --git a/tests/manual/login.sh b/tests/manual/login.sh new file mode 100755 index 00000000..94fc0e38 --- /dev/null +++ b/tests/manual/login.sh @@ -0,0 +1,2 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +python ../../roboflowpy.py login diff --git a/tests/manual/upload.sh b/tests/manual/upload.sh new file mode 100755 index 00000000..56c8b467 --- /dev/null +++ b/tests/manual/upload.sh @@ -0,0 +1,2 @@ +export ROBOFLOW_CONFIG_DIR=./data/.config +python ../../roboflowpy.py upload ./data/cultura-pepino-voc -w wolfodorpythontests-iqu7t -p cultura-pepino-upload-test -f voc From cc2c0be64fbcfc23e08c21b99d7d8fb3bd282971 Mon Sep 17 00:00:00 2001 From: Tony Lampada Date: Wed, 18 Oct 2023 13:47:56 +0000 Subject: [PATCH 3/3] manual tests in bash --- roboflowpy.py | 11 +++++------ tests/manual/debugme.py | 26 ++++++++++++++++++++++++++ tests/manual/download.sh | 16 ++++++++++++++-- tests/manual/upload.sh | 4 +++- tests/manual/useprod | 2 ++ tests/manual/usestaging | 2 ++ 6 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 tests/manual/debugme.py create mode 100644 tests/manual/useprod create mode 100644 tests/manual/usestaging diff --git a/roboflowpy.py b/roboflowpy.py index ff3ca8a0..d63ff5f2 100644 --- a/roboflowpy.py +++ b/roboflowpy.py @@ -21,30 +21,29 @@ def upload(args): project_name=p, ) - -def main(): +def _argparser(): parser = argparse.ArgumentParser(description="main description") subparsers = parser.add_subparsers(title="subcommands") - login_parser = subparsers.add_parser("login", help="Log in to Roboflow") login_parser.set_defaults(func=login) - download_parser = subparsers.add_parser("download", help="Download a dataset version from your workspace or Roboflow Universe.") download_parser.add_argument("datasetUrl", help="Dataset URL (e.g., `roboflow-100/cells-uyemf/2`)") download_parser.add_argument("-f", choices=["coco", "yolov5pytorch", "yolov7pytorch", "my-yolov6", "darknet", "voc", "tfrecord", - "createml", "clip", "multiclass", "coco-segmentation", "yolo5-obb", "png-mask-semantic"], + "createml", "clip", "multiclass", "coco-segmentation", "yolo5-obb", "png-mask-semantic", "yolov8"], help="Specify the format to download the version in (default: interactive prompt)") download_parser.add_argument("-l", help="Location to download the dataset") download_parser.set_defaults(func=download) - upload_parser = subparsers.add_parser("upload", help="Upload a dataset") upload_parser.add_argument("folder", help="filesystem path to a folder that contains your dataset") upload_parser.add_argument("-w", help="workspace url") upload_parser.add_argument("-p", help="Project name") upload_parser.add_argument("-f", choices=["voc", "yolov8", "yolov5"], help="format") upload_parser.set_defaults(func=upload) + return parser +def main(): + parser = _argparser() args = parser.parse_args() if hasattr(args, 'func'): args.func(args) diff --git a/tests/manual/debugme.py b/tests/manual/debugme.py new file mode 100644 index 00000000..138686ac --- /dev/null +++ b/tests/manual/debugme.py @@ -0,0 +1,26 @@ +import sys +import os + +thisdir = os.path.dirname(os.path.abspath(__file__)) +rootdir = os.path.abspath(f"{thisdir}/../..") +os.environ["ROBOFLOW_CONFIG_DIR"] = f"{thisdir}/data/.config" +sys.path.append(rootdir) + +from roboflowpy import _argparser + +if __name__ == "__main__": + parser = _argparser() + args = parser.parse_args(["login"]) + # args = parser.parse_args( + # [ + # "upload", + # "./data/cultura-pepino-voc", + # "-w", + # "wolfodorpythontests", + # "-p", + # "cultura-pepino-upload-test-voc", + # "-f", + # "voc", + # ] + # ) + args.func(args) diff --git a/tests/manual/download.sh b/tests/manual/download.sh index 63a5c93d..0f577901 100755 --- a/tests/manual/download.sh +++ b/tests/manual/download.sh @@ -1,3 +1,15 @@ export ROBOFLOW_CONFIG_DIR=./data/.config -python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f voc -l ./data/cultura-pepino-voc - +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco -l ./data/cultura-pepino-coco +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov5pytorch -l ./data/cultura-pepino-yolov5pytorch +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov7pytorch -l ./data/cultura-pepino-yolov7pytorch +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f my-yolov6 -l ./data/cultura-pepino-my-yolov6 +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f darknet -l ./data/cultura-pepino-darknet +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f voc -l ./data/cultura-pepino-voc +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f tfrecord -l ./data/cultura-pepino-tfrecord +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f createml -l ./data/cultura-pepino-createml +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f clip -l ./data/cultura-pepino-clip +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f multiclass -l ./data/cultura-pepino-multiclass +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco-segmentation -l ./data/cultura-pepino-coco-segmentation +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolo5-obb -l ./data/cultura-pepino-yolo5-obb +python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov8 -l ./data/cultura-pepino-yolov8 +# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f png-mask-semantic -l ./data/cultura-pepino-png-mask-semantic diff --git a/tests/manual/upload.sh b/tests/manual/upload.sh index 56c8b467..7fdfbe55 100755 --- a/tests/manual/upload.sh +++ b/tests/manual/upload.sh @@ -1,2 +1,4 @@ export ROBOFLOW_CONFIG_DIR=./data/.config -python ../../roboflowpy.py upload ./data/cultura-pepino-voc -w wolfodorpythontests-iqu7t -p cultura-pepino-upload-test -f voc +# python ../../roboflowpy.py upload ./data/cultura-pepino-voc -w wolfodorpythontests -p cultura-pepino-upload-test-voc -f voc +python ../../roboflowpy.py upload ./data/cultura-pepino-yolov8 -w wolfodorpythontests -p cultura-pepino-upload-test-yolov8 -f yolov8 +# python ../../roboflowpy.py upload ./data/cultura-pepino-yolov5pytorch -w wolfodorpythontests -p cultura-pepino-upload-test-yolov5 -f yolov5 diff --git a/tests/manual/useprod b/tests/manual/useprod new file mode 100644 index 00000000..9b326535 --- /dev/null +++ b/tests/manual/useprod @@ -0,0 +1,2 @@ +export API_URL=https://api.roboflow.com +export APP_URL=https://app.roboflow.com diff --git a/tests/manual/usestaging b/tests/manual/usestaging new file mode 100644 index 00000000..d9a06980 --- /dev/null +++ b/tests/manual/usestaging @@ -0,0 +1,2 @@ +export API_URL=https://api.roboflow.one +export APP_URL=https://app.roboflow.one