Metadata-Version: 2.1
Name: tensorio-bundler
Version: 0.3.0
Summary: Bundle models for use with TensorIO
Home-page: https://github.com/doc-ai/tensorio-bundler
Author: Doc.ai
Author-email: neeraj@doc.ai
License: Apache License 2.0
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
Requires-Dist: absl-py (~=0.7.1)
Requires-Dist: astor (~=0.7.1)
Requires-Dist: astroid (~=2.1.0)
Requires-Dist: bleach (~=3.1.0)
Requires-Dist: certifi (~=2018.11.29)
Requires-Dist: chardet (~=3.0.4)
Requires-Dist: docutils (~=0.14)
Requires-Dist: falcon (~=1.4.1)
Requires-Dist: gast (~=0.2.2)
Requires-Dist: grpcio (~=1.18.0)
Requires-Dist: gunicorn (~=19.9.0)
Requires-Dist: h5py (~=2.9.0)
Requires-Dist: idna (~=2.8)
Requires-Dist: isort (~=4.3.20)
Requires-Dist: Keras-Applications (~=1.0.7)
Requires-Dist: Keras-Preprocessing (~=1.0.9)
Requires-Dist: lazy-object-proxy (~=1.3.1)
Requires-Dist: Markdown (~=3.0.1)
Requires-Dist: mccabe (~=0.6.1)
Requires-Dist: numpy (~=1.16.4)
Requires-Dist: pkginfo (~=1.5.0.1)
Requires-Dist: protobuf (~=3.6.1)
Requires-Dist: Pygments (~=2.3.1)
Requires-Dist: pylint (~=2.2.3)
Requires-Dist: python-mimeparse (~=1.6.0)
Requires-Dist: readme-renderer (~=24.0)
Requires-Dist: requests (~=2.21.0)
Requires-Dist: requests-toolbelt (~=0.9.1)
Requires-Dist: six (~=1.12.0)
Requires-Dist: slack-invoker (~=0.1.4)
Requires-Dist: slackclient (~=1.3.1)
Requires-Dist: tensorboard (~=1.12.2)
Requires-Dist: tensorflow (~=1.12.2)
Requires-Dist: termcolor (~=1.1.0)
Requires-Dist: tqdm (~=4.30.0)
Requires-Dist: twine (~=1.12.1)
Requires-Dist: typed-ast (~=1.1.2)
Requires-Dist: urllib3 (~=1.24.3)
Requires-Dist: webencodings (~=0.5.1)
Requires-Dist: websocket-client (~=0.54.0)
Requires-Dist: Werkzeug (~=0.14.1)
Requires-Dist: wrapt (~=1.10.11)

# tensorio-bundler
Create TensorIO model bundles


## Running the bundler from the command line

NOTE: Working on making a PyPI package. Once that is done, these instructions will change
to use whatever binary the corresponding `pip install` produces.

### Requirements
+ Python 3

### Instructions
The `tensorio_bundler` module comes with a `bundler` utility that you can use to create TensorIO
zipped tiobundle files directly from your command line.

For more information on how to run the `bundler`, run:
```
python -m tensorio_bundler.bundler -h
```

A sample invocation (using test data, assumed to be run from project root -- same directory as this
README):
```
python -m tensorio_bundler.bundler \
    --tflite-model ./tensorio_bundler/fixtures/test.tflite \
    --model-json ./tensorio_bundler/fixtures/test.tiobundle/model.json \
    --assets-dir ./tensorio_bundler/fixtures/test.tiobundle/assets \
    --bundle-name sample.tiobundle \
    --outfile sample.tiobundle.zip
```


## Calling the bundler locally through the REST API

To run the REST API locally from project root (same directory as this README):
```
gunicorn tensorio_bundler.rest:api
```

In a separate terminal window, you can invoke the bundler as follows:
```
TFLITE_PATH="\"$(mktemp -d)/model.tflite\""

read -r -d '' REQUEST_BODY <<-EOF
    {
        "saved_model_dir": "./tensorio_bundler/fixtures/test-model",
        "build": true,
        "tflite_path": $TFLITE_PATH,
        "model_json_path": "./tensorio_bundler/fixtures/test.tiobundle/model.json",
        "assets_path": "./tensorio_bundler/fixtures/test.tiobundle/assets",
        "bundle_name": "curl-test.tiobundle",
        "bundle_output_path": "curl-test.tiobundle.zip"
    }
EOF

curl -v -X POST \
    -H "Content-Type: application/json" \
    -d "$REQUEST_BODY" \
    http://localhost:8000/bundle
```


## Running the bundler via docker

### Requirements
+ Docker

If you don't have it, [get it](https://docs.docker.com/install/linux/docker-ce/ubuntu/)

### Instructions
You can either bind mount the paths to the inputs into your docker container when you run the
bundler or you can bind mount in a service account credentials file and set the
`GOOGLE_APPLICATION_CREDENTIALS` environment variable to point at the mount path in the container.

NOTE: These instructions are extremely sparse at the moment. They will not be so forever.


## TensorIO Models repositories

The TensorIO bundler is now integrated with [tensorio-models](https://github.com/doc-ai/tensorio-models)
via the Repository REST API. Once a bundle has been built, you can use the
`tensorio_bundler.bundler.register_bundle` method to register it against a TensorIO Models
repository. The `tensorio_bundler.bundler` CLI allows you to do this automatically through the
`--repository-path` argument.

This requires two environment variables to be set in your environment:

1. `REPOSITORY` -- a URL for a TensorIO models repository API URL (e.g. https://tio-models-test.dev.docai.beer/rest/v1/repository)

1. `REPISITORY_API_KEY` -- a basic auth token used to authenticate requests against the repository
REST API.

## Running tests if you want to contribute to this project

### Requirements
+ Docker

If you don't have it, [get it](https://docs.docker.com/install/linux/docker-ce/ubuntu/)

### Instructions
Simply run:
```
./test.sh
```


