Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 54 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,23 @@
name: Python Checks

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
push:
branches:
- main
tags:
- "*"

concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: "ubuntu-22.04"
python-version: "3.7"
- os: "ubuntu-latest"
python-version: "3.8"
- os: "ubuntu-latest"
python-version: "3.9"
- os: "ubuntu-latest"
python-version: "3.10"
- os: "ubuntu-latest"
Expand All @@ -35,27 +30,60 @@ jobs:
- os: "ubuntu-latest"
python-version: "3.13"
- os: "ubuntu-latest"
python-version: "pypy-3.9"
python-version: "3.14"
- os: "ubuntu-latest"
python-version: "pypy-3.11"

env:
UV_PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up UV
id: setup-uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}

- name: Run tests
run: uv run --frozen --all-extras --group=dev pytest

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
lint:
name: "Lint"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up UV
id: setup-uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0

- name: Run prek
run: uvx prek run --all-files

publish:
name: Publish package to PyPI
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
permissions:
id-token: write
needs:
- tests
- lint
environment:
name: release
url: https://pypi.org/project/simpleflow
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up UV
id: setup-uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0

- name: Install the project
run: uv sync --all-extras --dev
- name: Build wheel & sdist
run: uv build

- name: Test
run: |
uv run ./script/test -v
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
15 changes: 0 additions & 15 deletions .github/workflows/pre-commit.yml

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
=========

