scaleway-functions-python


Namescaleway-functions-python JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/scaleway/serverless-functions-python
SummaryUtilities for testing your Python handlers for Scaleway Serverless Functions.
upload_time2023-04-27 08:02:04
maintainer
docs_urlNone
authorScaleway Serverless Team
requires_python>=3.8.1,<3.12
licenseMIT
keywords serverless scaleway functions cloud faas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Serverless Functions Python 💜

[![PyPI version](https://badge.fury.io/py/scaleway-functions-python.svg)](https://badge.fury.io/py/scaleway-functions-python)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/scaleway/serverless-functions-python/main.svg)](https://results.pre-commit.ci/latest/github/scaleway/serverless-functions-python/main)
![pre-commit.ci status](https://img.shields.io/badge/python-3.8_|_3.9_|_3.10_|_3.11-blue.svg)

Scaleway Serverless Functions Python is a framework that simplifies Scaleway [Serverless Functions](https://www.scaleway.com/fr/serverless-functions/) local development.
It enables you to debug your function locally and provide the event data format used in Scaleway Serverless Functions.

This library helps you to write functions but for deployment please refer to the documentation.

Get started with Scaleway Functions:

- [Scaleway Serverless Functions Documentation](https://www.scaleway.com/en/docs/serverless/functions/quickstart/)
- [Scaleway Serverless Framework plugin](https://github.com/scaleway/serverless-scaleway-functions)
- [Scaleway Serverless Examples](https://github.com/scaleway/serverless-examples)
- [Scaleway Cloud Provider](https://scaleway.com)

Testing frameworks for Scaleway Serverless Functions in other languages can be found here:

- [Go](https://github.com/scaleway/serverless-functions-go)
- [Node](https://github.com/scaleway/serverless-functions-node)

## ⚙️ Quickstart

You can use `pip` to install the framework:

```console
pip install scaleway-functions-python
```

```python
# handler.py

# Standard entrypoint to a Scaleway serverless function
def handler(event, context):
    if event["httpMethod"] != "GET":
         return {"statusCode": 405, "body": "Invalid method!"}
    return "Hello World!"

if __name__ == "__main__":
    # The import is conditional so that you do not need
    # to package the library when deploying on Scaleway Functions.
    from scaleway_functions_python import local
    local.serve_handler(handler, port=8080)
```

You can then run your function locally:

```console
$ python handler.py
$ curl http://localhost:8080
> Hello World!
$ curl -X POST http://localhost:8080
> Invalid method!
```

## 🚀 Features

This repository aims to provide a better experience on **local testing, utils, and documentation**

### 🏡 Local testing

What this package does:

- **Format Input**: Serverless Functions have a specific input format encapsulating the body received by functions to add some useful data.
  The local testing package lets you interact with the formatted data.
- **Advanced debugging**: To improve developer experience you can run your handler locally and debug it by running your code step-by-step or reading output directly before deploying it.

What this package does not:

- **Simulate performance**: Scaleway FaaS lets you choose different options for CPU/RAM that can have an impact
  on your development. This package does not provide specific limits for your function on local testing but you can profile your application or you can use our metrics available in [Scaleway Console](https://console.scaleway.com/)
  to monitor your application.
- **Deploy functions**: When your function is uploaded we package it in an environment that can be different than yours. Our build pipelines support several dependencies but sometimes require specific system dependencies (especially those related to lib c) that we don't support
  If you have compatibility issues, please see the help section.

### 🧱 Type hints

The framework provides some types hints to make it easier to develop your handler. See this [example](examples/mirror.py) for more information on how to use them.

## ❓ FAQ

**Why do I need an additional package to call my function?**

Your Function Handler can be served by a simple HTTP server but Serverless Ecosystem involves a lot of different layers that will change changes the headers, input and output of your function. This package aims to simulate everything your request will go through to help you debug your application properly.
This library is not mandatory to use Scaleway Serverless Functions.

**How my function will be deployed**

To deploy your function please refer to our official documentation.

**Do I need to deploy my function differently?**

No, this framework does not affect deployment or performance.

## 🎓 Contributing

We welcome all contributions to our open-source projects, please see our [contributing guidelines](./.github/CONTRIBUTING.md).

Do not hesitate to raise issues and pull requests we will have a look at them.

## 📭 Reach Us

We love feedback. Feel free to:

- Open a [Github issue](https://github.com/scaleway/serverless-functions-python/issues/new)
- Send us a message on the [Scaleway Slack community](https://slack.scaleway.com/), in the [#serverless-functions](https://scaleway-community.slack.com/app_redirect?channel=serverless-functions) channel.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/scaleway/serverless-functions-python",
    "name": "scaleway-functions-python",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<3.12",
    "maintainer_email": "",
    "keywords": "serverless,scaleway,functions,cloud,faas",
    "author": "Scaleway Serverless Team",
    "author_email": "opensource@scaleway.com",
    "download_url": "https://files.pythonhosted.org/packages/82/f0/d9d5a2e6128695ae9eda008b18168c80c0421291c6461d4465565fc483a5/scaleway_functions_python-0.2.0.tar.gz",
    "platform": null,
    "description": "# Serverless Functions Python \ud83d\udc9c\n\n[![PyPI version](https://badge.fury.io/py/scaleway-functions-python.svg)](https://badge.fury.io/py/scaleway-functions-python)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/scaleway/serverless-functions-python/main.svg)](https://results.pre-commit.ci/latest/github/scaleway/serverless-functions-python/main)\n![pre-commit.ci status](https://img.shields.io/badge/python-3.8_|_3.9_|_3.10_|_3.11-blue.svg)\n\nScaleway Serverless Functions Python is a framework that simplifies Scaleway [Serverless Functions](https://www.scaleway.com/fr/serverless-functions/) local development.\nIt enables you to debug your function locally and provide the event data format used in Scaleway Serverless Functions.\n\nThis library helps you to write functions but for deployment please refer to the documentation.\n\nGet started with Scaleway Functions:\n\n- [Scaleway Serverless Functions Documentation](https://www.scaleway.com/en/docs/serverless/functions/quickstart/)\n- [Scaleway Serverless Framework plugin](https://github.com/scaleway/serverless-scaleway-functions)\n- [Scaleway Serverless Examples](https://github.com/scaleway/serverless-examples)\n- [Scaleway Cloud Provider](https://scaleway.com)\n\nTesting frameworks for Scaleway Serverless Functions in other languages can be found here:\n\n- [Go](https://github.com/scaleway/serverless-functions-go)\n- [Node](https://github.com/scaleway/serverless-functions-node)\n\n## \u2699\ufe0f Quickstart\n\nYou can use `pip` to install the framework:\n\n```console\npip install scaleway-functions-python\n```\n\n```python\n# handler.py\n\n# Standard entrypoint to a Scaleway serverless function\ndef handler(event, context):\n    if event[\"httpMethod\"] != \"GET\":\n         return {\"statusCode\": 405, \"body\": \"Invalid method!\"}\n    return \"Hello World!\"\n\nif __name__ == \"__main__\":\n    # The import is conditional so that you do not need\n    # to package the library when deploying on Scaleway Functions.\n    from scaleway_functions_python import local\n    local.serve_handler(handler, port=8080)\n```\n\nYou can then run your function locally:\n\n```console\n$ python handler.py\n$ curl http://localhost:8080\n> Hello World!\n$ curl -X POST http://localhost:8080\n> Invalid method!\n```\n\n## \ud83d\ude80 Features\n\nThis repository aims to provide a better experience on **local testing, utils, and documentation**\n\n### \ud83c\udfe1 Local testing\n\nWhat this package does:\n\n- **Format Input**: Serverless Functions have a specific input format encapsulating the body received by functions to add some useful data.\n  The local testing package lets you interact with the formatted data.\n- **Advanced debugging**: To improve developer experience you can run your handler locally and debug it by running your code step-by-step or reading output directly before deploying it.\n\nWhat this package does not:\n\n- **Simulate performance**: Scaleway FaaS lets you choose different options for CPU/RAM that can have an impact\n  on your development. This package does not provide specific limits for your function on local testing but you can profile your application or you can use our metrics available in [Scaleway Console](https://console.scaleway.com/)\n  to monitor your application.\n- **Deploy functions**: When your function is uploaded we package it in an environment that can be different than yours. Our build pipelines support several dependencies but sometimes require specific system dependencies (especially those related to lib c) that we don't support\n  If you have compatibility issues, please see the help section.\n\n### \ud83e\uddf1 Type hints\n\nThe framework provides some types hints to make it easier to develop your handler. See this [example](examples/mirror.py) for more information on how to use them.\n\n## \u2753 FAQ\n\n**Why do I need an additional package to call my function?**\n\nYour Function Handler can be served by a simple HTTP server but Serverless Ecosystem involves a lot of different layers that will change changes the headers, input and output of your function. This package aims to simulate everything your request will go through to help you debug your application properly.\nThis library is not mandatory to use Scaleway Serverless Functions.\n\n**How my function will be deployed**\n\nTo deploy your function please refer to our official documentation.\n\n**Do I need to deploy my function differently?**\n\nNo, this framework does not affect deployment or performance.\n\n## \ud83c\udf93 Contributing\n\nWe welcome all contributions to our open-source projects, please see our [contributing guidelines](./.github/CONTRIBUTING.md).\n\nDo not hesitate to raise issues and pull requests we will have a look at them.\n\n## \ud83d\udced Reach Us\n\nWe love feedback. Feel free to:\n\n- Open a [Github issue](https://github.com/scaleway/serverless-functions-python/issues/new)\n- Send us a message on the [Scaleway Slack community](https://slack.scaleway.com/), in the [#serverless-functions](https://scaleway-community.slack.com/app_redirect?channel=serverless-functions) channel.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Utilities for testing your Python handlers for Scaleway Serverless Functions.",
    "version": "0.2.0",
    "split_keywords": [
        "serverless",
        "scaleway",
        "functions",
        "cloud",
        "faas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7829875729ecad2526a54cb701da5b8d35cff112ac60f8df3ae4c336c3f0d763",
                "md5": "8335e6792242a511d64c8661181a34f5",
                "sha256": "8c069cde434d0b981905f81fcf83404b1c715a475bbdac0005dfcdbd83005fc7"
            },
            "downloads": -1,
            "filename": "scaleway_functions_python-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8335e6792242a511d64c8661181a34f5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<3.12",
            "size": 11207,
            "upload_time": "2023-04-27T08:02:02",
            "upload_time_iso_8601": "2023-04-27T08:02:02.200511Z",
            "url": "https://files.pythonhosted.org/packages/78/29/875729ecad2526a54cb701da5b8d35cff112ac60f8df3ae4c336c3f0d763/scaleway_functions_python-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82f0d9d5a2e6128695ae9eda008b18168c80c0421291c6461d4465565fc483a5",
                "md5": "a2ceb9693933c31f7695823b9bdcac64",
                "sha256": "58248385fd6dabe34a61cfb014d6187f1c2e4c314e2b15275787b6b77c50d804"
            },
            "downloads": -1,
            "filename": "scaleway_functions_python-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a2ceb9693933c31f7695823b9bdcac64",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<3.12",
            "size": 10457,
            "upload_time": "2023-04-27T08:02:04",
            "upload_time_iso_8601": "2023-04-27T08:02:04.375920Z",
            "url": "https://files.pythonhosted.org/packages/82/f0/d9d5a2e6128695ae9eda008b18168c80c0421291c6461d4465565fc483a5/scaleway_functions_python-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-27 08:02:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "scaleway",
    "github_project": "serverless-functions-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "scaleway-functions-python"
}
        
Elapsed time: 0.14948s