Add example to CLI and testing
Browse files- .github/workflows/python-publish.yml +11 -4
- scoutbot/scoutbot.py +26 -0
.github/workflows/python-publish.yml
CHANGED
|
@@ -20,7 +20,7 @@ jobs:
|
|
| 20 |
- name: Checkout code
|
| 21 |
uses: nschloe/action-cached-lfs-checkout@v1.1.3
|
| 22 |
with:
|
| 23 |
-
|
| 24 |
|
| 25 |
- uses: actions/setup-python@v2
|
| 26 |
name: Install Python
|
|
@@ -44,7 +44,7 @@ jobs:
|
|
| 44 |
- name: Checkout code
|
| 45 |
uses: nschloe/action-cached-lfs-checkout@v1.1.3
|
| 46 |
with:
|
| 47 |
-
|
| 48 |
|
| 49 |
- uses: actions/setup-python@v2
|
| 50 |
name: Install Python
|
|
@@ -82,8 +82,15 @@ jobs:
|
|
| 82 |
pip install --upgrade pip
|
| 83 |
pip install wheel
|
| 84 |
pip install dist/*.whl
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
upload_pypi:
|
| 89 |
needs: [test_wheel]
|
|
|
|
| 20 |
- name: Checkout code
|
| 21 |
uses: nschloe/action-cached-lfs-checkout@v1.1.3
|
| 22 |
with:
|
| 23 |
+
exclude: "scoutbot/*/models/pytorch/"
|
| 24 |
|
| 25 |
- uses: actions/setup-python@v2
|
| 26 |
name: Install Python
|
|
|
|
| 44 |
- name: Checkout code
|
| 45 |
uses: nschloe/action-cached-lfs-checkout@v1.1.3
|
| 46 |
with:
|
| 47 |
+
exclude: "scoutbot/*/models/pytorch/"
|
| 48 |
|
| 49 |
- uses: actions/setup-python@v2
|
| 50 |
name: Install Python
|
|
|
|
| 82 |
pip install --upgrade pip
|
| 83 |
pip install wheel
|
| 84 |
pip install dist/*.whl
|
| 85 |
+
|
| 86 |
+
- name: Test module
|
| 87 |
+
run: |
|
| 88 |
+
python -c "import scoutbot; scoutbot.fetch(); scoutbot.example();"
|
| 89 |
+
|
| 90 |
+
- name: Test CLI
|
| 91 |
+
run: |
|
| 92 |
+
scoutbot fetch
|
| 93 |
+
scoutbot example
|
| 94 |
|
| 95 |
upload_pypi:
|
| 96 |
needs: [test_wheel]
|
scoutbot/scoutbot.py
CHANGED
|
@@ -7,6 +7,7 @@ import json
|
|
| 7 |
from os.path import exists
|
| 8 |
|
| 9 |
import click
|
|
|
|
| 10 |
import utool as ut
|
| 11 |
|
| 12 |
import scoutbot
|
|
@@ -100,6 +101,30 @@ def fetch():
|
|
| 100 |
scoutbot.fetch()
|
| 101 |
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
@click.group()
|
| 104 |
def cli():
|
| 105 |
"""
|
|
@@ -110,6 +135,7 @@ def cli():
|
|
| 110 |
|
| 111 |
cli.add_command(fetch)
|
| 112 |
cli.add_command(pipeline)
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
if __name__ == '__main__':
|
|
|
|
| 7 |
from os.path import exists
|
| 8 |
|
| 9 |
import click
|
| 10 |
+
import pooch
|
| 11 |
import utool as ut
|
| 12 |
|
| 13 |
import scoutbot
|
|
|
|
| 101 |
scoutbot.fetch()
|
| 102 |
|
| 103 |
|
| 104 |
+
@click.command('example')
|
| 105 |
+
def example():
|
| 106 |
+
"""
|
| 107 |
+
Run a test of the pipeline on an example image
|
| 108 |
+
"""
|
| 109 |
+
TEST_IMAGE = 'scout.example.jpg'
|
| 110 |
+
TEST_IMAGE_HASH = (
|
| 111 |
+
'786a940b062a90961f409539292f09144c3dbdbc6b6faa64c3e764d63d55c988' # NOQA
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
img_filepath = pooch.retrieve(
|
| 115 |
+
url=f'https://wildbookiarepository.azureedge.net/data/{TEST_IMAGE}',
|
| 116 |
+
known_hash=TEST_IMAGE_HASH,
|
| 117 |
+
progressbar=True,
|
| 118 |
+
)
|
| 119 |
+
assert exists(img_filepath)
|
| 120 |
+
|
| 121 |
+
log.info(f'Running pipeline on image: {img_filepath}')
|
| 122 |
+
|
| 123 |
+
detects = scoutbot.pipeline(img_filepath)
|
| 124 |
+
|
| 125 |
+
log.info(ut.repr3(detects))
|
| 126 |
+
|
| 127 |
+
|
| 128 |
@click.group()
|
| 129 |
def cli():
|
| 130 |
"""
|
|
|
|
| 135 |
|
| 136 |
cli.add_command(fetch)
|
| 137 |
cli.add_command(pipeline)
|
| 138 |
+
cli.add_command(example)
|
| 139 |
|
| 140 |
|
| 141 |
if __name__ == '__main__':
|