Skip to content

Commit 0d1527a

Browse files
authored
Merge pull request #194 from roboflow/upload-tests
Sharpen the axe - shell tests baked in
2 parents 62fd093 + cc2c0be commit 0d1527a

File tree

8 files changed

+106
-0
lines changed

8 files changed

+106
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ cython_debug/
142142

143143
#config stuff
144144
tests/config.json
145+
tests/manual/data
145146

146147
#dataset download stuff
147148

roboflowpy.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import argparse
2+
import roboflow
3+
4+
def login(args):
5+
roboflow.login()
6+
7+
def download(args):
8+
rf = roboflow.Roboflow()
9+
w, p, v = args.datasetUrl.split("/")
10+
format, location = args.f, args.l
11+
project = rf.workspace(w).project(p)
12+
project.version(int(v)).download(format, location=location, overwrite=True)
13+
14+
def upload(args):
15+
rf = roboflow.Roboflow()
16+
f, w, p, folder = args.f, args.w, args.p, args.folder
17+
workspace = rf.workspace(w)
18+
workspace.upload_dataset(
19+
dataset_path=folder,
20+
dataset_format=f,
21+
project_name=p,
22+
)
23+
24+
def _argparser():
25+
parser = argparse.ArgumentParser(description="main description")
26+
subparsers = parser.add_subparsers(title="subcommands")
27+
login_parser = subparsers.add_parser("login", help="Log in to Roboflow")
28+
login_parser.set_defaults(func=login)
29+
download_parser = subparsers.add_parser("download", help="Download a dataset version from your workspace or Roboflow Universe.")
30+
download_parser.add_argument("datasetUrl", help="Dataset URL (e.g., `roboflow-100/cells-uyemf/2`)")
31+
download_parser.add_argument("-f",
32+
choices=["coco", "yolov5pytorch", "yolov7pytorch", "my-yolov6", "darknet", "voc", "tfrecord",
33+
"createml", "clip", "multiclass", "coco-segmentation", "yolo5-obb", "png-mask-semantic", "yolov8"],
34+
help="Specify the format to download the version in (default: interactive prompt)")
35+
download_parser.add_argument("-l", help="Location to download the dataset")
36+
download_parser.set_defaults(func=download)
37+
upload_parser = subparsers.add_parser("upload", help="Upload a dataset")
38+
upload_parser.add_argument("folder", help="filesystem path to a folder that contains your dataset")
39+
upload_parser.add_argument("-w", help="workspace url")
40+
upload_parser.add_argument("-p", help="Project name")
41+
upload_parser.add_argument("-f", choices=["voc", "yolov8", "yolov5"], help="format")
42+
upload_parser.set_defaults(func=upload)
43+
return parser
44+
45+
def main():
46+
parser = _argparser()
47+
args = parser.parse_args()
48+
if hasattr(args, 'func'):
49+
args.func(args)
50+
else:
51+
parser.print_help()
52+
53+
if __name__ == "__main__":
54+
main()

tests/manual/debugme.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
import os
3+
4+
thisdir = os.path.dirname(os.path.abspath(__file__))
5+
rootdir = os.path.abspath(f"{thisdir}/../..")
6+
os.environ["ROBOFLOW_CONFIG_DIR"] = f"{thisdir}/data/.config"
7+
sys.path.append(rootdir)
8+
9+
from roboflowpy import _argparser
10+
11+
if __name__ == "__main__":
12+
parser = _argparser()
13+
args = parser.parse_args(["login"])
14+
# args = parser.parse_args(
15+
# [
16+
# "upload",
17+
# "./data/cultura-pepino-voc",
18+
# "-w",
19+
# "wolfodorpythontests",
20+
# "-p",
21+
# "cultura-pepino-upload-test-voc",
22+
# "-f",
23+
# "voc",
24+
# ]
25+
# )
26+
args.func(args)

tests/manual/download.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export ROBOFLOW_CONFIG_DIR=./data/.config
2+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco -l ./data/cultura-pepino-coco
3+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov5pytorch -l ./data/cultura-pepino-yolov5pytorch
4+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov7pytorch -l ./data/cultura-pepino-yolov7pytorch
5+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f my-yolov6 -l ./data/cultura-pepino-my-yolov6
6+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f darknet -l ./data/cultura-pepino-darknet
7+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f voc -l ./data/cultura-pepino-voc
8+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f tfrecord -l ./data/cultura-pepino-tfrecord
9+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f createml -l ./data/cultura-pepino-createml
10+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f clip -l ./data/cultura-pepino-clip
11+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f multiclass -l ./data/cultura-pepino-multiclass
12+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f coco-segmentation -l ./data/cultura-pepino-coco-segmentation
13+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolo5-obb -l ./data/cultura-pepino-yolo5-obb
14+
python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f yolov8 -l ./data/cultura-pepino-yolov8
15+
# python ../../roboflowpy.py download motusbots/cultura-pepino/2 -f png-mask-semantic -l ./data/cultura-pepino-png-mask-semantic

tests/manual/login.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export ROBOFLOW_CONFIG_DIR=./data/.config
2+
python ../../roboflowpy.py login

tests/manual/upload.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export ROBOFLOW_CONFIG_DIR=./data/.config
2+
# python ../../roboflowpy.py upload ./data/cultura-pepino-voc -w wolfodorpythontests -p cultura-pepino-upload-test-voc -f voc
3+
python ../../roboflowpy.py upload ./data/cultura-pepino-yolov8 -w wolfodorpythontests -p cultura-pepino-upload-test-yolov8 -f yolov8
4+
# python ../../roboflowpy.py upload ./data/cultura-pepino-yolov5pytorch -w wolfodorpythontests -p cultura-pepino-upload-test-yolov5 -f yolov5

tests/manual/useprod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export API_URL=https://api.roboflow.com
2+
export APP_URL=https://app.roboflow.com

tests/manual/usestaging

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export API_URL=https://api.roboflow.one
2+
export APP_URL=https://app.roboflow.one

0 commit comments

Comments
 (0)