Skip to content

Commit

Permalink
Merge pull request #194 from roboflow/upload-tests
Browse files Browse the repository at this point in the history
Sharpen the axe - shell tests baked in
  • Loading branch information
tonylampada authored Oct 18, 2023
2 parents 62fd093 + cc2c0be commit 0d1527a
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ cython_debug/

#config stuff
tests/config.json
tests/manual/data

#dataset download stuff

Expand Down
54 changes: 54 additions & 0 deletions roboflowpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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 _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", "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)
else:
parser.print_help()

if __name__ == "__main__":
main()
26 changes: 26 additions & 0 deletions tests/manual/debugme.py
Original file line number Diff line number Diff line change
@@ -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)
15 changes: 15 additions & 0 deletions tests/manual/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export ROBOFLOW_CONFIG_DIR=./data/.config
# 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
2 changes: 2 additions & 0 deletions tests/manual/login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export ROBOFLOW_CONFIG_DIR=./data/.config
python ../../roboflowpy.py login
4 changes: 4 additions & 0 deletions tests/manual/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export ROBOFLOW_CONFIG_DIR=./data/.config
# 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
2 changes: 2 additions & 0 deletions tests/manual/useprod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export API_URL=https://api.roboflow.com
export APP_URL=https://app.roboflow.com
2 changes: 2 additions & 0 deletions tests/manual/usestaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export API_URL=https://api.roboflow.one
export APP_URL=https://app.roboflow.one

0 comments on commit 0d1527a

Please sign in to comment.