Skip to main content

Bundle models for use with TensorIO

Project description

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

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 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)

  2. 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

Instructions

Simply run:

./test.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tensorio_bundler-0.3.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

tensorio_bundler-0.3.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file tensorio_bundler-0.3.2.tar.gz.

File metadata

  • Download URL: tensorio_bundler-0.3.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tensorio_bundler-0.3.2.tar.gz
Algorithm Hash digest
SHA256 b31756e143350a2b2e60c3c279bf8b8d4a645e404620b18f0701025fac7d7708
MD5 ed86a24057b24090445f8b1f44c3a942
BLAKE2b-256 f65c2d0b37b070b81f3659cade8685dda40f0c808ae1c6f2dff5b1c38dc97509

See more details on using hashes here.

File details

Details for the file tensorio_bundler-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: tensorio_bundler-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tensorio_bundler-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 586cce9158c6de301c69657b9a6f94b73316890d25893ce3953ee1acdbf2ff3a
MD5 82921c07f5dfc82c5d22ce9cdfaf870d
BLAKE2b-256 cda0e59b78c9ee999cf514a98fe38077feaa2dc0688cc10af4bd502f2e105033

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page