Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: scaleway/serverless-functions-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.0
Choose a base ref
...
head repository: scaleway/serverless-functions-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.2.1
Choose a head ref
Loading
8 changes: 6 additions & 2 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
---
name: Set up poetry

description: Install poetry and python dependencies

inputs:
groups:
description: "Poetry dependencies groups."
required: true
python-version:
description: "Python version."
required: true

runs:
using: "composite"
steps:
@@ -29,9 +33,9 @@ runs:
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-${{ inputs.groups }}
key: venv-${{ inputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry dependencies
shell: bash
run: poetry install --no-interaction --no-root --only main,${{ inputs.groups }}
run: poetry install --no-interaction --no-root --only ${{ inputs.groups }}
if: steps.cache-deps.outputs.cache-hit != 'true'
8 changes: 4 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -14,22 +14,22 @@ jobs:
test:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up Poetry
uses: ./.github/actions/setup-poetry
with:
groups: test
groups: main,test
python-version: ${{ matrix.python-version }}

- name: Print versions
13 changes: 6 additions & 7 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

name: python-publish

on:
@@ -13,19 +12,19 @@ jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up python 3.11
- name: Set up python 3.12
id: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.12"

- name: Set up Poetry
uses: ./.github/actions/setup-poetry
with:
groups: '' # will only install the main group
python-version: '3.11'
groups: main
python-version: "3.12"

- name: Publish package
run: poetry publish --build
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -9,25 +9,25 @@ default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.2.0
rev: v3.3.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 24.4.2
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
@@ -40,7 +40,7 @@ repos:
types: [python]
args: [-rn, -sn, --rcfile=pyproject.toml]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.1.0
hooks:
- id: flake8
args: [--config=.flake8]
@@ -51,15 +51,15 @@ repos:
additional_dependencies:
- tomli # for reading config from pyproject.toml
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.10.1
hooks:
- id: mypy
exclude: "^tests/" # See: https://github.com/pre-commit/mirrors-mypy/issues/1
args: [--ignore-missing-imports] # Needed because pre-commit runs mypy in a venv
additional_dependencies:
- typing_extensions
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.9
hooks:
- id: bandit
args: [--skip, B101, --recursive, clumper]
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -28,3 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added a simple server to test with multiple handlers

## [0.2.1] - 2024-07-15

### Fixed

- Returning a base64 encoded response would not be decoded by the framework
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -94,6 +94,18 @@ To deploy your function please refer to our official documentation.

No, this framework does not affect deployment or performance.

**How can I use my packaged dependencies?**

When deploying Python functions, your dependencies must be bundled in a `package` folder at the root of your project. For local testing, you can set `PYTHONPATH=$(pwd)/package` to make your dependencies available. This can be useful to avoid packaging your dependencies in multiple locations.

Please note that this does not work for native dependencies as the Scaleway Python runtime is different from your local machine.

**Why are my logs not showing up when using the print function?**

By default, stdout is buffered in Python, so calling `print` without `flush=True` can lead to missing logs when running locally.
If you experience this issue, you can export the environment variable `PYTHONUNBUFFERED` with `export PYTHONUNBUFFERED=1`.
This will flush stdout on every print call.

## 🎓 Contributing

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