mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-21 20:08:14 +00:00
initial commit w/ burnettk
This commit is contained in:
commit
116145e91f
12
.cookiecutter.json
Normal file
12
.cookiecutter.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"_template": "gh:cjolowicz/cookiecutter-hypermodern-python",
|
||||
"author": "Sartography",
|
||||
"development_status": "Development Status :: 1 - Planning",
|
||||
"email": "sartography@users.noreply.github.com",
|
||||
"friendly_name": "Spiff Workflow Webapp",
|
||||
"github_user": "sartography",
|
||||
"license": "MIT",
|
||||
"package_name": "spiff_workflow_webapp",
|
||||
"project_name": "spiff-workflow-webapp",
|
||||
"version": "0.0.1"
|
||||
}
|
12
.flake8
Normal file
12
.flake8
Normal file
@ -0,0 +1,12 @@
|
||||
[flake8]
|
||||
select = B,B9,C,D,DAR,E,F,N,RST,S,W
|
||||
ignore = E203,E501,RST201,RST203,RST301,W503
|
||||
max-line-length = 120
|
||||
max-complexity = 30
|
||||
docstring-convention = google
|
||||
rst-roles = class,const,func,meth,mod,ref
|
||||
rst-directives = deprecated
|
||||
|
||||
per-file-ignores =
|
||||
# prefer naming tests descriptively rather than forcing comments
|
||||
tests/*:S101,D103
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
18
.github/dependabot.yml
vendored
Normal file
18
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
- package-ecosystem: pip
|
||||
directory: "/.github/workflows"
|
||||
schedule:
|
||||
interval: daily
|
||||
- package-ecosystem: pip
|
||||
directory: "/docs"
|
||||
schedule:
|
||||
interval: daily
|
||||
- package-ecosystem: pip
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
66
.github/labels.yml
vendored
Normal file
66
.github/labels.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
# Labels names are important as they are used by Release Drafter to decide
|
||||
# regarding where to record them in changelog or if to skip them.
|
||||
#
|
||||
# The repository labels will be automatically configured using this file and
|
||||
# the GitHub Action https://github.com/marketplace/actions/github-labeler.
|
||||
- name: breaking
|
||||
description: Breaking Changes
|
||||
color: bfd4f2
|
||||
- name: bug
|
||||
description: Something isn't working
|
||||
color: d73a4a
|
||||
- name: build
|
||||
description: Build System and Dependencies
|
||||
color: bfdadc
|
||||
- name: ci
|
||||
description: Continuous Integration
|
||||
color: 4a97d6
|
||||
- name: dependencies
|
||||
description: Pull requests that update a dependency file
|
||||
color: 0366d6
|
||||
- name: documentation
|
||||
description: Improvements or additions to documentation
|
||||
color: 0075ca
|
||||
- name: duplicate
|
||||
description: This issue or pull request already exists
|
||||
color: cfd3d7
|
||||
- name: enhancement
|
||||
description: New feature or request
|
||||
color: a2eeef
|
||||
- name: github_actions
|
||||
description: Pull requests that update Github_actions code
|
||||
color: "000000"
|
||||
- name: good first issue
|
||||
description: Good for newcomers
|
||||
color: 7057ff
|
||||
- name: help wanted
|
||||
description: Extra attention is needed
|
||||
color: 008672
|
||||
- name: invalid
|
||||
description: This doesn't seem right
|
||||
color: e4e669
|
||||
- name: performance
|
||||
description: Performance
|
||||
color: "016175"
|
||||
- name: python
|
||||
description: Pull requests that update Python code
|
||||
color: 2b67c6
|
||||
- name: question
|
||||
description: Further information is requested
|
||||
color: d876e3
|
||||
- name: refactoring
|
||||
description: Refactoring
|
||||
color: ef67c4
|
||||
- name: removal
|
||||
description: Removals and Deprecations
|
||||
color: 9ae7ea
|
||||
- name: style
|
||||
description: Style
|
||||
color: c120e5
|
||||
- name: testing
|
||||
description: Testing
|
||||
color: b1fc6f
|
||||
- name: wontfix
|
||||
description: This will not be worked on
|
||||
color: ffffff
|
29
.github/release-drafter.yml
vendored
Normal file
29
.github/release-drafter.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
categories:
|
||||
- title: ":boom: Breaking Changes"
|
||||
label: "breaking"
|
||||
- title: ":rocket: Features"
|
||||
label: "enhancement"
|
||||
- title: ":fire: Removals and Deprecations"
|
||||
label: "removal"
|
||||
- title: ":beetle: Fixes"
|
||||
label: "bug"
|
||||
- title: ":racehorse: Performance"
|
||||
label: "performance"
|
||||
- title: ":rotating_light: Testing"
|
||||
label: "testing"
|
||||
- title: ":construction_worker: Continuous Integration"
|
||||
label: "ci"
|
||||
- title: ":books: Documentation"
|
||||
label: "documentation"
|
||||
- title: ":hammer: Refactoring"
|
||||
label: "refactoring"
|
||||
- title: ":lipstick: Style"
|
||||
label: "style"
|
||||
- title: ":package: Dependencies"
|
||||
labels:
|
||||
- "dependencies"
|
||||
- "build"
|
||||
template: |
|
||||
## Changes
|
||||
|
||||
$CHANGES
|
28
.github/workflows/auto-merge-dependabot-prs.yml
vendored
Normal file
28
.github/workflows/auto-merge-dependabot-prs.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Dependabot auto-merge
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Tests"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.actor == 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' && github.event_name == 'pull_request' }}
|
||||
steps:
|
||||
- name: Dependabot metadata
|
||||
id: metadata
|
||||
uses: dependabot/fetch-metadata@v1.1.1
|
||||
with:
|
||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: Enable auto-merge for Dependabot PRs
|
||||
# if: ${{contains(steps.metadata.outputs.dependency-names, 'pytest') && steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
|
||||
# if: ${{contains(steps.metadata.outputs.dependency-names, 'pytest')}}
|
||||
# ideally we auto-merge if all checks pass
|
||||
run: gh pr merge --auto --merge "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{github.event.pull_request.html_url}}
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
5
.github/workflows/constraints.txt
vendored
Normal file
5
.github/workflows/constraints.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
pip==22.0.4
|
||||
nox==2022.1.7
|
||||
nox-poetry==0.9.0
|
||||
poetry==1.1.13
|
||||
virtualenv==20.14.1
|
19
.github/workflows/labeler.yml
vendored
Normal file
19
.github/workflows/labeler.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
name: Labeler
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
jobs:
|
||||
labeler:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3.0.2
|
||||
|
||||
- name: Run Labeler
|
||||
uses: crazy-max/ghaction-github-labeler@v3.1.1
|
||||
with:
|
||||
skip-delete: true
|
165
.github/workflows/tests.yml
vendored
Normal file
165
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "pre-commit" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "safety" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "mypy" }
|
||||
- { python: "3.9", os: "ubuntu-latest", session: "mypy" }
|
||||
- { python: "3.8", os: "ubuntu-latest", session: "mypy" }
|
||||
- { python: "3.7", os: "ubuntu-latest", session: "mypy" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
|
||||
- { python: "3.9", os: "ubuntu-latest", session: "tests" }
|
||||
- { python: "3.8", os: "ubuntu-latest", session: "tests" }
|
||||
- { python: "3.7", os: "ubuntu-latest", session: "tests" }
|
||||
- { python: "3.10", os: "windows-latest", session: "tests" }
|
||||
- { python: "3.10", os: "macos-latest", session: "tests" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "typeguard" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "xdoctest" }
|
||||
- { python: "3.10", os: "ubuntu-latest", session: "docs-build" }
|
||||
|
||||
env:
|
||||
NOXSESSION: ${{ matrix.session }}
|
||||
FORCE_COLOR: "1"
|
||||
PRE_COMMIT_COLOR: "always"
|
||||
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3.0.2
|
||||
|
||||
- name: Set up Python ${{ matrix.python }}
|
||||
uses: actions/setup-python@v3.1.2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
|
||||
- name: Upgrade pip
|
||||
run: |
|
||||
pip install --constraint=.github/workflows/constraints.txt pip
|
||||
pip --version
|
||||
|
||||
- name: Upgrade pip in virtual environments
|
||||
shell: python
|
||||
run: |
|
||||
import os
|
||||
import pip
|
||||
|
||||
with open(os.environ["GITHUB_ENV"], mode="a") as io:
|
||||
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
|
||||
|
||||
- name: Install Poetry
|
||||
run: |
|
||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
|
||||
poetry --version
|
||||
|
||||
- name: Install Nox
|
||||
run: |
|
||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
|
||||
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
|
||||
nox --version
|
||||
|
||||
- name: Compute pre-commit cache key
|
||||
if: matrix.session == 'pre-commit'
|
||||
id: pre-commit-cache
|
||||
shell: python
|
||||
run: |
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
python = "py{}.{}".format(*sys.version_info[:2])
|
||||
payload = sys.version.encode() + sys.executable.encode()
|
||||
digest = hashlib.sha256(payload).hexdigest()
|
||||
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
|
||||
|
||||
print("::set-output name=result::{}".format(result))
|
||||
|
||||
- name: Restore pre-commit cache
|
||||
uses: actions/cache@v3.0.2
|
||||
if: matrix.session == 'pre-commit'
|
||||
with:
|
||||
path: ~/.cache/pre-commit
|
||||
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
||||
restore-keys: |
|
||||
${{ steps.pre-commit-cache.outputs.result }}-
|
||||
|
||||
- name: Run Nox
|
||||
run: |
|
||||
nox --force-color --python=${{ matrix.python }}
|
||||
|
||||
- name: Upload coverage data
|
||||
# pin to upload coverage from only one matrix entry, otherwise coverage gets confused later
|
||||
if: always() && matrix.session == 'tests' && matrix.python == '3.10' && matrix.os == 'ubuntu-latest'
|
||||
uses: "actions/upload-artifact@v3.0.0"
|
||||
with:
|
||||
name: coverage-data
|
||||
path: ".coverage.*"
|
||||
|
||||
- name: Upload documentation
|
||||
if: matrix.session == 'docs-build'
|
||||
uses: actions/upload-artifact@v3.0.0
|
||||
with:
|
||||
name: docs
|
||||
path: docs/_build
|
||||
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
steps:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v3.0.2
|
||||
with:
|
||||
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v3.1.2
|
||||
with:
|
||||
python-version: "3.10"
|
||||
|
||||
- name: Upgrade pip
|
||||
run: |
|
||||
pip install --constraint=.github/workflows/constraints.txt pip
|
||||
pip --version
|
||||
|
||||
- name: Install Poetry
|
||||
run: |
|
||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
|
||||
poetry --version
|
||||
|
||||
- name: Install Nox
|
||||
run: |
|
||||
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
|
||||
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
|
||||
nox --version
|
||||
|
||||
- name: Download coverage data
|
||||
uses: actions/download-artifact@v3.0.0
|
||||
with:
|
||||
name: coverage-data
|
||||
|
||||
- name: Combine coverage data and display human readable report
|
||||
run: |
|
||||
find . -name \*.pyc -delete
|
||||
nox --force-color --session=coverage
|
||||
|
||||
- name: Create coverage report
|
||||
run: |
|
||||
nox --force-color --session=coverage -- xml
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: codecov/codecov-action@v3.1.0
|
||||
|
||||
- name: SonarCloud Scan
|
||||
uses: sonarsource/sonarcloud-github-action@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
.mypy_cache/
|
||||
/.coverage
|
||||
/.coverage.*
|
||||
/.nox/
|
||||
/.python-version
|
||||
/.pytype/
|
||||
/dist/
|
||||
/docs/_build/
|
||||
/src/*.egg-info/
|
||||
__pycache__/
|
58
.pre-commit-config.yaml
Normal file
58
.pre-commit-config.yaml
Normal file
@ -0,0 +1,58 @@
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: black
|
||||
name: black
|
||||
entry: black
|
||||
language: system
|
||||
types: [python]
|
||||
require_serial: true
|
||||
- id: check-added-large-files
|
||||
name: Check for added large files
|
||||
entry: check-added-large-files
|
||||
language: system
|
||||
- id: check-toml
|
||||
name: Check Toml
|
||||
entry: check-toml
|
||||
language: system
|
||||
types: [toml]
|
||||
- id: check-yaml
|
||||
name: Check Yaml
|
||||
entry: check-yaml
|
||||
language: system
|
||||
types: [yaml]
|
||||
- id: end-of-file-fixer
|
||||
name: Fix End of Files
|
||||
entry: end-of-file-fixer
|
||||
language: system
|
||||
types: [text]
|
||||
stages: [commit, push, manual]
|
||||
- id: flake8
|
||||
name: flake8
|
||||
entry: flake8
|
||||
language: system
|
||||
types: [python]
|
||||
require_serial: true
|
||||
- id: pyupgrade
|
||||
name: pyupgrade
|
||||
description: Automatically upgrade syntax for newer versions.
|
||||
entry: pyupgrade
|
||||
language: system
|
||||
types: [python]
|
||||
args: [--py37-plus]
|
||||
- id: reorder-python-imports
|
||||
name: Reorder python imports
|
||||
entry: reorder-python-imports
|
||||
language: system
|
||||
types: [python]
|
||||
args: [--application-directories=src]
|
||||
- id: trailing-whitespace
|
||||
name: Trim Trailing Whitespace
|
||||
entry: trailing-whitespace-fixer
|
||||
language: system
|
||||
types: [text]
|
||||
stages: [commit, push, manual]
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.4.1
|
||||
hooks:
|
||||
- id: prettier
|
12
.readthedocs.yml
Normal file
12
.readthedocs.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: 2
|
||||
build:
|
||||
os: ubuntu-20.04
|
||||
tools:
|
||||
python: "3.10"
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
formats: all
|
||||
python:
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
- path: .
|
1
.tool-versions
Normal file
1
.tool-versions
Normal file
@ -0,0 +1 @@
|
||||
python 3.10.4
|
105
CODE_OF_CONDUCT.rst
Normal file
105
CODE_OF_CONDUCT.rst
Normal file
@ -0,0 +1,105 @@
|
||||
Contributor Covenant Code of Conduct
|
||||
====================================
|
||||
|
||||
Our Pledge
|
||||
----------
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
||||
|
||||
|
||||
Our Standards
|
||||
-------------
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our community include:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
- Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
Enforcement Responsibilities
|
||||
----------------------------
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
||||
|
||||
|
||||
Scope
|
||||
-----
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
||||
|
||||
|
||||
Enforcement
|
||||
-----------
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at sartography@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
||||
|
||||
|
||||
Enforcement Guidelines
|
||||
----------------------
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
|
||||
1. Correction
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
|
||||
2. Warning
|
||||
~~~~~~~~~~
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
||||
|
||||
|
||||
3. Temporary Ban
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
|
||||
4. Permanent Ban
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
||||
|
||||
|
||||
Attribution
|
||||
-----------
|
||||
|
||||
This Code of Conduct is adapted from the `Contributor Covenant <homepage_>`__, version 2.0,
|
||||
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by `Mozilla’s code of conduct enforcement ladder <https://github.com/mozilla/diversity>`__.
|
||||
|
||||
.. _homepage: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
123
CONTRIBUTING.rst
Normal file
123
CONTRIBUTING.rst
Normal file
@ -0,0 +1,123 @@
|
||||
Contributor Guide
|
||||
=================
|
||||
|
||||
Thank you for your interest in improving this project.
|
||||
This project is open-source under the `MIT license`_ and
|
||||
welcomes contributions in the form of bug reports, feature requests, and pull requests.
|
||||
|
||||
Here is a list of important resources for contributors:
|
||||
|
||||
- `Source Code`_
|
||||
- `Documentation`_
|
||||
- `Issue Tracker`_
|
||||
- `Code of Conduct`_
|
||||
|
||||
.. _MIT license: https://opensource.org/licenses/MIT
|
||||
.. _Source Code: https://github.com/sartography/spiff-workflow-webapp
|
||||
.. _Documentation: https://spiff-workflow-webapp.readthedocs.io/
|
||||
.. _Issue Tracker: https://github.com/sartography/spiff-workflow-webapp/issues
|
||||
|
||||
How to report a bug
|
||||
-------------------
|
||||
|
||||
Report bugs on the `Issue Tracker`_.
|
||||
|
||||
When filing an issue, make sure to answer these questions:
|
||||
|
||||
- Which operating system and Python version are you using?
|
||||
- Which version of this project are you using?
|
||||
- What did you do?
|
||||
- What did you expect to see?
|
||||
- What did you see instead?
|
||||
|
||||
The best way to get your bug fixed is to provide a test case,
|
||||
and/or steps to reproduce the issue.
|
||||
|
||||
|
||||
How to request a feature
|
||||
------------------------
|
||||
|
||||
Request features on the `Issue Tracker`_.
|
||||
|
||||
|
||||
How to set up your development environment
|
||||
------------------------------------------
|
||||
|
||||
You need Python 3.7+ and the following tools:
|
||||
|
||||
- Poetry_
|
||||
- Nox_
|
||||
- nox-poetry_
|
||||
|
||||
Install the package with development requirements:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ poetry install
|
||||
|
||||
You can now run an interactive Python session,
|
||||
or the command-line interface:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ poetry run python
|
||||
$ poetry run spiff-workflow-webapp
|
||||
|
||||
.. _Poetry: https://python-poetry.org/
|
||||
.. _Nox: https://nox.thea.codes/
|
||||
.. _nox-poetry: https://nox-poetry.readthedocs.io/
|
||||
|
||||
|
||||
How to test the project
|
||||
-----------------------
|
||||
|
||||
Run the full test suite:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ nox
|
||||
|
||||
List the available Nox sessions:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ nox --list-sessions
|
||||
|
||||
You can also run a specific Nox session.
|
||||
For example, invoke the unit test suite like this:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ nox --session=tests
|
||||
|
||||
Unit tests are located in the ``tests`` directory,
|
||||
and are written using the pytest_ testing framework.
|
||||
|
||||
.. _pytest: https://pytest.readthedocs.io/
|
||||
|
||||
|
||||
How to submit changes
|
||||
---------------------
|
||||
|
||||
Open a `pull request`_ to submit changes to this project.
|
||||
|
||||
Your pull request needs to meet the following guidelines for acceptance:
|
||||
|
||||
- The Nox test suite must pass without errors and warnings.
|
||||
- Include unit tests. This project maintains 100% code coverage.
|
||||
- If your changes add functionality, update the documentation accordingly.
|
||||
|
||||
Feel free to submit early, though—we can always iterate on this.
|
||||
|
||||
To run linting and code formatting checks before committing your change, you can install pre-commit as a Git hook by running the following command:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ nox --session=pre-commit -- install
|
||||
|
||||
It is recommended to open an issue before starting work on anything.
|
||||
This will allow a chance to talk it over with the owners and validate your approach.
|
||||
|
||||
.. _pull request: https://github.com/sartography/spiff-workflow-webapp/pulls
|
||||
.. github-only
|
||||
.. _Code of Conduct: CODE_OF_CONDUCT.rst
|
504
LICENSE.rst
Normal file
504
LICENSE.rst
Normal file
@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
|
||||
USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random
|
||||
Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
102
README.rst
Normal file
102
README.rst
Normal file
@ -0,0 +1,102 @@
|
||||
Spiff Workflow Webapp
|
||||
==========
|
||||
|
||||
|PyPI| |Status| |Python Version| |License|
|
||||
|
||||
|Read the Docs| |Tests| |Codecov|
|
||||
|
||||
|pre-commit| |Black|
|
||||
|
||||
.. |PyPI| image:: https://img.shields.io/pypi/v/spiff-workflow-webapp.svg
|
||||
:target: https://pypi.org/project/spiff-workflow-webapp/
|
||||
:alt: PyPI
|
||||
.. |Status| image:: https://img.shields.io/pypi/status/spiff-workflow-webapp.svg
|
||||
:target: https://pypi.org/project/spiff-workflow-webapp/
|
||||
:alt: Status
|
||||
.. |Python Version| image:: https://img.shields.io/pypi/pyversions/spiff-workflow-webapp
|
||||
:target: https://pypi.org/project/spiff-workflow-webapp
|
||||
:alt: Python Version
|
||||
.. |License| image:: https://img.shields.io/pypi/l/spiff-workflow-webapp
|
||||
:target: https://opensource.org/licenses/MIT
|
||||
:alt: License
|
||||
.. |Read the Docs| image:: https://img.shields.io/readthedocs/spiff-workflow-webapp/latest.svg?label=Read%20the%20Docs
|
||||
:target: https://spiff-workflow-webapp.readthedocs.io/
|
||||
:alt: Read the documentation at https://spiff-workflow-webapp.readthedocs.io/
|
||||
.. |Tests| image:: https://github.com/sartography/spiff-workflow-webapp/workflows/Tests/badge.svg
|
||||
:target: https://github.com/sartography/spiff-workflow-webapp/actions?workflow=Tests
|
||||
:alt: Tests
|
||||
.. |Codecov| image:: https://codecov.io/gh/sartography/spiff-workflow-webapp/branch/main/graph/badge.svg
|
||||
:target: https://codecov.io/gh/sartography/spiff-workflow-webapp
|
||||
:alt: Codecov
|
||||
.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
|
||||
:target: https://github.com/pre-commit/pre-commit
|
||||
:alt: pre-commit
|
||||
.. |Black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||
:target: https://github.com/psf/black
|
||||
:alt: Black
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* TODO
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Python 3.7+
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You can install *Spiff Workflow Webapp* via pip_ from PyPI_:
|
||||
|
||||
.. code:: console
|
||||
|
||||
$ pip install spiff-workflow-webapp
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Please see the `Command-line Reference <Usage_>`_ for details.
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions are very welcome.
|
||||
To learn more, see the `Contributor Guide`_.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Distributed under the terms of the `MIT license`_,
|
||||
*Spiff Workflow Webapp* is free and open source software.
|
||||
|
||||
|
||||
Issues
|
||||
------
|
||||
|
||||
If you encounter any problems,
|
||||
please `file an issue`_ along with a detailed description.
|
||||
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
||||
This project was generated from `@cjolowicz`_'s `Hypermodern Python Cookiecutter`_ template.
|
||||
|
||||
.. _@cjolowicz: https://github.com/cjolowicz
|
||||
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
|
||||
.. _MIT license: https://opensource.org/licenses/MIT
|
||||
.. _PyPI: https://pypi.org/
|
||||
.. _Hypermodern Python Cookiecutter: https://github.com/cjolowicz/cookiecutter-hypermodern-python
|
||||
.. _file an issue: https://github.com/sartography/spiff-workflow-webapp/issues
|
||||
.. _pip: https://pip.pypa.io/
|
||||
.. github-only
|
||||
.. _Contributor Guide: CONTRIBUTING.rst
|
||||
.. _Usage: https://spiff-workflow-webapp.readthedocs.io/en/latest/usage.html
|
9
codecov.yml
Normal file
9
codecov.yml
Normal file
@ -0,0 +1,9 @@
|
||||
comment: false
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: "100"
|
||||
patch:
|
||||
default:
|
||||
target: "100"
|
1
docs/codeofconduct.rst
Normal file
1
docs/codeofconduct.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../CODE_OF_CONDUCT.rst
|
17
docs/conf.py
Normal file
17
docs/conf.py
Normal file
@ -0,0 +1,17 @@
|
||||
"""Sphinx configuration."""
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
project = "Spiff Workflow Webapp"
|
||||
author = "Sartography"
|
||||
copyright = f"{datetime.now().year}, {author}"
|
||||
extensions = [
|
||||
"sphinx.ext.napoleon",
|
||||
"autoapi.extension",
|
||||
"sphinx_click",
|
||||
]
|
||||
|
||||
# https://github.com/readthedocs/sphinx-autoapi
|
||||
autoapi_type = "python"
|
||||
autoapi_dirs = ["../src"]
|
||||
html_theme = "furo"
|
4
docs/contributing.rst
Normal file
4
docs/contributing.rst
Normal file
@ -0,0 +1,4 @@
|
||||
.. include:: ../CONTRIBUTING.rst
|
||||
:end-before: github-only
|
||||
|
||||
.. _Code of Conduct: codeofconduct.html
|
16
docs/index.rst
Normal file
16
docs/index.rst
Normal file
@ -0,0 +1,16 @@
|
||||
.. include:: ../README.rst
|
||||
:end-before: github-only
|
||||
|
||||
.. _Contributor Guide: contributing.html
|
||||
.. _Usage: usage.html
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 1
|
||||
|
||||
usage
|
||||
reference
|
||||
contributing
|
||||
Code of Conduct <codeofconduct>
|
||||
License <license>
|
||||
Changelog <https://github.com/sartography/spiff-workflow-webapp/releases>
|
1
docs/license.rst
Normal file
1
docs/license.rst
Normal file
@ -0,0 +1 @@
|
||||
.. include:: ../LICENSE.rst
|
9
docs/reference.rst
Normal file
9
docs/reference.rst
Normal file
@ -0,0 +1,9 @@
|
||||
Reference
|
||||
=========
|
||||
|
||||
|
||||
spiff_workflow_webapp
|
||||
----------
|
||||
|
||||
.. automodule:: spiff_workflow_webapp
|
||||
:members:
|
3
docs/requirements.txt
Normal file
3
docs/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
furo==2022.4.7
|
||||
sphinx==4.5.0
|
||||
sphinx-click==4.0.3
|
6
docs/usage.rst
Normal file
6
docs/usage.rst
Normal file
@ -0,0 +1,6 @@
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. click:: spiff_workflow_webapp.__main__:main
|
||||
:prog: spiff-workflow-webapp
|
||||
:nested: full
|
205
noxfile.py
Normal file
205
noxfile.py
Normal file
@ -0,0 +1,205 @@
|
||||
"""Nox sessions."""
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
import nox
|
||||
|
||||
try:
|
||||
from nox_poetry import Session
|
||||
from nox_poetry import session
|
||||
except ImportError:
|
||||
message = f"""\
|
||||
Nox failed to import the 'nox-poetry' package.
|
||||
|
||||
Please install it using the following command:
|
||||
|
||||
{sys.executable} -m pip install nox-poetry"""
|
||||
raise SystemExit(dedent(message)) from None
|
||||
|
||||
|
||||
package = "spiff_workflow_webapp"
|
||||
python_versions = ["3.10", "3.9", "3.8", "3.7"]
|
||||
nox.needs_version = ">= 2021.6.6"
|
||||
nox.options.sessions = (
|
||||
"pre-commit",
|
||||
"safety",
|
||||
"mypy",
|
||||
"tests",
|
||||
"typeguard",
|
||||
"xdoctest",
|
||||
"docs-build",
|
||||
)
|
||||
|
||||
|
||||
def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
|
||||
"""Activate virtualenv in hooks installed by pre-commit.
|
||||
|
||||
This function patches git hooks installed by pre-commit to activate the
|
||||
session's virtual environment. This allows pre-commit to locate hooks in
|
||||
that environment when invoked from git.
|
||||
|
||||
Args:
|
||||
session: The Session object.
|
||||
"""
|
||||
assert session.bin is not None # noqa: S101
|
||||
|
||||
virtualenv = session.env.get("VIRTUAL_ENV")
|
||||
if virtualenv is None:
|
||||
return
|
||||
|
||||
hookdir = Path(".git") / "hooks"
|
||||
if not hookdir.is_dir():
|
||||
return
|
||||
|
||||
for hook in hookdir.iterdir():
|
||||
if hook.name.endswith(".sample") or not hook.is_file():
|
||||
continue
|
||||
|
||||
text = hook.read_text()
|
||||
bindir = repr(session.bin)[1:-1] # strip quotes
|
||||
if not (
|
||||
Path("A") == Path("a") and bindir.lower() in text.lower() or bindir in text
|
||||
):
|
||||
continue
|
||||
|
||||
lines = text.splitlines()
|
||||
if not (lines[0].startswith("#!") and "python" in lines[0].lower()):
|
||||
continue
|
||||
|
||||
header = dedent(
|
||||
f"""\
|
||||
import os
|
||||
os.environ["VIRTUAL_ENV"] = {virtualenv!r}
|
||||
os.environ["PATH"] = os.pathsep.join((
|
||||
{session.bin!r},
|
||||
os.environ.get("PATH", ""),
|
||||
))
|
||||
"""
|
||||
)
|
||||
|
||||
lines.insert(1, header)
|
||||
hook.write_text("\n".join(lines))
|
||||
|
||||
|
||||
@session(name="pre-commit", python="3.10")
|
||||
def precommit(session: Session) -> None:
|
||||
"""Lint using pre-commit."""
|
||||
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
|
||||
session.install(
|
||||
"black",
|
||||
"darglint",
|
||||
"flake8",
|
||||
"flake8-bandit",
|
||||
"flake8-bugbear",
|
||||
"flake8-docstrings",
|
||||
"flake8-rst-docstrings",
|
||||
"pep8-naming",
|
||||
"pre-commit",
|
||||
"pre-commit-hooks",
|
||||
"pyupgrade",
|
||||
"reorder-python-imports",
|
||||
)
|
||||
session.run("pre-commit", *args)
|
||||
if args and args[0] == "install":
|
||||
activate_virtualenv_in_precommit_hooks(session)
|
||||
|
||||
|
||||
@session(python="3.10")
|
||||
def safety(session: Session) -> None:
|
||||
"""Scan dependencies for insecure packages."""
|
||||
requirements = session.poetry.export_requirements()
|
||||
session.install("safety")
|
||||
session.run("safety", "check", "--full-report", f"--file={requirements}")
|
||||
|
||||
|
||||
@session(python=python_versions)
|
||||
def mypy(session: Session) -> None:
|
||||
"""Type-check using mypy."""
|
||||
args = session.posargs or ["src", "tests", "docs/conf.py"]
|
||||
session.install(".")
|
||||
session.install("mypy", "pytest")
|
||||
session.run("mypy", *args)
|
||||
if not session.posargs:
|
||||
session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py")
|
||||
|
||||
|
||||
@session(python=python_versions)
|
||||
def tests(session: Session) -> None:
|
||||
"""Run the test suite."""
|
||||
session.install(".")
|
||||
session.install("coverage[toml]", "pytest", "pygments")
|
||||
try:
|
||||
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
|
||||
finally:
|
||||
if session.interactive:
|
||||
session.notify("coverage", posargs=[])
|
||||
|
||||
|
||||
@session
|
||||
def coverage(session: Session) -> None:
|
||||
"""Produce the coverage report."""
|
||||
args = session.posargs or ["report"]
|
||||
|
||||
session.install("coverage[toml]")
|
||||
|
||||
if not session.posargs and any(Path().glob(".coverage.*")):
|
||||
session.run("coverage", "combine")
|
||||
|
||||
session.run("coverage", *args)
|
||||
|
||||
|
||||
@session(python=python_versions)
|
||||
def typeguard(session: Session) -> None:
|
||||
"""Runtime type checking using Typeguard."""
|
||||
session.install(".")
|
||||
session.install("pytest", "typeguard", "pygments")
|
||||
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
|
||||
|
||||
|
||||
@session(python=python_versions)
|
||||
def xdoctest(session: Session) -> None:
|
||||
"""Run examples with xdoctest."""
|
||||
if session.posargs:
|
||||
args = [package, *session.posargs]
|
||||
else:
|
||||
args = [f"--modname={package}", "--command=all"]
|
||||
if "FORCE_COLOR" in os.environ:
|
||||
args.append("--colored=1")
|
||||
|
||||
session.install(".")
|
||||
session.install("xdoctest[colors]")
|
||||
session.run("python", "-m", "xdoctest", *args)
|
||||
|
||||
|
||||
@session(name="docs-build", python="3.10")
|
||||
def docs_build(session: Session) -> None:
|
||||
"""Build the documentation."""
|
||||
args = session.posargs or ["docs", "docs/_build"]
|
||||
if not session.posargs and "FORCE_COLOR" in os.environ:
|
||||
args.insert(0, "--color")
|
||||
|
||||
session.install(".")
|
||||
session.install("sphinx", "sphinx-click", "furo")
|
||||
|
||||
build_dir = Path("docs", "_build")
|
||||
if build_dir.exists():
|
||||
shutil.rmtree(build_dir)
|
||||
|
||||
session.run("sphinx-build", *args)
|
||||
|
||||
|
||||
@session(python="3.10")
|
||||
def docs(session: Session) -> None:
|
||||
"""Build and serve the documentation with live reloading on file changes."""
|
||||
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
|
||||
session.install(".")
|
||||
session.install("sphinx", "sphinx-autobuild", "sphinx-click", "furo")
|
||||
|
||||
build_dir = Path("docs", "_build")
|
||||
if build_dir.exists():
|
||||
shutil.rmtree(build_dir)
|
||||
|
||||
session.run("sphinx-autobuild", *args)
|
2942
poetry.lock
generated
Normal file
2942
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
97
pyproject.toml
Normal file
97
pyproject.toml
Normal file
@ -0,0 +1,97 @@
|
||||
[tool.poetry]
|
||||
name = "spiff-workflow-webapp"
|
||||
version = "0.0.0"
|
||||
description = "Spiff Workflow Webapp"
|
||||
authors = ["Jason Lantz <sartography@users.noreply.github.com>"]
|
||||
license = "MIT"
|
||||
readme = "README.rst"
|
||||
homepage = "https://github.com/sartography/spiff-workflow-webapp"
|
||||
repository = "https://github.com/sartography/spiff-workflow-webapp"
|
||||
documentation = "https://spiff-workflow-webapp.readthedocs.io"
|
||||
classifiers = [
|
||||
"Development Status :: 1 - Planning",
|
||||
]
|
||||
|
||||
[tool.poetry.urls]
|
||||
Changelog = "https://github.com/sartography/spiff-workflow-webapp/releases"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.7"
|
||||
click = "^8.0.1"
|
||||
flask = "*"
|
||||
flask-admin = "*"
|
||||
flask-bcrypt = "*"
|
||||
flask-cors = "*"
|
||||
flask-mail = "*"
|
||||
flask-marshmallow = "*"
|
||||
flask-migrate = "*"
|
||||
flask-restful = "*"
|
||||
werkzeug = "*"
|
||||
spiffworkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
|
||||
sentry-sdk = "0.14.4"
|
||||
sphinx-autoapi = "^1.8.4"
|
||||
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^6.2.5"
|
||||
coverage = {extras = ["toml"], version = "^6.1"}
|
||||
safety = "^1.10.3"
|
||||
mypy = "^0.910"
|
||||
typeguard = "^2.13.2"
|
||||
xdoctest = {extras = ["colors"], version = "^1.0.0"}
|
||||
sphinx = "^4.3.0"
|
||||
sphinx-autobuild = ">=2021.3.14"
|
||||
pre-commit = "^2.15.0"
|
||||
flake8 = "^4.0.1"
|
||||
black = ">=21.10b0"
|
||||
flake8-bandit = "^2.1.2"
|
||||
|
||||
# 1.7.3 broke us. https://github.com/PyCQA/bandit/issues/841
|
||||
bandit = "1.7.2"
|
||||
|
||||
flake8-bugbear = "^22.4.25"
|
||||
flake8-docstrings = "^1.6.0"
|
||||
flake8-rst-docstrings = "^0.2.3"
|
||||
pep8-naming = "^0.12.1"
|
||||
darglint = "^1.8.1"
|
||||
reorder-python-imports = "^3.1.0"
|
||||
pre-commit-hooks = "^4.0.1"
|
||||
sphinx-click = "^4.0.3"
|
||||
Pygments = "^2.10.0"
|
||||
pyupgrade = "^2.29.1"
|
||||
furo = ">=2021.11.12"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
spiff-workflow-webapp = "spiff_workflow_webapp.__main__:main"
|
||||
|
||||
[tool.coverage.paths]
|
||||
source = ["src", "*/site-packages"]
|
||||
tests = ["tests", "*/tests"]
|
||||
|
||||
[tool.coverage.run]
|
||||
branch = true
|
||||
source = ["spiff_workflow_webapp", "tests"]
|
||||
|
||||
[tool.coverage.report]
|
||||
show_missing = true
|
||||
fail_under = 50
|
||||
|
||||
[tool.mypy]
|
||||
strict = true
|
||||
disallow_any_generics = false
|
||||
warn_unreachable = true
|
||||
pretty = true
|
||||
show_column_numbers = true
|
||||
show_error_codes = true
|
||||
show_error_context = true
|
||||
|
||||
# We get 'error: Module has no attribute "set_context"' for sentry-sdk without this option
|
||||
implicit_reexport = true
|
||||
|
||||
# allow for subdirs to NOT require __init__.py
|
||||
namespace_packages = true
|
||||
explicit_package_bases = false
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
8
sonar-project.properties
Normal file
8
sonar-project.properties
Normal file
@ -0,0 +1,8 @@
|
||||
sonar.organization=sartography
|
||||
sonar.projectKey=sartography_spiff-workflow-webapp
|
||||
sonar.host.url=https://sonarcloud.io
|
||||
sonar.python.version=3.7,3.8,3.9,3.10
|
||||
sonar.python.coverage.reportPaths=coverage.xml
|
||||
sonar.test.inclusions=tests
|
||||
# sonar.exclusions=crc/templates/*.html,docs/**,config/**,instance/**,migrations/**,postgres/**,readme_images/**,schema/**,templates/**
|
||||
# sonar.sources=crc
|
1
src/spiff_workflow_webapp/__init__.py
Normal file
1
src/spiff_workflow_webapp/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""Spiff Workflow Webapp."""
|
13
src/spiff_workflow_webapp/__main__.py
Normal file
13
src/spiff_workflow_webapp/__main__.py
Normal file
@ -0,0 +1,13 @@
|
||||
"""Command-line interface."""
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.version_option()
|
||||
def main() -> None:
|
||||
"""Spiff Workflow Webapp."""
|
||||
print("This does nothing")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(prog_name="spiff-workflow-webapp") # pragma: no cover
|
229
src/spiff_workflow_webapp/api/api_error.py
Normal file
229
src/spiff_workflow_webapp/api/api_error.py
Normal file
@ -0,0 +1,229 @@
|
||||
"""API Error functionality."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import sentry_sdk
|
||||
from flask import Blueprint
|
||||
from flask import current_app
|
||||
from flask import g
|
||||
from marshmallow import Schema
|
||||
from SpiffWorkflow import WorkflowException # type: ignore
|
||||
from SpiffWorkflow.exceptions import WorkflowTaskExecException # type: ignore
|
||||
from SpiffWorkflow.specs.base import TaskSpec # type: ignore
|
||||
from SpiffWorkflow.task import Task # type: ignore
|
||||
from werkzeug.exceptions import InternalServerError
|
||||
|
||||
api_error_blueprint = Blueprint("api_error_blueprint", __name__)
|
||||
|
||||
|
||||
class ApiError(Exception):
|
||||
"""ApiError Class to help handle exceptions."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
code: str,
|
||||
message: str,
|
||||
status_code: int = 400,
|
||||
file_name: str = "",
|
||||
task_id: str = "",
|
||||
task_name: str = "",
|
||||
tag: str = "",
|
||||
task_data: dict | None | str = None,
|
||||
error_type: str = "",
|
||||
error_line: str = "",
|
||||
line_number: int = 0,
|
||||
offset: int = 0,
|
||||
task_trace: dict | None = None,
|
||||
) -> None:
|
||||
"""The Init Method."""
|
||||
if task_data is None:
|
||||
task_data = {}
|
||||
if task_trace is None:
|
||||
task_trace = {}
|
||||
self.status_code = status_code
|
||||
self.code = code # a short consistent string describing the error.
|
||||
self.message = message # A detailed message that provides more information.
|
||||
|
||||
# OPTIONAL: The id of the task in the BPMN Diagram.
|
||||
self.task_id = task_id or ""
|
||||
|
||||
# OPTIONAL: The name of the task in the BPMN Diagram.
|
||||
|
||||
# OPTIONAL: The file that caused the error.
|
||||
self.task_name = task_name or ""
|
||||
self.file_name = file_name or ""
|
||||
|
||||
# OPTIONAL: The XML Tag that caused the issue.
|
||||
self.tag = tag or ""
|
||||
|
||||
# OPTIONAL: A snapshot of data connected to the task when error occurred.
|
||||
self.task_data = task_data or ""
|
||||
self.line_number = line_number
|
||||
self.offset = offset
|
||||
self.error_type = error_type
|
||||
self.error_line = error_line
|
||||
self.task_trace = task_trace
|
||||
|
||||
try:
|
||||
user = g.user.uid
|
||||
except Exception:
|
||||
user = "Unknown"
|
||||
self.task_user = user
|
||||
# This is for sentry logging into Slack
|
||||
sentry_sdk.set_context("User", {"user": user})
|
||||
Exception.__init__(self, self.message)
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Instructions to print instance as a string."""
|
||||
msg = "ApiError: % s. " % self.message
|
||||
if self.task_name:
|
||||
msg += f"Error in task '{self.task_name}' ({self.task_id}). "
|
||||
if self.line_number:
|
||||
msg += "Error is on line %i. " % self.line_number
|
||||
if self.file_name:
|
||||
msg += "In file %s. " % self.file_name
|
||||
return msg
|
||||
|
||||
@classmethod
|
||||
def from_task(
|
||||
cls,
|
||||
code: str,
|
||||
message: str,
|
||||
task: Task,
|
||||
status_code: int = 400,
|
||||
line_number: int = 0,
|
||||
offset: int = 0,
|
||||
error_type: str = "",
|
||||
error_line: str = "",
|
||||
task_trace: dict | None = None,
|
||||
) -> ApiError:
|
||||
"""Constructs an API Error with details pulled from the current task."""
|
||||
instance = cls(code, message, status_code=status_code)
|
||||
instance.task_id = task.task_spec.name or ""
|
||||
instance.task_name = task.task_spec.description or ""
|
||||
instance.file_name = task.workflow.spec.file or ""
|
||||
instance.line_number = line_number
|
||||
instance.offset = offset
|
||||
instance.error_type = error_type
|
||||
instance.error_line = error_line
|
||||
if task_trace:
|
||||
instance.task_trace = task_trace
|
||||
else:
|
||||
instance.task_trace = WorkflowTaskExecException.get_task_trace(task)
|
||||
|
||||
# Fixme: spiffworkflow is doing something weird where task ends up referenced in the data in some cases.
|
||||
if "task" in task.data:
|
||||
task.data.pop("task")
|
||||
|
||||
# Assure that there is nothing in the json data that can't be serialized.
|
||||
instance.task_data = ApiError.remove_unserializeable_from_dict(task.data)
|
||||
|
||||
current_app.logger.error(message, exc_info=True)
|
||||
return instance
|
||||
|
||||
@staticmethod
|
||||
def remove_unserializeable_from_dict(my_dict: dict) -> dict:
|
||||
"""Removes unserializeable from dict."""
|
||||
keys_to_delete = []
|
||||
for key, value in my_dict.items():
|
||||
if not ApiError.is_jsonable(value):
|
||||
keys_to_delete.append(key)
|
||||
for key in keys_to_delete:
|
||||
del my_dict[key]
|
||||
return my_dict
|
||||
|
||||
@staticmethod
|
||||
def is_jsonable(x: Any) -> bool:
|
||||
"""Attempts a json.dump on given input and returns false if it cannot."""
|
||||
try:
|
||||
json.dumps(x)
|
||||
return True
|
||||
except (TypeError, OverflowError, ValueError):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def from_task_spec(
|
||||
cls,
|
||||
code: str,
|
||||
message: str,
|
||||
task_spec: TaskSpec,
|
||||
status_code: int = 400,
|
||||
) -> ApiError:
|
||||
"""Constructs an API Error with details pulled from the current task."""
|
||||
instance = cls(code, message, status_code=status_code)
|
||||
instance.task_id = task_spec.name or ""
|
||||
instance.task_name = task_spec.description or ""
|
||||
if task_spec._wf_spec:
|
||||
instance.file_name = task_spec._wf_spec.file
|
||||
current_app.logger.error(message, exc_info=True)
|
||||
return instance
|
||||
|
||||
@classmethod
|
||||
def from_workflow_exception(
|
||||
cls,
|
||||
code: str,
|
||||
message: str,
|
||||
exp: WorkflowException,
|
||||
) -> ApiError:
|
||||
"""Deals with workflow exceptions.
|
||||
|
||||
We catch a lot of workflow exception errors,
|
||||
so consolidating the code, and doing the best things
|
||||
we can with the data we have.
|
||||
"""
|
||||
if isinstance(exp, WorkflowTaskExecException):
|
||||
return ApiError.from_task(
|
||||
code,
|
||||
message,
|
||||
exp.task,
|
||||
line_number=exp.line_number,
|
||||
offset=exp.offset,
|
||||
error_type=exp.exception.__class__.__name__,
|
||||
error_line=exp.error_line,
|
||||
task_trace=exp.task_trace,
|
||||
)
|
||||
|
||||
else:
|
||||
return ApiError.from_task_spec(code, message, exp.sender)
|
||||
|
||||
|
||||
class ApiErrorSchema(Schema):
|
||||
"""ApiErrorSchema Class."""
|
||||
|
||||
class Meta:
|
||||
"""Sets the fields to search the error schema for."""
|
||||
|
||||
fields = (
|
||||
"code",
|
||||
"message",
|
||||
"workflow_name",
|
||||
"file_name",
|
||||
"task_name",
|
||||
"task_id",
|
||||
"task_data",
|
||||
"task_user",
|
||||
"hint",
|
||||
"line_number",
|
||||
"offset",
|
||||
"error_type",
|
||||
"error_line",
|
||||
"task_trace",
|
||||
)
|
||||
|
||||
|
||||
@api_error_blueprint.app_errorhandler(ApiError)
|
||||
def handle_invalid_usage(error: ApiError) -> tuple[str, int]:
|
||||
"""Handles invalid usage error."""
|
||||
response = ApiErrorSchema().dump(error)
|
||||
return response, error.status_code
|
||||
|
||||
|
||||
@api_error_blueprint.app_errorhandler(InternalServerError)
|
||||
def handle_internal_server_error(error: ApiError) -> tuple[str, int]:
|
||||
"""Handles internal server error."""
|
||||
original = getattr(error, "original_exception", None)
|
||||
api_error = ApiError(code="Internal Server Error (500)", message=str(original))
|
||||
response = ApiErrorSchema().dump(api_error)
|
||||
return response, 500
|
122
src/spiff_workflow_webapp/api/data_store.py
Normal file
122
src/spiff_workflow_webapp/api/data_store.py
Normal file
@ -0,0 +1,122 @@
|
||||
"""Methods to talk to the database."""
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from crc.models.data_store import DataStoreModel
|
||||
from crc.models.data_store import DataStoreSchema
|
||||
from crc.services.data_store_service import DataStoreBase
|
||||
from flask import Blueprint
|
||||
from sqlalchemy.orm import Session # type: ignore
|
||||
|
||||
from spiff_workflow_webapp.api.api_error import ApiError
|
||||
|
||||
# from crc import session
|
||||
|
||||
|
||||
def construct_blueprint(database_session: Session) -> Blueprint:
|
||||
"""Construct_blueprint."""
|
||||
data_store_blueprint = Blueprint("data_store", __name__)
|
||||
database_session = database_session
|
||||
|
||||
def study_multi_get(study_id: str) -> Any:
|
||||
"""Get all data_store values for a given study_id study."""
|
||||
if study_id is None:
|
||||
raise ApiError("unknown_study", "Please provide a valid Study ID.")
|
||||
|
||||
dsb = DataStoreBase()
|
||||
retval = dsb.get_multi_common(study_id, None)
|
||||
results = DataStoreSchema(many=True).dump(retval)
|
||||
return results
|
||||
|
||||
def user_multi_get(user_id: str) -> Any:
|
||||
"""Get all data values in the data_store for a userid."""
|
||||
if user_id is None:
|
||||
raise ApiError("unknown_study", "Please provide a valid UserID.")
|
||||
|
||||
dsb = DataStoreBase()
|
||||
retval = dsb.get_multi_common(None, user_id)
|
||||
results = DataStoreSchema(many=True).dump(retval)
|
||||
return results
|
||||
|
||||
def file_multi_get(file_id: str) -> Any:
|
||||
"""Get all data values in the data store for a file_id."""
|
||||
if file_id is None:
|
||||
raise ApiError(
|
||||
code="unknown_file", message="Please provide a valid file id."
|
||||
)
|
||||
dsb = DataStoreBase()
|
||||
retval = dsb.get_multi_common(None, None, file_id=file_id)
|
||||
results = DataStoreSchema(many=True).dump(retval)
|
||||
return results
|
||||
|
||||
def datastore_del(id: str) -> Any:
|
||||
"""Delete a data store item for a key."""
|
||||
database_session.query(DataStoreModel).filter_by(id=id).delete()
|
||||
database_session.commit()
|
||||
json_value = json.dumps("deleted", ensure_ascii=False, indent=2)
|
||||
return json_value
|
||||
|
||||
def datastore_get(id: str) -> Any:
|
||||
"""Retrieve a data store item by a key."""
|
||||
item = database_session.query(DataStoreModel).filter_by(id=id).first()
|
||||
results = DataStoreSchema(many=False).dump(item)
|
||||
return results
|
||||
|
||||
def update_datastore(id: str, body: dict) -> Any:
|
||||
"""Allow a modification to a datastore item."""
|
||||
if id is None:
|
||||
raise ApiError("unknown_id", "Please provide a valid ID.")
|
||||
|
||||
item = database_session.query(DataStoreModel).filter_by(id=id).first()
|
||||
if item is None:
|
||||
raise ApiError("unknown_item", 'The item "' + id + '" is not recognized.')
|
||||
|
||||
DataStoreSchema().load(body, instance=item, database_session=database_session)
|
||||
item.last_updated = datetime.utcnow()
|
||||
database_session.add(item)
|
||||
database_session.commit()
|
||||
return DataStoreSchema().dump(item)
|
||||
|
||||
def add_datastore(body: dict) -> Any:
|
||||
"""Add a new datastore item."""
|
||||
if body.get(id, None):
|
||||
raise ApiError(
|
||||
"id_specified", "You may not specify an id for a new datastore item"
|
||||
)
|
||||
|
||||
if "key" not in body:
|
||||
raise ApiError(
|
||||
"no_key", "You need to specify a key to add a datastore item"
|
||||
)
|
||||
|
||||
if "value" not in body:
|
||||
raise ApiError(
|
||||
"no_value", "You need to specify a value to add a datastore item"
|
||||
)
|
||||
|
||||
if (
|
||||
("user_id" not in body)
|
||||
and ("study_id" not in body)
|
||||
and ("file_id" not in body)
|
||||
):
|
||||
raise ApiError(
|
||||
"conflicting_values",
|
||||
"A datastore item should have either a study_id, user_id or file_id ",
|
||||
)
|
||||
|
||||
present = 0
|
||||
for field in ["user_id", "study_id", "file_id"]:
|
||||
if field in body:
|
||||
present = present + 1
|
||||
if present > 1:
|
||||
message = "A datastore item should have one of a study_id, user_id or a file_id but not more than one of these"
|
||||
raise ApiError("conflicting_values", message)
|
||||
|
||||
item = DataStoreSchema().load(body)
|
||||
# item.last_updated = datetime.utcnow() # Do this in the database
|
||||
database_session.add(item)
|
||||
database_session.commit()
|
||||
return DataStoreSchema().dump(item)
|
||||
|
||||
return data_store_blueprint
|
26
src/spiff_workflow_webapp/models/data_store.py
Normal file
26
src/spiff_workflow_webapp/models/data_store.py
Normal file
@ -0,0 +1,26 @@
|
||||
from flask_marshmallow.sqla import SQLAlchemyAutoSchema
|
||||
from sqlalchemy import func
|
||||
|
||||
from crc import db
|
||||
|
||||
|
||||
class DataStoreModel(db.Model):
|
||||
__tablename__ = 'data_store'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
last_updated = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
key = db.Column(db.String, nullable=False)
|
||||
workflow_id = db.Column(db.Integer)
|
||||
study_id = db.Column(db.Integer, nullable=True)
|
||||
task_spec = db.Column(db.String)
|
||||
spec_id = db.Column(db.String)
|
||||
user_id = db.Column(db.String, nullable=True)
|
||||
file_id = db.Column(db.Integer, db.ForeignKey('file.id'), nullable=True)
|
||||
value = db.Column(db.String)
|
||||
|
||||
|
||||
class DataStoreSchema(SQLAlchemyAutoSchema):
|
||||
class Meta:
|
||||
model = DataStoreModel
|
||||
load_instance = True
|
||||
include_fk = True
|
||||
sqla_session = db.session
|
122
src/spiff_workflow_webapp/models/workflow.py
Normal file
122
src/spiff_workflow_webapp/models/workflow.py
Normal file
@ -0,0 +1,122 @@
|
||||
import enum
|
||||
|
||||
import marshmallow
|
||||
from marshmallow import EXCLUDE, post_load, fields, INCLUDE
|
||||
from sqlalchemy import func
|
||||
from sqlalchemy.orm import deferred
|
||||
|
||||
from crc import db, ma
|
||||
|
||||
|
||||
class WorkflowSpecCategory(object):
|
||||
def __init__(self, id, display_name, display_order=0, admin=False):
|
||||
self.id = id # A unique string name, lower case, under scores (ie, 'my_category')
|
||||
self.display_name = display_name
|
||||
self.display_order = display_order
|
||||
self.admin = admin
|
||||
self.workflows = [] # For storing Workflow Metadata
|
||||
self.specs = [] # For the list of specifications associated with a category
|
||||
self.meta = None # For storing category metadata
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, WorkflowSpecCategory):
|
||||
return False
|
||||
if other.id == self.id:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class WorkflowSpecCategorySchema(ma.Schema):
|
||||
class Meta:
|
||||
model = WorkflowSpecCategory
|
||||
fields = ["id", "display_name", "display_order", "admin"]
|
||||
|
||||
@post_load
|
||||
def make_cat(self, data, **kwargs):
|
||||
return WorkflowSpecCategory(**data)
|
||||
|
||||
|
||||
class WorkflowSpecInfo(object):
|
||||
def __init__(self, id, display_name, description, is_master_spec=False,
|
||||
standalone=False, library=False, primary_file_name='', primary_process_id='',
|
||||
libraries=[], category_id="", display_order=0, is_review=False):
|
||||
self.id = id # Sting unique id
|
||||
self.display_name = display_name
|
||||
self.description = description
|
||||
self.display_order = display_order
|
||||
self.is_master_spec = is_master_spec
|
||||
self.standalone = standalone
|
||||
self.library = library
|
||||
self.primary_file_name = primary_file_name
|
||||
self.primary_process_id = primary_process_id
|
||||
self.is_review = is_review
|
||||
self.libraries = libraries
|
||||
self.category_id = category_id
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, WorkflowSpecInfo):
|
||||
return False
|
||||
if other.id == self.id:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class WorkflowSpecInfoSchema(ma.Schema):
|
||||
class Meta:
|
||||
model = WorkflowSpecInfo
|
||||
id = marshmallow.fields.String(required=True)
|
||||
display_name = marshmallow.fields.String(required=True)
|
||||
description = marshmallow.fields.String()
|
||||
is_master_spec = marshmallow.fields.Boolean(required=True)
|
||||
standalone = marshmallow.fields.Boolean(required=True)
|
||||
library = marshmallow.fields.Boolean(required=True)
|
||||
display_order = marshmallow.fields.Integer(allow_none=True)
|
||||
primary_file_name = marshmallow.fields.String(allow_none=True)
|
||||
primary_process_id = marshmallow.fields.String(allow_none=True)
|
||||
is_review = marshmallow.fields.Boolean(allow_none=True)
|
||||
category_id = marshmallow.fields.String(allow_none=True)
|
||||
libraries = marshmallow.fields.List(marshmallow.fields.String(), allow_none=True)
|
||||
|
||||
@post_load
|
||||
def make_spec(self, data, **kwargs):
|
||||
return WorkflowSpecInfo(**data)
|
||||
|
||||
|
||||
class WorkflowState(enum.Enum):
|
||||
hidden = "hidden"
|
||||
disabled = "disabled"
|
||||
required = "required"
|
||||
optional = "optional"
|
||||
locked = "locked"
|
||||
|
||||
@classmethod
|
||||
def has_value(cls, value):
|
||||
return value in cls._value2member_map_
|
||||
|
||||
@staticmethod
|
||||
def list():
|
||||
return list(map(lambda c: c.value, WorkflowState))
|
||||
|
||||
|
||||
class WorkflowStatus(enum.Enum):
|
||||
not_started = "not_started"
|
||||
user_input_required = "user_input_required"
|
||||
waiting = "waiting"
|
||||
complete = "complete"
|
||||
erroring = "erroring"
|
||||
|
||||
|
||||
class WorkflowModel(db.Model):
|
||||
__tablename__ = 'workflow'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
bpmn_workflow_json = deferred(db.Column(db.JSON))
|
||||
status = db.Column(db.Enum(WorkflowStatus))
|
||||
study_id = db.Column(db.Integer, db.ForeignKey('study.id'))
|
||||
study = db.relationship("StudyModel", backref='workflow', lazy='select')
|
||||
workflow_spec_id = db.Column(db.String)
|
||||
total_tasks = db.Column(db.Integer, default=0)
|
||||
completed_tasks = db.Column(db.Integer, default=0)
|
||||
last_updated = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
user_id = db.Column(db.String, default=None)
|
||||
state = db.Column(db.String, nullable=True)
|
||||
state_message = db.Column(db.String, nullable=True)
|
0
src/spiff_workflow_webapp/py.typed
Normal file
0
src/spiff_workflow_webapp/py.typed
Normal file
160
src/spiff_workflow_webapp/services/data_store_service.py
Normal file
160
src/spiff_workflow_webapp/services/data_store_service.py
Normal file
@ -0,0 +1,160 @@
|
||||
from crc import session
|
||||
from spiff_workflow_webapp.api.api_error import ApiError
|
||||
from crc.models.data_store import DataStoreModel
|
||||
from crc.models.workflow import WorkflowModel
|
||||
|
||||
from flask import g
|
||||
from sqlalchemy import desc
|
||||
|
||||
|
||||
class DataStoreBase(object):
|
||||
|
||||
def set_validate_common(self, task_id, study_id, workflow_id, script_name, user_id, file_id, *args):
|
||||
self.check_args_2(args, script_name)
|
||||
key = args[0]
|
||||
value = args[1]
|
||||
if script_name == 'study_data_set':
|
||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, key: value}
|
||||
elif script_name == 'file_data_set':
|
||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'file_id': file_id, key: value}
|
||||
elif script_name == 'user_data_set':
|
||||
record = {'task_id': task_id, 'study_id': study_id, 'workflow_id': workflow_id, 'user_id': user_id, key: value}
|
||||
g.validation_data_store.append(record)
|
||||
return record
|
||||
|
||||
def get_validate_common(self, script_name, study_id=None, user_id=None, file_id=None, *args):
|
||||
# This method uses a temporary validation_data_store that is only available for the current validation request.
|
||||
# This allows us to set data_store values during validation that don't affect the real data_store.
|
||||
# For data_store `gets`, we first look in the temporary validation_data_store.
|
||||
# If we don't find an entry in validation_data_store, we look in the real data_store.
|
||||
key = args[0]
|
||||
if script_name == 'study_data_get':
|
||||
# If it's in the validation data store, return it
|
||||
for record in g.validation_data_store:
|
||||
if 'study_id' in record and record['study_id'] == study_id and key in record:
|
||||
return record[key]
|
||||
# If not in validation_data_store, look in the actual data_store
|
||||
return self.get_data_common(study_id, user_id, 'study_data_get', file_id, *args)
|
||||
elif script_name == 'file_data_get':
|
||||
for record in g.validation_data_store:
|
||||
if 'file_id' in record and record['file_id'] == file_id and key in record:
|
||||
return record[key]
|
||||
return self.get_data_common(study_id, user_id, 'file_data_get', file_id, *args)
|
||||
elif script_name == 'user_data_get':
|
||||
for record in g.validation_data_store:
|
||||
if 'user_id' in record and record['user_id'] == user_id and key in record:
|
||||
return record[key]
|
||||
return self.get_data_common(study_id, user_id, 'user_data_get', file_id, *args)
|
||||
|
||||
@staticmethod
|
||||
def check_args(args, maxlen=1, script_name='study_data_get'):
|
||||
if len(args) < 1 or len(args) > maxlen:
|
||||
raise ApiError(code="missing_argument",
|
||||
message=f"The {script_name} script takes either one or two arguments, "
|
||||
f"starting with the key and an optional default")
|
||||
|
||||
@staticmethod
|
||||
def check_args_2(args, script_name='study_data_set'):
|
||||
if len(args) != 2:
|
||||
raise ApiError(code="missing_argument",
|
||||
message=f"The {script_name} script takes two arguments, key and value, in that order.")
|
||||
|
||||
def set_data_common(self,
|
||||
task_spec,
|
||||
study_id,
|
||||
user_id,
|
||||
workflow_id,
|
||||
script_name,
|
||||
file_id,
|
||||
*args):
|
||||
|
||||
self.check_args_2(args, script_name=script_name)
|
||||
key = args[0]
|
||||
value = args[1]
|
||||
if value == '' or value is None:
|
||||
# We delete the data store if the value is empty
|
||||
return self.delete_data_store(study_id, user_id, file_id, *args)
|
||||
workflow_spec_id = None
|
||||
if workflow_id is not None:
|
||||
workflow = session.query(WorkflowModel).filter(WorkflowModel.id == workflow_id).first()
|
||||
workflow_spec_id = workflow.workflow_spec_id
|
||||
|
||||
# Check if this data store is previously set
|
||||
query = session.query(DataStoreModel).filter(DataStoreModel.key == key)
|
||||
if study_id:
|
||||
query = query.filter(DataStoreModel.study_id == study_id)
|
||||
elif file_id:
|
||||
query = query.filter(DataStoreModel.file_id == file_id)
|
||||
elif user_id:
|
||||
query = query.filter(DataStoreModel.user_id == user_id)
|
||||
result = query.order_by(desc(DataStoreModel.last_updated)).all()
|
||||
if result:
|
||||
dsm = result[0]
|
||||
dsm.value = value
|
||||
if task_spec:
|
||||
dsm.task_spec = task_spec
|
||||
if workflow_id:
|
||||
dsm.workflow_id = workflow_id
|
||||
if workflow_spec_id:
|
||||
dsm.spec_id = workflow_spec_id
|
||||
if len(result) > 1:
|
||||
# We had a bug where we had created new records instead of updating values of existing records
|
||||
# This just gets rid of all the old unused records
|
||||
self.delete_extra_data_stores(result[1:])
|
||||
else:
|
||||
dsm = DataStoreModel(key=key,
|
||||
value=value,
|
||||
study_id=study_id,
|
||||
task_spec=task_spec,
|
||||
user_id=user_id, # Make this available to any User
|
||||
file_id=file_id,
|
||||
workflow_id=workflow_id,
|
||||
spec_id=workflow_spec_id)
|
||||
session.add(dsm)
|
||||
session.commit()
|
||||
|
||||
return dsm.value
|
||||
|
||||
def get_data_common(self, study_id, user_id, script_name, file_id=None, *args):
|
||||
self.check_args(args, 2, script_name)
|
||||
record = session.query(DataStoreModel).filter_by(study_id=study_id,
|
||||
user_id=user_id,
|
||||
file_id=file_id,
|
||||
key=args[0]).first()
|
||||
if record:
|
||||
return record.value
|
||||
else:
|
||||
# This is a possible default value passed in from the data_store get methods
|
||||
if len(args) == 2:
|
||||
return args[1]
|
||||
|
||||
@staticmethod
|
||||
def get_multi_common(study_id, user_id, file_id=None):
|
||||
results = session.query(DataStoreModel).filter_by(study_id=study_id,
|
||||
user_id=user_id,
|
||||
file_id=file_id)
|
||||
return results
|
||||
|
||||
@staticmethod
|
||||
def delete_data_store(study_id, user_id, file_id, *args):
|
||||
|
||||
query = session.query(DataStoreModel).filter(DataStoreModel.key == args[0])
|
||||
if user_id:
|
||||
query = query.filter(DataStoreModel.user_id == user_id)
|
||||
elif file_id:
|
||||
query = query.filter(DataStoreModel.file_id == file_id)
|
||||
elif study_id:
|
||||
query = query.filter(DataStoreModel.study_id == study_id)
|
||||
record = query.first()
|
||||
if record is not None:
|
||||
session.delete(record)
|
||||
session.commit()
|
||||
|
||||
@staticmethod
|
||||
def delete_extra_data_stores(records):
|
||||
"""We had a bug where we created new records instead of updating existing records.
|
||||
We use this to clean up all the extra records.
|
||||
We may remove this method in the future."""
|
||||
for record in records:
|
||||
session.query(DataStoreModel).filter(DataStoreModel.id == record.id).delete()
|
||||
session.commit()
|
33
src/spiff_workflow_webapp/test_blueprint_file.py
Normal file
33
src/spiff_workflow_webapp/test_blueprint_file.py
Normal file
@ -0,0 +1,33 @@
|
||||
"""Tests a blueprint file."""
|
||||
# from flask import Blueprint
|
||||
# from flask import current_app
|
||||
# from flask_marshmallow import Marshmallow # type: ignore
|
||||
#
|
||||
# # from crc import session, ma
|
||||
# # from crc.models.user import UserModel, UserModelSchema
|
||||
#
|
||||
# # from jinja2 import TemplateNotFound
|
||||
#
|
||||
# test_blueprint = Blueprint("test_blueprint", __name__)
|
||||
# # template_folder='templates')
|
||||
#
|
||||
#
|
||||
# @test_blueprint.route("/test_blueprint1") # , defaults={'page': 'index'})
|
||||
# # @simple_page.route('/<page>')
|
||||
# def show() -> str:
|
||||
# """Test flask action from blueprint."""
|
||||
# ma = Marshmallow(current_app)
|
||||
# current_app.logger.error("THIS IS TEH LOGGER", exc_info=True)
|
||||
# current_app.logger.error(ma, exc_info=True)
|
||||
# print(current_app)
|
||||
# return "HELLO8"
|
||||
# # result = db.session.execute(select(UserModel).order_by(UserModel.id))
|
||||
# # all_users = session.query(UserModel).all()
|
||||
# # print(UserModelSchema(many=True).dump(all_users))
|
||||
# # return UserModelSchema(many=True).dump(all_users)[0]
|
||||
#
|
||||
# # return "THIS OUR BLUEPRINT"
|
||||
# # try:
|
||||
# # return render_template(f'pages/{page}.html')
|
||||
# # except TemplateNotFound:
|
||||
# # abort(404)
|
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""Test suite for the spiff_workflow_webapp package."""
|
26
tests/spiff_workflow_webapp/api/test_api_error.py
Normal file
26
tests/spiff_workflow_webapp/api/test_api_error.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Test cases for the __main__ module."""
|
||||
import io
|
||||
|
||||
from spiff_workflow_webapp.api.api_error import ApiError
|
||||
|
||||
|
||||
def test_is_jsonable_can_succeed() -> None:
|
||||
result = ApiError.is_jsonable("This is a string and should pass json.dumps")
|
||||
assert result is True
|
||||
|
||||
|
||||
def test_is_jsonable_can_fail() -> None:
|
||||
result = ApiError.is_jsonable(io.StringIO("BAD JSON OBJECT"))
|
||||
assert result is False
|
||||
|
||||
|
||||
def test_remove_unserializeable_from_dict_succeeds() -> None:
|
||||
initial_dict_object = {
|
||||
"valid_key": "valid_value",
|
||||
"invalid_key_value": io.StringIO("BAD JSON OBJECT"),
|
||||
}
|
||||
final_dict_object = {
|
||||
"valid_key": "valid_value",
|
||||
}
|
||||
result = ApiError.remove_unserializeable_from_dict(initial_dict_object)
|
||||
assert result == final_dict_object
|
17
tests/test_main.py
Normal file
17
tests/test_main.py
Normal file
@ -0,0 +1,17 @@
|
||||
"""Test cases for the __main__ module."""
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from spiff_workflow_webapp import __main__
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner() -> CliRunner:
|
||||
"""Fixture for invoking command-line interfaces."""
|
||||
return CliRunner()
|
||||
|
||||
|
||||
def test_main_succeeds(runner: CliRunner) -> None:
|
||||
"""It exits with a status code of zero."""
|
||||
result = runner.invoke(__main__.main)
|
||||
assert result.exit_code == 0
|
Loading…
x
Reference in New Issue
Block a user