Skip to main content

Tool for creating nanowire tools with the flask structure.

Project description

This library is designed to allow a python developer to easily create a nanowire plugin using the flask APIs structure.

The function you mount for image plugins, using the function mount_Image_function must have the arguments img and variables if you want initialise a model or other variables when the sever starts you may make the function to be mounted into a function of a class which is initiated with the function mount_Image_function. You should expect img to be a PIL RGB image object and variables to be a dictionary containing the variables sent to the plugin in the curl request.

The function for mounting a text based plugin is similar however it is called mount_text_function and expects the arguments text (a string) and variables.

The curl requests for images may be formatted 2 ways. The first involves sending the image as a file attached to the curl request. For example:

curl -F "image=@./1.jpg" -XPOST http://0.0.0.0:5000/model/predict?threshold=0.5

alternatively the file may be sent as a link using a dictionary eg.

curl -X POST -H "Content-Type:application/json" -d '{"contentUrl":"http://127.0.0.1:8000/1.jpg", "threshold":0.5}' http://0.0.0.0:5000/model/predict

The currently supported image formats are:

  • jpg

  • png

  • bmp

  • tif

  • ppm

The curl request for text is similar to that used for images except that it may take either raw text or a file containing raw text. You may either post a document containing the raw text using the command

curl -F "doc=@./doc1.txt" -XPOST http://0.0.0.0:5000/model/predict?deactivate_ngrams=True

or the raw text can be sent using:

curl -X POST -H "Content-Type:application/json" -d '{"text":"Example text about whichever subject you're interested in", "deactivate_ngrams"="True"}' http://0.0.0.0:5000/model/predict

This library will eventually be expanded to be able to handle video, sound and arbitary files however for now it is limited to text and images.

The API you create will also return maximum memory usage (in MB), maximum cpu usage (in %) and time taken (in seconds) when processing a given API call.

Notes for advanced users

mount_Image_function

Parameters

  • function :- The function to be mounted on the API. The function must take img and variables as arguments when processing images. The function must return a dictionary.

  • host optional:- default is ‘0.0.0.0’. Set the IP address to host the API on.

  • port optional:- default 5000. Set the port to host the API on.

  • path optional:- default ‘/model/predict’. Set the path for the API.

mount_text_function

Parameters * function :- The function to be mounted on the API. The function must take text and variables as arguments when processing text. The function must return a dictionary. * host optional:- default is ‘0.0.0.0’. Set the IP address to host the API on. * port optional:- default 5000. Set the port to host the API on. * path optional:- default ‘/model/predict’. Set the path for the API.

Notes on debug mode

In order to activate debug mode the environmental variable PYTHON_DEBUG must be set to true.

Debug mode will mean that any errors encountered whilst running the function will also give a full traceback of the error in the returned JSON.

Notes on taskID

If the post contains taskID as an argument the taskID given will also be returned in the output JSON.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

nanowire_flask-0.0.82.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanowire_flask-0.0.82-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file nanowire_flask-0.0.82.tar.gz.

File metadata

  • Download URL: nanowire_flask-0.0.82.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15rc1

File hashes

Hashes for nanowire_flask-0.0.82.tar.gz
Algorithm Hash digest
SHA256 97eaf8a8c5ef0a0509b528ffc7c5ee19ba993a91649d8689bdb1f5d95f57c6bb
MD5 95bde6806d007a8e42892da9b1d6b4d6
BLAKE2b-256 3c304401b19d3a04463aeaee05b204f55662b7aab1636c1451c9f11d75216b2c

See more details on using hashes here.

File details

Details for the file nanowire_flask-0.0.82-py3-none-any.whl.

File metadata

  • Download URL: nanowire_flask-0.0.82-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/2.7.15rc1

File hashes

Hashes for nanowire_flask-0.0.82-py3-none-any.whl
Algorithm Hash digest
SHA256 3ca46b42df3482f3763b0aaa6ce30e0277667ea4043bb4e135339c64024385b8
MD5 eb89e15ed5f3af321e52d5dcc25acefc
BLAKE2b-256 8c270894ff423b1ceb97588c274faf4c07f8a1a7e908d2e3434f2ecb13d6a116

See more details on using hashes here.

Supported by

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