Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into swf-typed
Browse files Browse the repository at this point in the history
  • Loading branch information
EpicWink committed Nov 21, 2024
2 parents 8732ed7 + 7664674 commit 984e497
Show file tree
Hide file tree
Showing 24 changed files with 136 additions and 80 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Editor code-style configuration

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 88
trim_trailing_whitespace = true

[*.py]
indent_size = 4
12 changes: 5 additions & 7 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olegtarasov/[email protected]
id: get-tag
- uses: actions/checkout@v4
- name: Build image
run: docker build . -t epicwink/seddy:${{ steps.get-tag.outputs.tag }}
run: docker build . -t epicwink/seddy:${{ github.ref_name }}
- name: Login to DockerHub
run: >
echo ${{ secrets.DOCKERHUB_PASSWORD }}
| docker login --password-stdin -u epicwink
- name: Publish image
run: docker push epicwink/seddy:${{ steps.get-tag.outputs.tag }}
run: docker push epicwink/seddy:${{ github.ref_name }}
- name: Check tag
id: check-tag
run: |
if [[ ${{ steps.get-tag.outputs.tag }} =~ ^v\d+\.\d+\.\d+$ ]]; then
if [[ "${{ github.ref_name }}" =~ '^v\d+\.\d+\.\d+$' ]]; then
echo ::set-output name=match::true
fi
- name: Publish latest image
if: steps.check-tag.outputs.match == 'true'
run: |
docker tag epicwink/seddy:${{ steps.get-tag.outputs.tag }} epicwink/seddy:latest
docker tag epicwink/seddy:${{ github.ref_name }} epicwink/seddy:latest
docker push epicwink/seddy:latest
18 changes: 9 additions & 9 deletions .github/workflows/publish-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ on:
jobs:
release:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/seddy
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
- name: Update pip
run: pip install -U pip
- name: Build package
run: |
apt-get update && apt-get install -y git
pip install build
python -m build --sdist --wheel .
python -m build --outdir dist .
- name: Publish package
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install twine
twine upload dist/*
uses: pypa/gh-action-pypi-publish@release/v1
22 changes: 16 additions & 6 deletions .github/workflows/test-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
include:
- os: ubuntu-20.04
python-version: '3.6'
- os: ubuntu-22.04
python-version: '3.7'

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
Expand All @@ -29,15 +36,18 @@ jobs:
run: |
apt-get update && apt-get install -y git
pip --no-cache-dir install .
- name: Install dev requirements
run: pip install -r dev.requirements.txt
- name: Lint with black
run: |
pip install black
black --check src/
- name: Lint imports with isort
run: isort --check src/
- name: Test with pytest
run: |
pip install -r tests/requirements.txt
pytest -vvra --cov seddy --cov-report xml --cov-report term
- name: Upload coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
13 changes: 9 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Thanks for wanting to help out!

## Environment installation
```bash
pip3 install -e .
pip3 install -r tests/requirements.txt
python -m pip install -e . -r ./tests/requirements.txt -r ./dev.requirements.txt
```

## Testing
Expand All @@ -14,8 +13,14 @@ pytest --cov seddy

## Style-guide
Follow [PEP-8](https://www.python.org/dev/peps/pep-0008/?), hanging-indent style, with 4
spaces for indentation, 88-character lines. Lint with [`black`](
https://black.readthedocs.io/en/stable/)
spaces for indentation, 88-character lines. Format with [`black`](
https://black.readthedocs.io/en/stable/) and sort imports with [`isort`](
https://pycqa.github.io/isort/)

```shell
python -m black ./src
python -m isort ./src ./tests
```

## TODO
See the [issues page](https://github.com/EpicWink/seddy/issues) for the current
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ https://github.com/EpicWink/seddy/actions?query=branch%3Amaster+workflow%3Atest)
https://codecov.io/gh/EpicWink/seddy)
[![Documentation Status](https://readthedocs.org/projects/seddy/badge/?version=latest)](
https://seddy.readthedocs.io/en/latest/?badge=latest)
[![PyPI - Version](https://img.shields.io/pypi/v/seddy?logo=pypi)](
https://pypi.org/project/seddy/)

Multi-workflow SWF decider and workflow management service.

Expand Down
2 changes: 2 additions & 0 deletions dev.requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black ~= 22.0
isort ~= 5.0
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
build-backend = "setuptools.build_meta"
requires = [
"setuptools >= 42",
"wheel",
"setuptools-scm[toml] >= 3.4",
]

[tool.setuptools_scm]

[tool.isort]
length_sort_straight = true
profile = "black"
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ long_description = file: README.md
long_description_content_type = text/markdown
keywords = swf, decider
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3 :: Only
Natural Language :: English
Operating System :: POSIX :: Linux
Operating System :: Microsoft :: Windows
Topic :: Software Development
Topic :: System :: Distributed Computing
Typing :: Typed

[options]
install_requires =
boto3
swf-typed ~= 1.0
dataclasses; python_version < "3.7"
importlib-metadata; python_version < "3.8"
packages = find:
package_dir =
=src
Expand Down
18 changes: 10 additions & 8 deletions src/seddy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"WORKFLOW",
]

from ._specs import ChildPolicy
from ._specs import Registration
from ._specs import DecisionsBuilder
from ._specs import Workflow
from ._specs import DAGBuilder
from ._specs import DAGWorkflow
from ._specs import load_workflows
from ._specs import WORKFLOW
from ._specs import (
WORKFLOW,
ChildPolicy,
DAGBuilder,
DAGWorkflow,
DecisionsBuilder,
Registration,
Workflow,
load_workflows,
)
19 changes: 12 additions & 7 deletions src/seddy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@
import pathlib
import argparse

import pkg_resources

try:
from pythonjsonlogger import jsonlogger
except ImportError as e: # pragma: no cover
jsonlogger = e

try:
version = pkg_resources.get_distribution("seddy").version
except pkg_resources.DistributionNotFound: # pragma: no cover
version = None


def run_app(args: argparse.Namespace):
"""Run application from parsed command-line arguments."""
Expand All @@ -36,6 +29,18 @@ def run_app(args: argparse.Namespace):

def build_parser() -> argparse.ArgumentParser:
"""Build command-line argument parser."""

try:
import importlib.metadata as importlib_metadata
except ImportError:
# noinspection PyUnresolvedReferences
import importlib_metadata

try:
version = importlib_metadata.version("seddy")
except importlib_metadata.PackageNotFoundError:
version = None

parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument(
"-v", "--verbose", action="count", default=0, help="increase logging verbosity"
Expand Down
19 changes: 9 additions & 10 deletions src/seddy/_specs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
"WORKFLOW",
]

from ._base import ChildPolicy
from ._base import Registration
from ._base import DecisionsBuilder
from ._base import Workflow
from ._base import make_decisions_on_error
from ._dag import DAGBuilder
from ._dag import DAGWorkflow
from ._io import WorkflowNotFound
from ._io import get_workflow
from ._io import load_workflows
from ._base import (
ChildPolicy,
DecisionsBuilder,
Registration,
Workflow,
make_decisions_on_error,
)
from ._dag import DAGBuilder, DAGWorkflow
from ._io import WorkflowNotFound, get_workflow, load_workflows

WORKFLOW = {
DAGWorkflow.spec_type: DAGWorkflow,
Expand Down
2 changes: 1 addition & 1 deletion src/seddy/_specs/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import abc
import enum
import dataclasses
import typing as t
import dataclasses

import swf_typed

Expand Down
4 changes: 2 additions & 2 deletions src/seddy/_specs/_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import json
import string
import datetime
import dataclasses
import typing as t
import logging as lg
import datetime
import dataclasses

import swf_typed

Expand Down
2 changes: 1 addition & 1 deletion src/seddy/_specs/_io.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Workflows specs serialisation and desieralisation."""

import json
import pathlib
import typing as t
import logging as lg
import pathlib

from . import Workflow

Expand Down
5 changes: 2 additions & 3 deletions src/seddy/decider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import uuid
import socket
import pathlib
import typing as t
import logging as lg
import pathlib
from concurrent import futures as cf

import swf_typed

from . import _util
from . import _specs
from . import _specs, _util

logger = lg.getLogger(__name__)
socket.setdefaulttimeout(70.0)
Expand Down
5 changes: 2 additions & 3 deletions src/seddy/registration.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""SWF workflow registration."""

import pathlib
import typing as t
import logging as lg
import pathlib

import swf_typed

from . import _util
from . import _specs
from . import _specs, _util

logger = lg.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest
pytest-cov
coloredlogs
moto[swf] ~= 2.0
moto[swf] >= 2.0, < 5.0
pyyaml
python-json-logger
Loading

0 comments on commit 984e497

Please sign in to comment.