Name | pare JSON |
Version |
0.3.2
JSON |
| download |
home_page | None |
Summary | Effortless serverless Python |
upload_time | 2024-08-23 22:42:14 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
python
lambda
aws
serverless
fastapi
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ๐ช Pare
[![version](https://img.shields.io/pypi/v/pare.svg)](https://pypi.Python.org/pypi/pare)
[![license](https://img.shields.io/pypi/l/pare.svg)](https://pypi.Python.org/pypi/pare)
[![python](https://img.shields.io/pypi/pyversions/pare.svg)](https://pypi.Python.org/pypi/pare)
[![ci](https://github.com/gauge-sh/pare/actions/workflows/ci.yml/badge.svg)](https://github.com/gauge-sh/pare/actions/workflows/ci.yml)
[![pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
[![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
Pare is the easiest way to deploy Python Lambdas alongside your primary web application.
[Discord](https://discord.gg/Kz2TnszerR)
![pare_demo](https://github.com/user-attachments/assets/2513eb92-51f3-45c6-9eb3-0b71dafe8a48)
## Why use Pare?
Pare is built to allow web developers to independently scale parts of a web application.
More specifically, Pare is useful if you have functions which are:
- compute intensive
- blocking
- isolated
- parallel
Some examples are **document parsing**, **data aggregation**, **webhook handling** and **image processing**.
With Pare, you can offload these tasks from your main web server, while also getting automatic scaling for concurrent requests.
## Quickstart
```shell
> pip install pare
```
First, mark the function you want to deploy onto a Lambda:
```python
import pare
@pare.endpoint(name="quickstart")
def my_function(*args, **kwargs):
...
```
This will tell Pare to use this function as the Lambda handler.
Calling the function in your code will still execute locally, but the decorator adds additional methods to make calls to the deployed Lambda.
```python
from my_module import my_function
my_function(*args, **kwargs) # local function call
my_function.invoke(*args, **kwargs) # remote Lambda call
await my_function.invoke_async(*args, **kwargs) # async remote Lambda call
```
Next, login with Github to get a Pare API Key:
```shell
> pare login
Please visit: https://github.com/login/device
and enter code: 1111-1111
```
Following the on-screen instructions will authorize Gauge to retrieve your Github username and email for the purposes of account creation. The token has no other permissions.
After logging in, you can run a deploy of your function into the Pare Cloud:
```shell
> pare deploy my_module.py
```
> [!NOTE]
> This generally takes between 3s (when heavily cached) and 60s (no cache, heavy dependencies)
> [!NOTE]
> Make sure you are in a git repository. Pare uses the latest git hash to tag your deploy.
Once the deploy is finished, you can verify with `pare status`:
```shell
> pare status
Deployment Data
โโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโ
โ Name โ Git Hash โ Created At โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ quickstart โ 8a4096b โ 2024-08-19 22:55:51 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโ
```
That's it! Your function is now serverless.
To delete a deployed function, use `pare delete`:
```shell
> pare delete quickstart
```
## Notes on Deployment
The `pare deploy` command accepts a sequence of file patterns (filepaths, directories, or glob paths).
The corresponding files will be collected into a single bundle, which will be built and deployed with each function.
The entrypoint for each function will be defined by `pare.endpoint`, and it is critical that
all of the entrypoint's imports are included in the bundle.
Third party dependencies are bundled
with each function individually, see the section below for more details.
In the future, we plan to use the technology behind [Tach] to automatically determine
the transitive dependencies in your project and create a complete bundle. Reach out on [Discord](https://discord.gg/Kz2TnszerR)
if this is an important feature for you!
## Advanced Usage
### 3rd Party Dependencies
Pare allows installing 3rd party dependencies from PyPI for each deployed function.
Use the `dependencies` kwarg in the `endpoint` decorator to specify the dependencies for a function,
and they will automatically be installed during the deploy.
```python
@pare.endpoint(name="3rd-party-deps", dependencies=["pydantic", ...])
```
The dependency names can specify version numbers as well, just as if they were listed in `requirements.txt`.
```python
@pare.endpoint(name="3rd-party-deps", dependencies=["pydantic==2.8.2", ...])
```
> [!TIP]
> If you want to quickly determine the 3rd party dependencies used by a set of files, consider using [Tach](https://github.com/gauge-sh/tach) with [`tach report-external`](https://docs.gauge.sh/usage/commands#tach-report-external)
### Environment Variables
Pare allows setting environment variables for your functions during the deploy.
Use the `-e` option to set environment variables:
```shell
> pare deploy my_module.py -e MY_VARIABLE=myvalue -e OTHER_VARIABLE=othervalue [...]
```
### Atomic Deployment
Pare supports 'atomic deployment' of services based on a git hash.
When atomic deployment is disabled (the default),
the Pare API will route requests by name to the latest deployed version of your function.
When atomic deployment is enabled, the Pare SDK will include the git hash in its requests to your deployed functions,
and the Pare API will route your request to the service with a matching git hash.
This feature is enabled on the client-side with the environment variable `PARE_ATOMIC_DEPLOYMENT_ENABLED`.
Since your main application likely will not have access to `git` to determine its git hash at runtime,
you will need to set the `PARE_GIT_HASH` environment variable during your build and deployment pipeline.
Raw data
{
"_id": null,
"home_page": null,
"name": "pare",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "python, lambda, aws, serverless, fastapi",
"author": null,
"author_email": "Caelean Barnes <caeleanb@gmail.com>, Evan Doyle <evanmdoyle@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f1/dc/80ddcf3e1e8f144b3f0ebee0b0e1fb72c70b5ca78fd5e35cf2dd9e48ced8/pare-0.3.2.tar.gz",
"platform": null,
"description": "# \ud83d\udd2a Pare\n\n[![version](https://img.shields.io/pypi/v/pare.svg)](https://pypi.Python.org/pypi/pare)\n[![license](https://img.shields.io/pypi/l/pare.svg)](https://pypi.Python.org/pypi/pare)\n[![python](https://img.shields.io/pypi/pyversions/pare.svg)](https://pypi.Python.org/pypi/pare)\n[![ci](https://github.com/gauge-sh/pare/actions/workflows/ci.yml/badge.svg)](https://github.com/gauge-sh/pare/actions/workflows/ci.yml)\n[![pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)\n[![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\nPare is the easiest way to deploy Python Lambdas alongside your primary web application.\n\n[Discord](https://discord.gg/Kz2TnszerR)\n\n![pare_demo](https://github.com/user-attachments/assets/2513eb92-51f3-45c6-9eb3-0b71dafe8a48)\n\n\n## Why use Pare?\n\nPare is built to allow web developers to independently scale parts of a web application.\nMore specifically, Pare is useful if you have functions which are:\n\n- compute intensive\n- blocking\n- isolated\n- parallel\n\nSome examples are **document parsing**, **data aggregation**, **webhook handling** and **image processing**.\n\nWith Pare, you can offload these tasks from your main web server, while also getting automatic scaling for concurrent requests.\n\n## Quickstart\n\n```shell\n> pip install pare\n```\n\nFirst, mark the function you want to deploy onto a Lambda:\n\n```python\nimport pare\n\n@pare.endpoint(name=\"quickstart\")\ndef my_function(*args, **kwargs):\n ...\n```\n\nThis will tell Pare to use this function as the Lambda handler.\n\nCalling the function in your code will still execute locally, but the decorator adds additional methods to make calls to the deployed Lambda.\n\n```python\nfrom my_module import my_function\n\nmy_function(*args, **kwargs) # local function call\n\nmy_function.invoke(*args, **kwargs) # remote Lambda call\n\nawait my_function.invoke_async(*args, **kwargs) # async remote Lambda call\n```\n\n\nNext, login with Github to get a Pare API Key:\n\n```shell\n> pare login\nPlease visit: https://github.com/login/device\nand enter code: 1111-1111\n```\n\nFollowing the on-screen instructions will authorize Gauge to retrieve your Github username and email for the purposes of account creation. The token has no other permissions.\n\nAfter logging in, you can run a deploy of your function into the Pare Cloud:\n\n```shell\n> pare deploy my_module.py\n```\n\n> [!NOTE]\n> This generally takes between 3s (when heavily cached) and 60s (no cache, heavy dependencies)\n\n> [!NOTE]\n> Make sure you are in a git repository. Pare uses the latest git hash to tag your deploy.\n\nOnce the deploy is finished, you can verify with `pare status`:\n\n```shell\n> pare status\n Deployment Data \n\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2533\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n\u2503 Name \u2503 Git Hash \u2503 Created At \u2503\n\u2521\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2547\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2529\n\u2502 quickstart \u2502 8a4096b \u2502 2024-08-19 22:55:51 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n\nThat's it! Your function is now serverless.\n\n\nTo delete a deployed function, use `pare delete`:\n\n```shell\n> pare delete quickstart\n```\n\n\n## Notes on Deployment\n\nThe `pare deploy` command accepts a sequence of file patterns (filepaths, directories, or glob paths).\nThe corresponding files will be collected into a single bundle, which will be built and deployed with each function.\n\nThe entrypoint for each function will be defined by `pare.endpoint`, and it is critical that\nall of the entrypoint's imports are included in the bundle.\n\nThird party dependencies are bundled\nwith each function individually, see the section below for more details.\n\nIn the future, we plan to use the technology behind [Tach] to automatically determine\nthe transitive dependencies in your project and create a complete bundle. Reach out on [Discord](https://discord.gg/Kz2TnszerR)\nif this is an important feature for you!\n\n\n## Advanced Usage\n\n\n### 3rd Party Dependencies\n\nPare allows installing 3rd party dependencies from PyPI for each deployed function.\n\nUse the `dependencies` kwarg in the `endpoint` decorator to specify the dependencies for a function,\nand they will automatically be installed during the deploy.\n\n```python\n@pare.endpoint(name=\"3rd-party-deps\", dependencies=[\"pydantic\", ...])\n```\n\nThe dependency names can specify version numbers as well, just as if they were listed in `requirements.txt`.\n\n```python\n@pare.endpoint(name=\"3rd-party-deps\", dependencies=[\"pydantic==2.8.2\", ...])\n```\n\n> [!TIP]\n> If you want to quickly determine the 3rd party dependencies used by a set of files, consider using [Tach](https://github.com/gauge-sh/tach) with [`tach report-external`](https://docs.gauge.sh/usage/commands#tach-report-external)\n\n### Environment Variables\n\nPare allows setting environment variables for your functions during the deploy.\n\nUse the `-e` option to set environment variables:\n\n```shell\n> pare deploy my_module.py -e MY_VARIABLE=myvalue -e OTHER_VARIABLE=othervalue [...]\n```\n\n\n### Atomic Deployment\n\nPare supports 'atomic deployment' of services based on a git hash.\n\nWhen atomic deployment is disabled (the default),\nthe Pare API will route requests by name to the latest deployed version of your function.\n\nWhen atomic deployment is enabled, the Pare SDK will include the git hash in its requests to your deployed functions,\nand the Pare API will route your request to the service with a matching git hash.\n\nThis feature is enabled on the client-side with the environment variable `PARE_ATOMIC_DEPLOYMENT_ENABLED`.\n\nSince your main application likely will not have access to `git` to determine its git hash at runtime,\nyou will need to set the `PARE_GIT_HASH` environment variable during your build and deployment pipeline.\n",
"bugtrack_url": null,
"license": null,
"summary": "Effortless serverless Python",
"version": "0.3.2",
"project_urls": {
"Homepage": "https://github.com/gauge-sh/pare",
"Issues": "https://github.com/gauge-sh/pare/issues"
},
"split_keywords": [
"python",
" lambda",
" aws",
" serverless",
" fastapi"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8b08febdea638b596c0529ffff80697f3f0c730dbb59378ccc65cf1b14162e92",
"md5": "e717cd8898e53a6bfd6179f3e732ba31",
"sha256": "d304bab760c24d749248faca0ce78ff19e4faf461d1e5ffc96d21b6bad820375"
},
"downloads": -1,
"filename": "pare-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e717cd8898e53a6bfd6179f3e732ba31",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 18965,
"upload_time": "2024-08-23T22:42:11",
"upload_time_iso_8601": "2024-08-23T22:42:11.681785Z",
"url": "https://files.pythonhosted.org/packages/8b/08/febdea638b596c0529ffff80697f3f0c730dbb59378ccc65cf1b14162e92/pare-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f1dc80ddcf3e1e8f144b3f0ebee0b0e1fb72c70b5ca78fd5e35cf2dd9e48ced8",
"md5": "b479a0bd46aaabf5f24f53dc312ada33",
"sha256": "5e381415bbd8c5d23196cbd494627864a926ba6d8f6fa80041fcd189cced9d80"
},
"downloads": -1,
"filename": "pare-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "b479a0bd46aaabf5f24f53dc312ada33",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 17886,
"upload_time": "2024-08-23T22:42:14",
"upload_time_iso_8601": "2024-08-23T22:42:14.442298Z",
"url": "https://files.pythonhosted.org/packages/f1/dc/80ddcf3e1e8f144b3f0ebee0b0e1fb72c70b5ca78fd5e35cf2dd9e48ced8/pare-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-23 22:42:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gauge-sh",
"github_project": "pare",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pare"
}