Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
Add files for initial release with pre-generated model files
Browse files Browse the repository at this point in the history
  • Loading branch information
bbridges committed Aug 3, 2018
1 parent d5c2643 commit 45fc146
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ venv.bak/

# mypy
.mypy_cache/

# target-finder-model files
/target_finder_model/data/

# Output from the create-release.sh script
/release/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

# v0.1.0

Initial release.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = test
51 changes: 51 additions & 0 deletions scripts/create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh -e

cd $(dirname "$0")

graph_file="../target_finder_model/data/graph.pb"
labels_file="../target_finder_model/data/labels.txt"

# Check that the model files exist.
[ -f "$graph_file" ] || (>&2 echo "Missing graph.pb" && exit 1)
[ -f "$labels_file" ] || (>&2 echo "Missing labels.txt" && exit 1)

# Find the version number to release.
version=$(grep -o -e "'.*'" "../target_finder_model/version.py" | tr -d "'")

echo "Detected version ""$version"

tf_stage_dir="../release/staging/target-finder-model"
archive_name="target-finder-model-""$version"".tar.gz"

# Create the staging directory and the target-finder folder.
echo "Staging files"
mkdir -p "$tf_stage_dir"

# Copy over python files.
mkdir -p "$tf_stage_dir""/target_finder_model"
find "../target_finder_model/" -name "*.py" -exec cp "{}" \
"$tf_stage_dir/target_finder_model/" \;

# Copy over the graph and labels.
mkdir -p "$tf_stage_dir""/target_finder_model/data"
cp "$graph_file" "$tf_stage_dir""/target_finder_model/data/"
cp "$labels_file" "$tf_stage_dir""/target_finder_model/data/"

# Copy over configuration and informational files.
cp ../README.md ../LICENSE \
../setup.py "$tf_stage_dir"

# Compress the directory.
echo "Creating archive"

cd "../release/staging"
tar -czvf "$archive_name" "target-finder-model"
mv "$archive_name" ..

echo "\033[32mCreated target-finder-model release" \
"(""$archive_name"")\033[0m"

# Remove the staging directory.
echo "Removing staging files"
cd ..
rm -rf staging
51 changes: 51 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python

import os

try:
from setuptools import setup, find_packages
except:
raise Exception('setuptools is required for installation')


def join(*paths):
"""Join and normalize several paths.
Args:
*paths (List[str]): The paths to join and normalize.
Returns:
str: The normalized path.
"""

return os.path.normpath(os.path.join(*paths))


VERSION_PATH = join(__file__, '..', 'target_finder_model', 'version.py')


def get_version():
"""Get the version number without running version.py.
Returns:
str: The current uavaustin-target-finder version.
"""

with open(VERSION_PATH, 'r') as version:
out = {}

exec(version.read(), out)

return out['__version__']


setup(
name='target-finder-model',
version=get_version(),
author='UAV Austin',
url='https://github.com/uavaustin/target-finder-model',
packages=find_packages(),
package_data={
'target_finder_model': [
'data/graph.pb', 'data/labels.txt'
]
},
license='MIT'
)
11 changes: 11 additions & 0 deletions target_finder_model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Entrypoint for the target_finder_model library.
This module contains the filenames used for target-finder so they can
be encapsulated in a single python library that can be fetched.
"""

from pkg_resources import resource_filename


graph_file = resource_filename(__name__, 'data/graph.pb')
labels_file = resource_filename(__name__, 'data/labels.txt')
1 change: 1 addition & 0 deletions target_finder_model/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
13 changes: 13 additions & 0 deletions test/test_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Testing that the files can be accessed and are non-empty."""

import os

import target_finder_model


def test_graph_file():
assert os.path.getsize(target_finder_model.graph_file) > 0


def test_label_file():
assert os.path.getsize(target_finder_model.labels_file) > 0

0 comments on commit 45fc146

Please sign in to comment.