!!! note
Starting with 0.35.0, changelog is posted as [GitHub Releases](https://github.com/botify-labs/simpleflow/releases)

0.35.0
------
- Add workflow_task_list parameter to WorkflowTask (#455)
Expand Down
61 changes: 43 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "uv-dynamic-versioning"

[tool.uv-dynamic-versioning]
pattern = "default-unprefixed"

[project]
name = "simpleflow"
description = "Python library for dataflow programming with Amazon SWF"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.10"
license = "MIT"
authors = [
{ name = "Greg Leclercq" },
]
maintainers = [
{ "email" = "tech@botify.com" },
]
authors = [{ name = "Greg Leclercq" }]
maintainers = [{ "email" = "tech@botify.com" }]
keywords = ["simpleflow", "amazon swf", "simple workflow"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dynamic = ["version"]

Expand Down Expand Up @@ -58,6 +58,7 @@ simpleflow = "simpleflow.command:cli"

[tool.ruff]
line-length = 120
unsafe-fixes = true

[tool.ruff.lint]
extend-select = [
Expand All @@ -68,8 +69,7 @@ extend-select = [
"RUF", # ruff
]
allowed-confusables = ["‘", "’"]
extend-ignore = [
]
extend-ignore = []
ignore = ["E501"]

[tool.ruff.lint.isort]
Expand All @@ -80,10 +80,35 @@ exclude_dirs = ["/tests", "/examples", "/venv", "/build"]
skips = ["B404"]

[tool.pytest.ini_options]
addopts = "--doctest-modules --ignore=setup.py --ignore=tasks.py --ignore=docs/ --ignore=build/ --ignore=examples/"
addopts = "-vv -rfE --no-success-flaky-report --doctest-modules --ignore=setup.py --ignore=tasks.py --ignore=docs/ --ignore=build/ --ignore=examples/"
env = [
"PYTHONDONTWRITEBYTECODE=1",
# The AWS_DEFAULT_REGION parameter determines the region used for SWF.
# Leaving it to a value different than "us-east-1" would break moto,
# because moto.swf only mocks calls to us-east-1 region for now.
"AWS_DEFAULT_REGION=us-east-1",
# Disable AWS credentials.
# NB: we set them to wrong values so boto believes they're here, so it
# issues integration requests later caught by VCR. For more information
# see tests/integration/README.md
"AWS_ACCESS_KEY_ID=1234",
"AWS_SECRET_ACCESS_KEY=1234",
# Enable various test optimizations
"SIMPLEFLOW_ENV=test",
"SIMPLEFLOW_CLEANUP_PROCESSES=yes",
# Simple variable to control the number of connection retries
"SWF_CONNECTION_RETRIES=1",
# Don't run real SWF requests if a cassette doesn't match
# See tests/integration/README.md for instructions about cassettes updating
"SIMPLEFLOW_VCR_RECORD_MODE=none",
# Disable jumbo fields
"SIMPLEFLOW_JUMBO_FIELDS_BUCKET=",
# setproctitle segfaults in forked children on macOS (py-setproctitle#165)
"SIMPLEFLOW_DISABLE_SETPROCTITLE=1",
# Prevent CI from overriding boto configuration
"BOTO_CONFIG=/dev/null",
Comment on lines +105 to +109

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this global on purpose: setproctitle segfaults in forked children on macOS (py-setproctitle#165) and gating a static pytest env list by platform is awkward. The only lost coverage is the process-title string in set_process_name, which is minor.

]

[tool.hatch.version]
path = "simpleflow/__init__.py"

[tool.hatch.build]
include = ["/simpleflow"]
Expand All @@ -102,13 +127,13 @@ dev = [
"pytest",
"pytest-xdist>=3.2.0",
"ruff",
"setuptools<72", # See https://github.com/pypa/setuptools/issues/4519
"setuptools<72", # See https://github.com/pypa/setuptools/issues/4519
"sphinx",
"sphinx_rtd_theme",
"sure",
"typing-extensions",
"vcrpy",
"twine",
"pytest-env>=1.0.1",
]

doc = [
Expand Down
2 changes: 1 addition & 1 deletion script/release
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from typing import TYPE_CHECKING
from packaging.version import Version

if TYPE_CHECKING:
from typing import Iterator
from collections.abc import Iterator

VERSION_FILE = "simpleflow/__init__.py"
MAIN_BRANCH = "main"
Expand Down
35 changes: 1 addition & 34 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
#!/bin/bash

export PYTHONDONTWRITEBYTECODE=1

# The AWS_DEFAULT_REGION parameter determines the region used for SWF
# Leaving it to a value different than "us-east-1" would break moto,
# because moto.swf only mocks calls to us-east-1 region for now.
unset AWS_DEFAULT_REGION

# Disable AWS credentials
# NB: we set them to wrong values so boto believes they're here, so it
# issues integration requests later caught by VCR. For more information
# see tests/integration/README.md
export AWS_ACCESS_KEY_ID=1234
export AWS_SECRET_ACCESS_KEY=1234

# Enable various test optimizations
export SIMPLEFLOW_ENV=test
export SIMPLEFLOW_CLEANUP_PROCESSES=yes

# Simple variable to control the number of connection retries
export SWF_CONNECTION_RETRIES=1

# Don't run real SWF requests if a cassette doesn't match
# See tests/integration/README.md for instructions about cassettes updating
export SIMPLEFLOW_VCR_RECORD_MODE=none

# Disable jumbo fields
export SIMPLEFLOW_JUMBO_FIELDS_BUCKET=""

# Prevent CI from overriding boto configuration
export BOTO_CONFIG=/dev/null

PYTHON=${PYTHON:-python}
# run tests
pytest --no-success-flaky-report -q $PYTEST_OPTIONS "$@"
exec pytest "$@"
18 changes: 12 additions & 6 deletions simpleflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from __future__ import annotations

from .activity import Activity # NOQA
from .runtime import logger # NOQA
from .signal import WaitForSignal # NOQA
from .workflow import Workflow # NOQA
from importlib.metadata import PackageNotFoundError, version

__version__ = "0.35.0"
__author__ = "Greg Leclercq"
from .activity import Activity as Activity
from .runtime import logger as logger
from .signal import WaitForSignal as WaitForSignal
from .workflow import Workflow as Workflow

try:
__version__ = version("simpleflow")
except PackageNotFoundError:
# Running from a source checkout without the distribution installed.
__version__ = "unknown"
__author__ = "Greg Leclercq, Yves Bastide"
__license__ = "MIT"
3 changes: 2 additions & 1 deletion simpleflow/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from . import registry, settings

if TYPE_CHECKING:
from typing import Any, Callable
from collections.abc import Callable
from typing import Any


__all__ = [
Expand Down
7 changes: 4 additions & 3 deletions simpleflow/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ def execute(*args, **kwargs):
tmp_dir = env.get(envname)
if tmp_dir:
break
with tempfile.TemporaryFile(dir=tmp_dir) as result_fd, tempfile.TemporaryFile(
dir=tmp_dir, buffering=0
) as error_fd: # TODO when Python 3.7 is dropped: encoding="utf-8", errors="replace"
with (
tempfile.TemporaryFile(dir=tmp_dir) as result_fd,
tempfile.TemporaryFile(dir=tmp_dir, buffering=0) as error_fd,
):
dup_result_fd = os.dup(result_fd.fileno()) # remove FD_CLOEXEC
dup_error_fd = os.dup(error_fd.fileno()) # remove FD_CLOEXEC
arguments_json = format_arguments_json(*args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion simpleflow/history.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import collections
from typing import TYPE_CHECKING, Callable, ClassVar
from collections.abc import Callable
from typing import TYPE_CHECKING, ClassVar

import simpleflow.swf.mapper.models.history
from simpleflow import logger
Expand Down
6 changes: 6 additions & 0 deletions simpleflow/process/_named_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import functools
import os

from setproctitle import setproctitle

Expand Down Expand Up @@ -61,6 +62,11 @@ def state(self, value):
self.set_process_name()

def set_process_name(self):
# setproctitle segfaults when called in a forked child process on macOS
# (see https://github.com/dvarrazzo/py-setproctitle/issues/165). Allow
# disabling it so the test suite doesn't crash spawned workers/deciders.
if os.environ.get("SIMPLEFLOW_DISABLE_SETPROCTITLE"):
return
klass = self.__class__.__name__
properties = []
for prop in getattr(self, "_named_mixin_properties", []):
Expand Down
2 changes: 1 addition & 1 deletion simpleflow/step/submittable.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)

if TYPE_CHECKING:
from typing import Sequence
from collections.abc import Sequence

from simpleflow.base import Submittable
from simpleflow.executor import Executor
Expand Down
2 changes: 1 addition & 1 deletion simpleflow/step/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Sequence
from collections.abc import Sequence


def should_force_step(step_name: str, force_steps: Sequence[str]) -> bool:
Expand Down
Loading