File tree Expand file tree Collapse file tree 6 files changed +48
-12
lines changed
Expand file tree Collapse file tree 6 files changed +48
-12
lines changed Original file line number Diff line number Diff line change 1111jobs :
1212 build :
1313
14- runs-on : ubuntu-latest
14+ runs-on : ${{ matrix.os }}
1515 strategy :
1616 matrix :
17+ os : [ubuntu-latest]
1718 python-version : [3.6, 3.7, 3.8]
19+ include :
20+ - python-version : 3.8
21+ push-package : true
22+ - os : windows-latest
23+ python-version : 3.8
24+ - os : macos-latest
25+ python-version : 3.8
1826
1927 steps :
2028 - uses : actions/checkout@v2
@@ -24,25 +32,25 @@ jobs:
2432 python-version : ${{ matrix.python-version }}
2533 - name : Install dependencies
2634 run : |
27- make dev-venv
35+ make dev-venv SYSTEM_PYTHON=python
2836 - name : Lint
2937 run : |
3038 make dev-lint
3139 - name : Test with pytest
3240 run : |
3341 make dev-pytest
3442 - name : Build dist
35- if : matrix.python-version == '3.8'
43+ if : matrix.push-package == true
3644 run : |
3745 make dev-remove-dist dev-build-dist dev-list-dist-contents dev-test-install-dist
3846 - name : Publish distribution to Test PyPI
39- if : matrix.python-version == '3.8'
47+ if : matrix.push-package == true
4048 uses : pypa/gh-action-pypi-publish@master
4149 with :
4250 password : ${{ secrets.test_pypi_password }}
4351 repository_url : https://test.pypi.org/legacy/
4452 - name : Publish distribution to PyPI
45- if : matrix.python-version == '3.8' && startsWith(github.ref, 'refs/tags')
53+ if : matrix.push-package == true && startsWith(github.ref, 'refs/tags')
4654 uses : pypa/gh-action-pypi-publish@master
4755 with :
4856 password : ${{ secrets.pypi_password }}
Original file line number Diff line number Diff line change 11VENV = venv
2- PIP = $(VENV ) /bin/pip
3- PYTHON = $(VENV ) /bin/python
2+
3+ ifeq ($(OS ) ,Windows_NT)
4+ VENV_BIN = $(VENV)/Scripts
5+ else
6+ VENV_BIN = $(VENV)/bin
7+ endif
8+
9+ PYTHON = $(VENV_BIN ) /python
10+ PIP = $(VENV_BIN ) /python -m pip
11+
12+ SYSTEM_PYTHON = python3
413
514VENV_TEMP = venv_temp
615
@@ -30,7 +39,7 @@ venv-clean:
3039
3140
3241venv-create :
33- python3 -m venv $(VENV )
42+ $( SYSTEM_PYTHON ) -m venv $(VENV )
3443
3544
3645dev-install :
Original file line number Diff line number Diff line change 1+ import logging
12from pathlib import Path
23
4+ from tf_bodypix .download import BodyPixModelPaths
35from tf_bodypix .cli import main
46
57
8+ LOGGER = logging .getLogger (__name__ )
9+
10+
611EXAMPLE_IMAGE_URL = (
712 r'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/'
813 r'Person_Of_Interest_-_Panel_%289353656298%29.jpg/'
@@ -69,3 +74,16 @@ def test_should_not_fail_to_replace_background(self, temp_dir: Path):
6974 '--background=%s' % EXAMPLE_IMAGE_URL ,
7075 '--output=%s' % output_image_path
7176 ])
77+
78+ def test_should_list_all_default_model_urls (self , capsys ):
79+ expected_urls = [
80+ value
81+ for key , value in BodyPixModelPaths .__dict__ .items ()
82+ if not key .startswith ('_' )
83+ ]
84+ main (['list-models' ])
85+ captured = capsys .readouterr ()
86+ output_urls = captured .out .splitlines ()
87+ LOGGER .debug ('output_urls: %s' , output_urls )
88+ missing_urls = set (expected_urls ) - set (output_urls )
89+ assert not missing_urls
Original file line number Diff line number Diff line change @@ -253,7 +253,7 @@ def add_arguments(self, parser: argparse.ArgumentParser):
253253 add_common_arguments (parser )
254254 parser .add_argument (
255255 "--storage-url" ,
256- default = "https://storage.googleapis.com/tfjs-models/ " ,
256+ default = "https://storage.googleapis.com/tfjs-models" ,
257257 help = "The base URL for the storage containing the models"
258258 )
259259
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ def download_model(model_path: str) -> str:
7878 for weights_manifest_path in weights_manifest_paths :
7979 local_model_json_path = tf .keras .utils .get_file (
8080 os .path .basename (weights_manifest_path ),
81- os . path . join ( model_base_path , weights_manifest_path ) ,
81+ model_base_path + '/' + weights_manifest_path ,
8282 cache_subdir = cache_subdir ,
8383 )
8484 return local_model_path
Original file line number Diff line number Diff line change 11import logging
22
3- import os
43import urllib .request
54from xml .etree import ElementTree
65from typing import Iterable
1716
1817
1918def iter_s3_file_urls (base_url : str ) -> Iterable [str ]:
19+ if not base_url .endswith ('/' ):
20+ base_url += '/'
2021 marker = None
2122 while True :
2223 current_url = base_url
@@ -29,7 +30,7 @@ def iter_s3_file_urls(base_url: str) -> Iterable[str]:
2930 for item in root .findall (S3_CONTENTS ):
3031 key = item .findtext (S3_KEY )
3132 LOGGER .debug ('key: %s' , key )
32- yield os . path . join ( base_url , key )
33+ yield base_url + key
3334 next_marker = root .findtext (S3_NEXT_MARKER )
3435 if not next_marker or next_marker == marker :
3536 break
You can’t perform that action at this time.
0 commit comments