No project description provided
Project description
README
This is the Python wrapper of the Feathr online transformation service.
There are 2 major classes in this package:
-
PiperService
, this is the service class, it is used to start a HTTP service to handle the transformation requests. It doesn't support HTTPS and authentication, so you may need to setup gateway or proxy to handle the security issues. ThePiperService
class has astart
method to start the HTTP service in blocking mode, andstart_async
method to start the service in theasync
context. -
Piper
, this is the transformation engine, it can be use to transform data directly, mainly for development and testing purpose. ThePiper
class has aprocess
method to transform data in blocking mode, andprocess_async
method to transform data in theasync
context.
Both above classes support UDF and UDLF written in Python.
NOTE: Because of the GIL, pure Python code cannot run concurrently, that means using Python UDF could slow down the transformation service, especially on heavy load.
Value Types
All values passed to the pipeline must be in one of the following types:
None
- Simple types:
bool
,int
,float
,str
- Date/time is represented as
datetime.DateTime
. - List: List of supported types.
- Map: Map of supported types, keys must be string, and value can be any supported type.
All values returned by the pipeline will also be in above types.
NOTE: When using Python big integer, exception will be thrown if any it exceeds the range of 64-bit signed integer.
User Defined Function (UDF) in Python
The UDF is implemented as ordinary Python function, and it must be registered to the service before it can be used in the pipeline.
- The UDF function can only accept positional arguments, keyword arguments are not supported.
- The UDF function must be able to be invoked by the usage in the DSL script, i.e. a UDF with 2 fixed arguments and 1 optional argument can be invoked as
udf(1, 2)
orudf(1, 2, 3)
, but notudf(1, 2, 3, 4)
orudf(1)
. - The UDF function may raise any exception, and the returned value will be record as an error. This error will be propagated to the caller.
- Every function and operator that takes error as the input will return the error.
- At the final output stage of the pipeline, the error value will be converted to
None
, and the error will be recorded in a separated error list. - The UDF function will never see the error as the input, the invocation is bypassed before the UDF function is called if any of the argument is error.
- The execution order is non-deterministic, so the UDF function shall not make any assumptions.
- The UDF function should not block, such behavior is not strictly forbidden but the performance will be impacted significantly.
User Defined Lookup Function (UDLF) in Python
Usually lookup
is to fetch external data, such as a database or a web service, so the lookup data source is implemented as a Python async functions, and it must be registered to the piper or the service before it can be used in the pipeline.
The lookup function is called with a single key and a list of requested field names, and it should return a list of rows that each row is a list that aligns with the requested fields, or an empty list when lookup failed. The key must be in the supported simple types, list and dict cannot be used as key, and using None
as the key will get None
as the value of all returned fields without actually calling the lookup function.
async def my_fancy_lookup_function(key: Any, fields: List[str]) -> List[List[Any]]:
...
return [
[some_data[f] for f in fields],
[some_other_data[f] for f in fields],
]
The lookup function must be added to the Piper
or PiperService
before it can be used in the pipeline:
piper = Piper(pipeline_def, {"lookup_name": my_fancy_lookup_function}, ...)
or
svc = PiperService(pipeline_def, {"lookup_name": my_fancy_lookup_function}, ...)
Then you can use the lookup data source in the pipeline in a lookup
transformation:
pipeline_name(...)
| ...
| lookup field1, field2 from lookup_name on key
| ...
;
or a join
transformation:
pipeline_name(...)
| ...
| join kind=left-inner field1, field2 from lookup_name on key
| ...
;
Once the user-defined lookup function is used, the Piper
and PiperService
must be used in async
context, otherwise all async function will never be executed and the program may hang forever.
Also you need to replace process
with process_async
, and start
with start_async
.
piper = Piper(pipeline_def, {"lookup_name": lookup_function})
async def test():
await piper.process_async(...)
asyncio.run(test())
For more information about Python async programming, please refer to Python Asyncio.
NOTE:
- Because of the asynchronous nature of the lookup function, it's recommended to use
asyncio
compatible libraries to implement the lookup function, traditional blocking libraries may cause the performance issue, e.g. useaiohttp
orHTTPX
instead ofRequests
. - This package only supports
asyncio
,Twisted
orGevent
based libraries are not supported. - In order to lookup data from a standard JSON-based HTTP API, you can use builtin HTTP client instead of implementing your own lookup function, register the lookup data source either in a JSON string or a
dict
with correct content, detailed doc is at here. - The
feathrpiper
also has builtin support of SqlServer/AzureSQL, Sqlite3, and Azure CosmosDb.
Integration with Other Web-Service Frameworks
The feathrpiper
contains built-in web service, but it doesn't support HTTPS and authentication, and has a specific HTTP API spec which cannot be changed from the Python side. In case you need to use it in any other scenario, you may integrate it with other Web service frameworks.
- Flask: prefer to use async version of Flask, such as Flask-Async, Flask-RESTful-Async, Flask-RESTX-Async, etc. And you should use
process_async
to process the request. - FastAPI: FastAPI is fully async-based, use
process_async
to process the request. - Any other Web framework that doesn't support async: You can use
process
in non-async context, but the user-defined lookup function feature will be unavailable.
Packaging and Deployment
The feathrpiper
package is a standard Python package without external dependency, you need to write your own code using the package to implement your own transformation service.
The packaging and the deployment process is also standard, refer to the official document if you need to build Docker image, currently we don't have any pre-built Docker image for the Python package.
In most cases, the packaging process could be like:
- Prepare the
requirements.txt
file which includes thefeathrpiper
package and all the other dependencies.# This package feathrpiper >= 0.4.1 # Any other dependencies pandas == 1.5.2 pytorch >= 1.0.0 ...
- Prepare a
Dockerfile
file which includes therequirements.txt
file and the code to run the service.FROM python:3.9-slim-buster COPY requirements.txt /tmp/ RUN pip install -r /tmp/requirements.txt COPY . /app WORKDIR /app # In case you want to use the built-in web service provided by `PiperService` class and it's listening at the port 8000 # Or you write your own web service and it's listening at the port 8000 EXPOSE 8000 CMD ["python", "main.py"]
- Build the Docker image:
docker build -t my_image .
- Run the Docker image:
docker run -p 8000:8000 my_image
Building from Source
The feathrpiper
package is written in Rust, so you need to setup the Rust toolchain to build it from source. The Rust toolchain can be installed from here. The development is done in Rust 1.65, older version may not work.
- Install
maturin
:pip install maturin
- Build the package under the
feathrpiper_root/python
directory:maturin build --release
More information about maturin
can be found here. Please note that running cargo build
in the top level directory won't build the Python package because the python package project is excluded from the workspace for some technical issues.
Limitations and Known Issues
- The
PiperService
class supports plain HTTP only, and it doesn't support any kind of authentication. - The
feathrpiper
supports Python 3.7~3.11, no support for Python 3.6 or earlier, and no support for Python 2. - The package published on PyPI only support following platforms:
- Linux arm64
- Linux armv7
- Linux x86_64
- macOS x86_64/AppleSilicon universal
- Windows x86_64
You need to build the package from source if you need to use it on other platforms.
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
Built Distributions
Hashes for feathrpiper-0.4.2-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c157ddcae4168256b1b46ad9501b603b714c47fae4dcd938a45195708536981 |
|
MD5 | efcdac0e34f485741e2d8e7463300fd7 |
|
BLAKE2b-256 | be5f3812793439dd0cf6cb189d253b80291012d535eaa4189f871ebdca102093 |
Hashes for feathrpiper-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbe8e1afd10f66e271168a7c73026dd228be564d2bd211e8fb1714b66a058fc8 |
|
MD5 | de4324c82addf7151e0a4044f98b825b |
|
BLAKE2b-256 | a19b37aee46215339f0be6c4d8724311c1f2b4b0f87c51c9b9a8e0093457ccff |
Hashes for feathrpiper-0.4.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1e9237af51806defc24ea02d693a8d2abd79b2a12329fb9afc166d0b7466b81 |
|
MD5 | c36f7cf82417ca1201114de1e092b0ff |
|
BLAKE2b-256 | 4990fa1015525a64f4397ef666f7675c22a5956da614756461a82321dc6ae38b |
Hashes for feathrpiper-0.4.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 266821e54373a0e41e6268d0e98a459e580c63be8a4c4bba7c7b4173b5a19546 |
|
MD5 | ed5ae1bb3d1cf09677fa094dfbc74835 |
|
BLAKE2b-256 | a3605772304d91879047f719c6b8fd37b8c5d2d83c8fd95cad76a94bfaf0f1e9 |
Hashes for feathrpiper-0.4.2-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2aa024da1fa345dc2995cd3cc1ed074ed2b145b494011555d325664ecbf2c2c |
|
MD5 | 68784de45a66a36507408e5cb28fa1c7 |
|
BLAKE2b-256 | 2e76314123121a74f235ae8cda1300417f636d423e40ed9f444a050936a3aea8 |
Hashes for feathrpiper-0.4.2-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c6640c348a13a848c5731d1e461646d567213d5569841760a2520ccad20a729 |
|
MD5 | e9bd6fa887c9778647cb1bd60c2bc834 |
|
BLAKE2b-256 | 28eb48c5c527f37b8d51b53bfe9fc0b7b17e2329eb64bd17819b40b0390c404e |
Hashes for feathrpiper-0.4.2-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9cc9456ed9b48d7d316034a38cb890b816111b0e9b6b9dba45899416a8cc4d9 |
|
MD5 | 5fd8bef429970c3c46f6728c1b8f72bc |
|
BLAKE2b-256 | fdeeb6bc1dcdf856d8ebe8394c328e1612788a7923dbeae7715ffc4c7deb677e |
Hashes for feathrpiper-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cef67d6524f63288a821373a562a21963ee97eae50c9b87417d10274669f61d7 |
|
MD5 | ea305e56c764d0e533dd1c15b22efb3a |
|
BLAKE2b-256 | 65175feae35599de0e1dffe508b485f612317e7541c469a53badb2caf4a1c429 |
Hashes for feathrpiper-0.4.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bc661620c58dbeac0a93bad48a695f9dc65e8a1052db039c6662a192e64584d |
|
MD5 | bc64c8a9e1665a6fbf28a2a313b2c3e8 |
|
BLAKE2b-256 | d8d36e7709919bd65f85064e65ffb7940f57cd499476c89e20db903cc5cd0cda |
Hashes for feathrpiper-0.4.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 289c4507d1be7a887c0c895ac1175ec7d74c4d0802e630caa59c9c45ebb4de58 |
|
MD5 | d753d345fab5b752f13fb27758aac1e5 |
|
BLAKE2b-256 | 64244a8ad43aaed1fa405825a24b4f3bbbff3bff7985e6f65387afab9273b9bc |
Hashes for feathrpiper-0.4.2-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4564106598b5f818e56179be077b3a866fbd95cb4a78b396d2384792e00755a8 |
|
MD5 | c8bf08d9cf4b95a6330f5ed2448a3359 |
|
BLAKE2b-256 | e5016829cdb0a64f413bbc19b47af2445d72bd34c40cf0db0f7387672dea7f19 |
Hashes for feathrpiper-0.4.2-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 475014ee9ba788906f28f3b15c4429a5f5f4503df437e4dbcdb0cc29bb092461 |
|
MD5 | 2e8d5aeae13a230f4ff5bf7dd028604c |
|
BLAKE2b-256 | ce1967b0b2708fc2e8c62ddf1375956a005c582de1f181c9a4fe3f718e4caea5 |
Hashes for feathrpiper-0.4.2-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01e79e897c4c81c60ccae927846d7c3c0695db3b17f0deb1554f05597fc7fdee |
|
MD5 | 950f589f7b8180a4a5665b7a33157ec7 |
|
BLAKE2b-256 | 0e8088eaef3b778d832c9b38a769da76484d467d0abfe37b88229bf28d31bea8 |
Hashes for feathrpiper-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa3fc689995d34e970edc66fe92218a2ee8773fbb5bb9761251f516debaeca4e |
|
MD5 | 1462a8d9e0ea8c98df4792055866c831 |
|
BLAKE2b-256 | 970b1d0e3b431a8e5afe4b66c72ec6d2aa6ff459ce408f27134d1b5f147627a7 |
Hashes for feathrpiper-0.4.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72a50a794e77806c55444cf7cacec27d0160454d26514d1cf6d0f435cad41b95 |
|
MD5 | db7568d156273c6b028b378e9f8ee109 |
|
BLAKE2b-256 | 9ab5c1135ea96b72f20e39b804d75219ab64092409f30ebc8f703d5fb01e6dc8 |
Hashes for feathrpiper-0.4.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3768004becf73724e63299b7c67857028712478acb7dd8fa73f004ae9e77227 |
|
MD5 | 24736885a021ec6744352a66aa632733 |
|
BLAKE2b-256 | c54b257e52c69947a59354d6c5cd3ff22a62ada219cc76179d5fb45185c14924 |
Hashes for feathrpiper-0.4.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd8e14a7f4d1220889696914a616e99866f5c4e96dd181d25c899d4f4e54b09f |
|
MD5 | fd605b3adbfbd2e48e91b1a4f2b66519 |
|
BLAKE2b-256 | f2093774ff463f714d2d09351064deea00e515ab16fd610b6b86d4581a2c41c1 |
Hashes for feathrpiper-0.4.2-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee94b1a05a54b0af7f36bf9287aefc1de2cb309ee6af97676a7aec9eac24bab2 |
|
MD5 | f985ea07c158dbd9577854d3dd30593f |
|
BLAKE2b-256 | a9b3313124ff6e03259bdb0d39f21067f487c2301cc4dac7a52b86e5bcf90c8a |
Hashes for feathrpiper-0.4.2-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8350b387d17449055d8029975b26bb7bfc8d9b46424553057dca1c5516426e34 |
|
MD5 | a093338aa39f2ee37d63223e11cf5f7f |
|
BLAKE2b-256 | 15fe3085bc86709d371664572dc72d918f6ec572e2acac607d92ef8446edee32 |
Hashes for feathrpiper-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9acc6ee29f4e234519e6fc5d691f1f29dedd09fd0a4809e7c47737b10cf9dac7 |
|
MD5 | 1f25ab1312578c2fe99adee724c95b89 |
|
BLAKE2b-256 | ef7f26ddb8789b9cd20d6a6ac7f0d79e932dc1a41d89a4bc074a37906a23859d |
Hashes for feathrpiper-0.4.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdcfc58ddcbd39acb3c13b0a276cfc1c86be78a5a877b965d87982735e22d778 |
|
MD5 | f100b736d4822d750b6c0c517797ec2c |
|
BLAKE2b-256 | 34a1591471fb28f7c0a8432f3964fd288b4abdaf22e2795d241d223a491358e9 |
Hashes for feathrpiper-0.4.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82591d3f21dcf071db06e7637e14f1c3f0d6d95366eee0edde89d6a3426b3dae |
|
MD5 | 001f26e1049381c27dd803f879143ebb |
|
BLAKE2b-256 | eed78ebf430270d3016387f0a1b6a2c9fc4418d5f31752da4d345386baf09e6e |
Hashes for feathrpiper-0.4.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce86e130b4c0edc1ef71e18bb844d1a9e8156487b6d24fe1cc2d8dadf9e29943 |
|
MD5 | 555d9303c1724be6ea63be93d5a8d6c6 |
|
BLAKE2b-256 | 9748362f41618a8d9dfce6bb7f8b5b4a1aab89a2b37d25634706ae816aa1aff9 |
Hashes for feathrpiper-0.4.2-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77c9a25d1edee45c33145b3b6f792312c988b26636c67f5623c823371d0d7a78 |
|
MD5 | 926df555d408599384a17d5a21380644 |
|
BLAKE2b-256 | 80bb2f663686053202c25896566c00a3957bbce4f25c3dce972dc670bedb9662 |
Hashes for feathrpiper-0.4.2-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff3461d0c0971f2d309354da0c06ae8db225bb5c93447db84d17bd974d71d9b |
|
MD5 | d0689813a3ff9003c3c62ae0d7aafdfe |
|
BLAKE2b-256 | d2128ccc14b26a0af3368be5f1cb5a830c4cd0af40c6b6fb81cc673736d0383c |
Hashes for feathrpiper-0.4.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f0a42f12f78478690f9babba096fcdd8e25264af9d4c05e031366170ce2ed7c |
|
MD5 | 5b60388cb70bb57e8bb3b3307bf54c86 |
|
BLAKE2b-256 | 818076a5c729ef6e65de5cd4262e80f04c5a02edd83d0e0c44118059373a320c |
Hashes for feathrpiper-0.4.2-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 086efd8cb6a24062f9fca38886cec733358197817e504ed1da6bc2aa550f0684 |
|
MD5 | 973b538624f70775c189b6a6bc92b5dd |
|
BLAKE2b-256 | 274403af99cdf645c2802d52cb3c382c01004a15169b67a21f011745ef6ad19a |
Hashes for feathrpiper-0.4.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f54b471b8caef251200cfc755cb2868f81f4b519f212a1790236ecfbf3c71124 |
|
MD5 | b9ad63d18563a9d2c7a9f79c1b2434b4 |
|
BLAKE2b-256 | 9a59801a911a93f4e1e43f6d289506942ecd81f272768205d0701cf49bfc95de |
Hashes for feathrpiper-0.4.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dcbfa5f8962a487e8319abc52805df46ded29340fb19130426ceabef9f5d379 |
|
MD5 | 40f952643860a0d3a44cecdb329909c2 |
|
BLAKE2b-256 | 5f3d6b2397a4047cdb6e130e1f0c1e617a279471f0d78af990c9c97597ee2c45 |
Hashes for feathrpiper-0.4.2-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e4884c570b54e81f32b2004ec7999252adace6cb29e529a674c84d223627a65 |
|
MD5 | 43400de1780a1d49e927d380c37bc9fb |
|
BLAKE2b-256 | 28921db3603187878d9159ef7918b4d127b8040a29ba18d7dfa1affe8f4baf72 |