-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editable dev container for connector proxy demo (#2097)
For easier local development and training purposes, this adds an editable dev container for the connector proxy demo as well as a local example connector that can be changed in the live environment without needing to poetry install a connector for another location.
- Loading branch information
Showing
15 changed files
with
1,056 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python 3.11.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# connector-example | ||
Example Connector | ||
|
||
|
||
## Happy Hacking | ||
|
||
When running the dev containers, you can edit this connector and see | ||
changes reflected next time you run a process model with a Service Task | ||
that calls this connector. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[tool.poetry] | ||
name = "connector-example" | ||
version = "1.0.0" | ||
description = "Example Connector for SpiffWorkflow Service Tasks" | ||
authors = ["Jon Herron <[email protected]>"] | ||
readme = "README.md" | ||
packages = [{include = "connector_example", from = "src" }] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
spiffworkflow-connector-command = {git = "https://github.com/sartography/spiffworkflow-connector-command.git", rev = "main"} | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
mypy = "^1.6.0" | ||
ruff = "^0.0.292" | ||
pytest = "^7.4.2" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.ruff] | ||
select = [ | ||
"B", # flake8-bugbear | ||
"C", # mccabe | ||
"E", # pycodestyle error | ||
# "ERA", # eradicate | ||
"F", # pyflakes | ||
"N", # pep8-naming | ||
"PL", # pylint | ||
"S", # flake8-bandit | ||
"UP", # pyupgrade | ||
"W", # pycodestyle warning | ||
"I001" # isort | ||
] | ||
|
||
ignore = [ | ||
"C901", # "complexity" category | ||
"PLR", # "refactoring" category has "too many lines in method" type stuff | ||
"PLE1205" # saw this Too many arguments for `logging` format string give a false positive once | ||
] | ||
|
||
line-length = 130 | ||
|
||
# target python 3.10 | ||
target-version = "py310" | ||
|
||
exclude = [ | ||
"migrations" | ||
] | ||
|
||
[tool.ruff.per-file-ignores] | ||
"migrations/versions/*.py" = ["E501"] | ||
"tests/**/*.py" = ["PLR2004", "S101"] # PLR2004 is about magic vars, S101 allows assert | ||
|
||
[tool.ruff.isort] | ||
force-single-line = true | ||
|
||
[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 |
Empty file.
Empty file.
32 changes: 32 additions & 0 deletions
32
connector-proxy-demo/connector-example/src/connector_example/commands/example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Any | ||
|
||
from spiffworkflow_connector_command.command_interface import CommandErrorDict | ||
from spiffworkflow_connector_command.command_interface import CommandResponseDict | ||
from spiffworkflow_connector_command.command_interface import ConnectorCommand | ||
from spiffworkflow_connector_command.command_interface import ConnectorProxyResponseDict | ||
|
||
|
||
class Example(ConnectorCommand): | ||
def __init__(self, | ||
message: str, | ||
): | ||
self.message = message | ||
|
||
def execute(self, _config: Any, _task_data: Any) -> ConnectorProxyResponseDict: | ||
error: CommandErrorDict | None = None | ||
|
||
return_response: CommandResponseDict = { | ||
"body": { | ||
"connector_response": f"You passed the example connector: '{self.message}'. Have a good day!", | ||
}, | ||
"mimetype": "application/json", | ||
} | ||
|
||
result: ConnectorProxyResponseDict = { | ||
"command_response": return_response, | ||
"error": error, | ||
"command_response_version": 2, | ||
"spiff__logs": [], | ||
} | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM python:3.11.6-slim-bookworm AS base | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install --upgrade pip | ||
RUN pip install poetry==1.8.1 pytest-xdist==3.5.0 | ||
|
||
CMD ["./bin/run_server_locally"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
services: | ||
spiffworkflow-connector: | ||
build: | ||
context: connector-proxy-demo | ||
dockerfile: dev.Dockerfile | ||
user: "${RUN_AS}" | ||
environment: | ||
FLASK_DEBUG: "1" | ||
POETRY_VIRTUALENVS_IN_PROJECT: "true" | ||
XDG_CACHE_HOME: "/app/.cache" | ||
env_file: | ||
- path: .env | ||
required: false | ||
volumes: | ||
- ./connector-proxy-demo:/app |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters