-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editable dev container for connector proxy demo #2097
Changes from all commits
03d51b5
f7c0f5f
7de0e9a
842f7f8
8635b6e
acfb957
19c8898
9263002
a980a14
e163e87
e2f697c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python 3.11.0 |
Large diffs are not rendered by default.
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. | ||
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance overall README structure and content. While the README provides basic information about the example connector and its development process, there are opportunities to improve its structure and content to make it more informative and user-friendly. Consider restructuring the README as follows:
This structure will provide a more comprehensive guide for developers working with the connector, aligning with the PR's objective of enhancing local development and training processes. |
Large diffs are not rendered by default.
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" | ||
Comment on lines
+9
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Pin the The [tool.poetry.dependencies]
python = "^3.9"
spiffworkflow-connector-command = {git = "https://github.com/sartography/spiffworkflow-connector-command.git", rev = "7e20603849ee609267ddc97c8433077e09ccd124"}
[tool.poetry.group.dev.dependencies]
mypy = "^1.6.0"
ruff = "^0.0.292"
pytest = "^7.4.2" 🔗 Analysis chainDependencies are well-defined, but consider pinning the Git dependency The dependencies are appropriately specified, including essential development tools. However, the main dependency Consider pinning this dependency to a specific commit or tag for better reproducibility. You can verify the latest release or commit using: If there's a stable release, you might want to use that instead of the 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check the latest release or commit of spiffworkflow-connector-command
# Test: Get the latest release tag or commit hash
gh repo view sartography/spiffworkflow-connector-command --json 'latestRelease,defaultBranchRef'
Length of output: 154 Script: #!/bin/bash
# Description: Retrieve the latest commit hash of the main branch for spiffworkflow-connector-command
gh api repos/sartography/spiffworkflow-connector-command/commits/main --jq '.sha'
Length of output: 122 |
||
|
||
|
||
[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 |
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 |
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 | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider optimizing package installation and setting up editable installs While upgrading pip and installing specific versions of poetry and pytest-xdist is good for reproducibility, consider the following improvements:
-RUN pip install --upgrade pip
-RUN pip install poetry==1.8.1 pytest-xdist==3.5.0
+RUN pip install --upgrade pip && \
+ pip install poetry==1.8.1 pytest-xdist==3.5.0
Would you like assistance in implementing these changes?
|
||
|
||
CMD ["./bin/run_server_locally"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Startup script The Dockerfile sets the default command to 🔗 Analysis chainVerify the existence and permissions of the startup script The use of CMD to set the default command is appropriate. However, ensure that the script To verify the script's existence and permissions, you can run the following commands in your local environment before building the image: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Verify the existence and permissions of the startup script
# Check if the script exists
if [ -f "./bin/run_server_locally" ]; then
echo "Script exists."
# Check if the script is executable
if [ -x "./bin/run_server_locally" ]; then
echo "Script is executable."
else
echo "Script is not executable. Consider running: chmod +x ./bin/run_server_locally"
fi
else
echo "Script does not exist. Please ensure it's present in the ./bin directory."
fi
Length of output: 197 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify or remove the "Happy Hacking" section.
The "Happy Hacking" section title is present, but there's no content underneath it. This could be confusing for readers.
Consider one of the following options: