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. -
Piper
, this is the transformation engine, it can be use to transform data directly, mainly for development and testing purpose.
Both above classes support UDF 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.
UDF in Python
The UDF is implemented as a 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 arguments are always in 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.
- The return value must be in above types.
- The UDF function may raise any exception, the returned value will be recorded as an error.
- Any operation with error as the input will result in an error as the output.
- 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.
Lookup Data Source 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 values for the requested fields.
async def lookup(key: Any, fields: List[str]):
...
return [some_data[f] for f in fields]
It must be added to the Piper
or PiperService
before it can be used in the pipeline:
piper = Piper(pipeline_def, {"lookup_name": lookup_function})
or
svc = PiperService(pipeline_def, {"lookup_name": lookup_function})
Then you can use the lookup data source in the pipeline:
pipeline_name(...)
| ...
| lookup 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.
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.3.0-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43ea5855778847b383018cae7c7cca7f37ca594deafeed164ec52571b3d37030 |
|
MD5 | 8c92d31d6340224667ff16f375acb1c0 |
|
BLAKE2b-256 | 109a82853a98783743643514769b35b16e08b7527b8f14610d9aaf4d85a1c0cf |
Hashes for feathrpiper-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d32eab1f88ef0c794e8ee983fed109ca4fb0fc59f27a6550b4037be671b2bf5 |
|
MD5 | 0a6668c45d532880437534d816645c3d |
|
BLAKE2b-256 | 77bc209df708cb3f0d53d648208c34fbe350371a813af3707fc7b79319d4c4f5 |
Hashes for feathrpiper-0.3.0-cp311-cp311-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33865e17b061ccdfb82bfaf740bc81a4b19b72010ee5cb062c5128b2b936058e |
|
MD5 | 03b1c8080b5f506f8ec02a3ee0f86b0d |
|
BLAKE2b-256 | 8ea6c036f3158df768c9d0ad592bc3ff81b03aa2009077996f3d874ad9793ef4 |
Hashes for feathrpiper-0.3.0-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91f584528fbaacb5f0c8acc98147c08f8cbb15cadb2e2373b2585cbb7cc1536a |
|
MD5 | f5e54d158d34b166b93513f9f3fc3934 |
|
BLAKE2b-256 | 3443d6a198f7df12562e34eedb95886ff7be13bdbcf03a8c013f95b017467666 |
Hashes for feathrpiper-0.3.0-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dda4f94b6d2468b9d5362ae1131652aab85419692aabfadac5ae1d3aa4d154fa |
|
MD5 | 92d4a73d1d8488e57defad853f9ec63a |
|
BLAKE2b-256 | beb8624349af5d681c070ae2930b4204100ca0afe965fee44ead384903b7cf97 |
Hashes for feathrpiper-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcb2d30f3f655307830502d51473f960633f012bbeebf657a5586167ba13e09c |
|
MD5 | c8c62c5ef38841fe8d0c6cde4ce124ba |
|
BLAKE2b-256 | 5ca15a66e438b50cb47b957a05345948d4a5a900e4d7e0dd78670e91fa9031f5 |
Hashes for feathrpiper-0.3.0-cp310-cp310-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230b4ea4409dc3880b1c658d2d2a728884cd166d847dc83723089a47c4de5d84 |
|
MD5 | ebb2eaef25db94ab74d8c515599b13d9 |
|
BLAKE2b-256 | 576ebdb4645938992c9872c10ad2309283313f772ef26ac86bb5d1eabc2623ba |
Hashes for feathrpiper-0.3.0-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19cf5114df7157b012991d0729e1536d26326a95747afa1322d49aad6cb565d5 |
|
MD5 | 9311f4f74a9431a1fef4f24867afe195 |
|
BLAKE2b-256 | a28ec066b307eebe0556a2cd9942543240263e280ca9ab25f87140b3909c6fdc |
Hashes for feathrpiper-0.3.0-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae751c88489060d46fe14ebc6315d6d50c08d241aa950f681611017ecd7102c0 |
|
MD5 | a347e0651a30ec9abf5c35563f5931a9 |
|
BLAKE2b-256 | 6cf432b9de5a30f92c23e77c07927ed0a4718e28c57779c0aab827f37ae44ff2 |
Hashes for feathrpiper-0.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2943c01487a2d8582ea20d55dd4c00ad874494e924edede84858affe71224782 |
|
MD5 | 9582d615ac1c2397e8566ea6cb699e1b |
|
BLAKE2b-256 | 788a8a50482fc17e5581554cb1d0d0fb588be9fd4d7bd73d40952a0860088a34 |
Hashes for feathrpiper-0.3.0-cp39-cp39-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3d24d8099a442a62fecbfd8e82ee0f0327f0274d83f3c6cf91a0dbe8a284fa7 |
|
MD5 | b52f8c9ad390db996a0082f849ceee73 |
|
BLAKE2b-256 | f17cc8fa42cb42bb75bab6c365f41788abdb23c7a9c73801f9fe941e9e9ab1a6 |
Hashes for feathrpiper-0.3.0-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd9872e0e35cde16d2c30200af559304366ac45f440cc80fe525b0c09adf4558 |
|
MD5 | f687d7740a4be4a801ca62879aebb166 |
|
BLAKE2b-256 | d05dde2f3dca6fe8efd1ab78bd3ba98eb965e5af1903ba9557414c70c6e2fa65 |
Hashes for feathrpiper-0.3.0-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7adbaeda22e5e9c395866d92f011f5b759939c3d9b1c3dc33e6e7dc143f07b67 |
|
MD5 | 25db623dd7674cb31f4febaf4b8e0202 |
|
BLAKE2b-256 | 2ddd41afae7bd4c511c0d2773f25fa43b61814f3257b7113e4ab41e3f797449a |
Hashes for feathrpiper-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 227402a61a4debe6c1591096b7fec1aba561c593a2691a9e620913f801f5ed88 |
|
MD5 | 1a7a6cc3a6230f4f72baea815e72a7df |
|
BLAKE2b-256 | eabf70ec7f113c7268949c58e2c36dd696f13edd567fcc8591d354642c385ef5 |
Hashes for feathrpiper-0.3.0-cp38-cp38-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08f23b05ba90d25e6fccc7e0964abe3f95dac04c272ba21a74e0091cbf20709a |
|
MD5 | 415d415e14dcd57f3f82e1f53df81cf5 |
|
BLAKE2b-256 | f7f77c31a65d501cca8f07a0a5be76524424bc1582f539d86a61cf29fd712fa4 |
Hashes for feathrpiper-0.3.0-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e87e88cb47603cf8f0f8985db494d9ca3d59a3a7922acc3b855a154995bfddd4 |
|
MD5 | 532b338c331ad52181cda56519526fbc |
|
BLAKE2b-256 | 4cb2a6773ed38f6443c9bf6a367c9b80bb3a4f566cd471fbab3df6b9cda21c61 |
Hashes for feathrpiper-0.3.0-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f87898171952555e760874814068c1d7dabef1f0aca0b4230b55011d593dd588 |
|
MD5 | 5cff43e13592d8b6ec4444d5ce7794a5 |
|
BLAKE2b-256 | c4c00854fa7af0af79fe5b7a587b46487bc57c6de4dc92420b1bdcf2d738ef59 |
Hashes for feathrpiper-0.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f2808449f6e3bf08b4347c2ba8058e48c0a793cb8f9d95f29a3949a2646165 |
|
MD5 | a4a5d48e7dc854f1444f065eb1e080d0 |
|
BLAKE2b-256 | 60c545c145202a49adb82cf66ca618290a32150d97c964535c5a27616800cead |
Hashes for feathrpiper-0.3.0-cp37-cp37m-macosx_10_9_x86_64.macosx_10_9_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca4ef8da6bf24a3bd988551093d7255e6c17ad8274fe032ef35c82de557c381e |
|
MD5 | 2b0e820a842c1b881f7d5c4a8e38e2a6 |
|
BLAKE2b-256 | b3e4f7fec283621eca25f599454e7b98855e310cea19a34d78b7ff358b0ea286 |
Hashes for feathrpiper-0.3.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea63da4719af91525a3755771cc657b1d176fa0e58935a6c28127eff160028e |
|
MD5 | d1c343b92efa41bbd20f4516ec3902e0 |
|
BLAKE2b-256 | 8d39630b48d7c408b8ed760b790ba271a1841c40417699a1feb206c1c4fc9d75 |