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 rows that each row is a list that aligns with the requested fields, or an empty list when lookup failed.
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],
]
It 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 built support of SqlServer/AzureSQL and Sqlite3, you can use them directly without implementing your own lookup function.
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.3.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 support plain HTTP only, and it doesn't support any kind of authentication. - The
feathrpiper
support 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 x86_64
- macOS x86_64
- macOS aarch64
- 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.1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c689d8557cc5a7d78de405b001d7faa89c948ee271bf294ddf7246c9d3272ef1 |
|
MD5 | 0961d2d17ae57c2b5039178cb5ac66a5 |
|
BLAKE2b-256 | 9cea375b6cc57c55fcfd06a2be17ae713ff7591defe399fa88d3e8c3081cb56e |
Hashes for feathrpiper-0.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83eb5c85af894e2cd67b56a75f373ff85b9063f01a41a6b56f997c160208d4a0 |
|
MD5 | 63eb2eedd2d98a00a358572d0f82ff18 |
|
BLAKE2b-256 | 3c24a7f2f5cc9da20e9ae6241326a4ce5826cbadd2e950957341d1053577a338 |
Hashes for feathrpiper-0.4.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32fad857bfa1650a32c1089e6adff38f312b534105ad5faa0985904e3f1cfb98 |
|
MD5 | 1c43a61eaaa41c08aa6bcd3eeb6ef66a |
|
BLAKE2b-256 | 61f4188ac55bb2c3e5ff1de1b4d27fa9a75c71ef27543bda2d8c0d7b0d92a885 |
Hashes for feathrpiper-0.4.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0147baf467797cca5d3bbf3e0ae9a3aa0a2965da1fe7a3a45827b5f9f7c2b0bb |
|
MD5 | c0e64485047b1ab62fd0b13ea23e46f8 |
|
BLAKE2b-256 | dd19db2f0932cdca7b783ac6c7a68583f857090ce79227a084e2b6c7127780e9 |
Hashes for feathrpiper-0.4.1-cp311-cp311-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 725b5de5c74d81e7fde9fbb127d4f8e0cf1b396e43676e153c37f783132c5c52 |
|
MD5 | 4c8f6aa151a5e5043b090a7008286a36 |
|
BLAKE2b-256 | a7558c09f008214ebbe38a3e5e6634e527a3b6207ff9fa28a253965e4a6ff63c |
Hashes for feathrpiper-0.4.1-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b31a8af87b010190ed747ec8804a674224310dde2d96102eeb3c19bd212ab4 |
|
MD5 | ece0dac60fe855bbc1578f40b49e46eb |
|
BLAKE2b-256 | 65a4485aa7fc584080e57e2bb5f7bb72441df739a5f34426e52ebe14c1254ff1 |
Hashes for feathrpiper-0.4.1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18c12ee3644806969e3a5780fd97c0d7a66aeffbdcf26acc8b1cb8e625922f5e |
|
MD5 | 2e0bbf445b490b6597779565e7c79a54 |
|
BLAKE2b-256 | 334dbc4577fc88a57f385935db02f1022d47038df16846ffc984170a274d8dd6 |
Hashes for feathrpiper-0.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80ca83053c68024bdab2716aa159535a67bc943fef5a5906a19985924466ba1a |
|
MD5 | 1fda9b1838c0c22f70ad5ef03fc9c8dc |
|
BLAKE2b-256 | 3e3a5cc8efdcb8097de7e9c3c8fcb55db4d6a5336cf9322a6b83f37cf8152817 |
Hashes for feathrpiper-0.4.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 263f1a8ec4ee2da20216f801bfd73f46cf68402b24f2c325820f02aabcb3b823 |
|
MD5 | 625822a05fa84ee67c781ab172fc3341 |
|
BLAKE2b-256 | d9bbc46fda6757f1a363622f321e7cd092af647289f5f1470c8a94f679be8308 |
Hashes for feathrpiper-0.4.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14d0e33222658d4124feb72a85f270a4087228050d89df2993b15b84d765f16f |
|
MD5 | 1a470bd4f3392bb9ba24177c441f1afd |
|
BLAKE2b-256 | 9f206e2a42e8a81960f4169ca8006ad3dcf2ca03af0b64793f9d754c88778e52 |
Hashes for feathrpiper-0.4.1-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ac33159db3a500e1848cbe3fd188f0cfb0fd28e860616df1baa00b1da749542 |
|
MD5 | 4d471f4255e48b7d2d5d2186a5842dd5 |
|
BLAKE2b-256 | 8dbf693c3e9109641d4483b67e5546de91d09b1c90ad255aa0ba5f329b2512a0 |
Hashes for feathrpiper-0.4.1-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c87eed945b3a040f95d0a519cbb80ac6285720eae38e8c3401af80f245aa14f1 |
|
MD5 | a9d42affc61ac00ebdb7808e215f305a |
|
BLAKE2b-256 | 7d603314d8ef5be5e545538a4ea900277e6f4a171e813f1c54dc3546acc7b422 |
Hashes for feathrpiper-0.4.1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8158ac5446279b472e6a100f9648b5d4e2ce9bcd0c510af91d56b6ef1ca5b0fe |
|
MD5 | f3a15bb440f2cef5acccca942f0b55ef |
|
BLAKE2b-256 | 980292859a58af28165c79d338f65e99511401966dd16cdf56c83655fa4cfd0f |
Hashes for feathrpiper-0.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d276f64c2ddac1f43ff2918071d65e0085683478f579dc52081b3591b3dc14a |
|
MD5 | 05d8cbbff214da8c3cb75f025f78a6ce |
|
BLAKE2b-256 | ec0e7ebc8fb1cf7c0702b2b063745c5f3bb0e285857fdb3324f63e5f8b731082 |
Hashes for feathrpiper-0.4.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4641f474406e3cb2c6aa66d1f760137b8bea57ef5e54f98932cbe49681bd5e18 |
|
MD5 | 80e5a8316184949985f2267f2efb7470 |
|
BLAKE2b-256 | 5b4f6b74bffc38bcdd8702357a7de290ca93c4efcfee124eb5663adbab04924d |
Hashes for feathrpiper-0.4.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5dc9b7542c45450fe8d4a93cd063b42368fac65008df92523a0f0a8d6b3e1e6 |
|
MD5 | 322f770265dd76396ff628f265c4fdae |
|
BLAKE2b-256 | de9196c71fdfdacac0d0d1a6800cdde78ca5d16167d438727220f6e0eb1b1b5a |
Hashes for feathrpiper-0.4.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b2a84eaea7153611b7e47e2ac6e2e740d7fef46e51d9242003e611f8bff5ad7 |
|
MD5 | 182a5cc8bddcbfa2e6010ebae157caed |
|
BLAKE2b-256 | fe8f18b5380854d39d54543b9d8a027d249fa9961e01cd9d9698f18b1f6b5e87 |
Hashes for feathrpiper-0.4.1-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37ffe0ca4b7c8e1a1072787236dbb189da8377d40659998f3c9d2886ec308514 |
|
MD5 | 614965843adae6aff2b7519397899c85 |
|
BLAKE2b-256 | 68722aa7bb1cb6f3e281c7ca9f445cdf43eace3cd7b9be7254e8e4ab25ee035a |
Hashes for feathrpiper-0.4.1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cda58f0bba6d4dfe399d89b33ce094c844e5e4b5105397939676922f6ca27434 |
|
MD5 | da0c2ea8f4d6a546bcceb91fcccac61d |
|
BLAKE2b-256 | 8cf5fd9a6d0b0fc40f894496d35a12eb6d270e41d55fb77b03419f8beed2e5e4 |
Hashes for feathrpiper-0.4.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4ac20b6a81cabc8d24c5f4e7e31c685543e4b501d888830fa045657c5fee940 |
|
MD5 | d9ea37350df1483b4bb717bbd6de2088 |
|
BLAKE2b-256 | 523b4548e4dbc6cffd72561c3230050baba11dc9fa41dd99d105de4d59e29f32 |
Hashes for feathrpiper-0.4.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c961916008ba4eb763c0391c3f3ebf5b535fd7010c2e77bea084d53f1849d7c0 |
|
MD5 | 2a88119fb50de362d120a413c535a3ba |
|
BLAKE2b-256 | 77de0b9ad41640045c6d52b44c93e2d9681d61b860dd526324865bc17e89784c |
Hashes for feathrpiper-0.4.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28310fa18a4db7c3d708387b496a0b61f359a2e0e2780e98da4b2c179ad38d6d |
|
MD5 | 1934ec01b2eb9f2ebeb93a782664d7fa |
|
BLAKE2b-256 | 87e9e12b1ec89d19797c4907efc072171cee6642429596d12c19cffee851ebca |
Hashes for feathrpiper-0.4.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fea73c4a4d936ad3889dd2755d90b8b205d24776b03a3e47815b69c1e76e2daa |
|
MD5 | 4dc2152a4bdad113d2bd7e3c7026a040 |
|
BLAKE2b-256 | 63ca1609b5225cf99fe1710299a2a2b07e7c11827c0c6d0f9a35e68d9b73ec38 |
Hashes for feathrpiper-0.4.1-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad81b6c40c3cfbdc3d7ebff7ad8fa5e21f6ebd427254fb98cd7a90fb5e2d4d2d |
|
MD5 | d629498c5c537da7899c764a74db181f |
|
BLAKE2b-256 | 5fd4f0fd12ae6fcfb43db1b55142d5fe87b68e88a551c88dfa8b330baa41e845 |
Hashes for feathrpiper-0.4.1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ee8942bd38326756d24b874107dde95a51c00db3e86b472bb276d992104875b |
|
MD5 | c8c18741e41e4d20e94c48b5a653962c |
|
BLAKE2b-256 | ec5c5b2b9ea9310e0e46923b768819c2d809025389392ed7fc286c4aa714d04f |
Hashes for feathrpiper-0.4.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b54119b9e457927fa36ef6104c710611e8224f0f7ed99b4d02caffa42cb0b0a4 |
|
MD5 | 94e3922cb41c7515dbca90a6a98be6ef |
|
BLAKE2b-256 | c83af10a7b13a2ad50c0c73b09cdc55dcf4a840e201c7f4f7926347513509c44 |
Hashes for feathrpiper-0.4.1-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 849e6ea98bffdf5664a54b45428eb374b59f9356eaa3e263f41053d1d8c4a76f |
|
MD5 | 29e304aa8fb25a40e609698f5b39993d |
|
BLAKE2b-256 | c503ac8808e37f8610e3738ca4c5e55e0ee47e251edb20938df81c2ebab34cb3 |
Hashes for feathrpiper-0.4.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c778cd0b401a23761c91aad2175ae84b0f6859a19fa435d30457cd23a8ebdd08 |
|
MD5 | ef0d4b76df7d15cf6806f0a7b3e36fc7 |
|
BLAKE2b-256 | b02b0f156b060ffac46331f9f19009694138aba1abd36a584abe86cfd0180c9e |
Hashes for feathrpiper-0.4.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0669b0712532a5d52ff2254449a5ce21d6aaf072a15fcf7632dc6c651ddf2dfa |
|
MD5 | 257df684ba8ec357c00a38465dc7e59a |
|
BLAKE2b-256 | 40f0914fb3a165d551e6750630f3d01139b08ead0c029acd2757707be70eb3dd |
Hashes for feathrpiper-0.4.1-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 042039da72d31ff09c9508c9369247177ba0f018dcc087cb203cd970911b817e |
|
MD5 | 6cf5912807e732aaec3d41b1e0948cc2 |
|
BLAKE2b-256 | 2258fa337601b49c29dd335af3abe79071e829148f3dbd50cef37d0b000f8e19 |