Skip to content

Commit 7600267

Browse files
committed
initial commit
0 parents  commit 7600267

File tree

10 files changed

+184
-0
lines changed

10 files changed

+184
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
indent_style = space
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
[*.py]
9+
indent_size = 4
10+
max_line_length = 88

.flake8

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[flake8]
2+
exclude = .git,__pycache__,.venv
3+
max-line-length = 88
4+
import-order-style = google
5+
application-import-names = MODNAME
6+
ignore =
7+
# Missing docstring for public module
8+
D100
9+
# Missing docstring for magic method (e.g. __str__)
10+
D105
11+
# Missing docstring in __init__
12+
D107
13+
per-file-ignores =
14+
# Missing docstring in public function
15+
tests/*:D103

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.coverage
2+
.envrc
3+
.dir-locals.el
4+
.projectile
5+
6+
.vscode/**
7+
8+
**/.DS_Store
9+
**/__pycache__
10+
**/*.egg-info
11+
**/.mypy_cache

MODNAME/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__identifier__ = "MODNAME"
2+
__version__ = "0.1.0"

MODNAME/node.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import json
2+
from typing import Any, Optional
3+
4+
from . import __identifier__, __version__
5+
6+
7+
async def do_thing(message: dict[str, Any], context: dict[str, Any]) -> dict[str, Any]:
8+
"""Process some incoming data."""
9+
# All debugging information MUST be output in stderr. you can just use the logging
10+
# module or if you are a die hard print debugger use this instead:
11+
# print("My debug!", file=sys.stderr)
12+
13+
return message
14+
15+
16+
if __name__ == "__main__":
17+
import asyncio
18+
import sys
19+
20+
# message is the input to your function. This is the output from the previous
21+
# function plus any transformations the user defined in their workflow. Parameters
22+
# should be documented in the parameters.json file so they can be used in the UI.
23+
try:
24+
message = json.loads(sys.argv[1])
25+
except IndexError:
26+
raise ValueError("missing required `message` argument") from None
27+
28+
# this contains some contextual information about the workflow and the current
29+
# state. required secrets should be defined in the README so users can write their
30+
# lookup class with this node's unique requirements in mind.
31+
try:
32+
context = json.loads(sys.argv[2])
33+
except IndexError:
34+
raise ValueError("missing `context` argument") from None
35+
36+
output = asyncio.run(do_thing(message, context))
37+
38+
# Non-zero exit codes indicate to the executor there was an unrecoverable error and
39+
# workflow execution should terminate.
40+
if output is None:
41+
sys.exit(1)
42+
43+
# The output of your function is input for a potential next state. It must be in
44+
# JSON format and be the only thing output on stdout. This value is picked up by the
45+
# executor and processed.
46+
print(json.dumps(output))

MODNAME/parameters.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"properties": {
5+
}
6+
}
7+

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MODNAME
2+
This node provides ...
3+
4+
## Node Configuration
5+
Environment variables can be set to alter functionality.
6+
7+
| name | required | description |
8+
|-|-|-|
9+
10+
## Context Properities
11+
The following context properties are available for this node.
12+
| name | required | description |
13+
|-|-|-|
14+
15+
## Node1
16+
This node does the following
17+
18+
### Parameters
19+
The following parameters are available.
20+
| name | required | description |
21+
|-|-|-|

pyproject.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[tool.black]
2+
target-version = ["py310"]
3+
4+
[tool.mypy]
5+
plugins = [
6+
"pydantic.mypy"
7+
]
8+
9+
# follow_imports = "silent"
10+
# warn_redundant_casts = true
11+
# warn_unused_ignores = true
12+
# disallow_any_generics = true
13+
# check_untyped_defs = true
14+
# no_implicit_reexport = true
15+
# for strict mypy: (this is the tricky one :-))
16+
# disallow_untyped_defs = true
17+
18+
[tool.mypy-pydantic]
19+
# init_forbid_extra = true
20+
# init_typed = true
21+
# warn_required_dynamic_aliases = true
22+
# warn_untyped_fields = true

setup.cfg

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[metadata]
2+
name = MODNAME
3+
version = attr: MODNAME.__version__
4+
author = wkflws node developer
5+
description = "wkflws node - MODNAME"
6+
# url = https://my-url.com
7+
# project_urls =
8+
# Bug Tracker = https://github.com/myorg/MODNAME/issues/
9+
# Source = https://github.com/myorg/MODNAME/
10+
classifiers =
11+
Programming Language :: Python :: 3
12+
13+
[options]
14+
python_requires = >= 3.10
15+
packages = find:
16+
# install_requires =
17+
18+
[options.extras_require]
19+
testing =
20+
# The following libraries are not hosted or distributed.
21+
black # automatic formatter
22+
coverage # unit test coverage analyzer
23+
flake8 # style checker
24+
flake8-docstrings # verify docstring formatting
25+
flake8-import-order # verify import order
26+
mypy # static type checker
27+
pytest # unit test discovery and runner
28+
pytest-cov # plugin for the coverage module
29+
pytest-mock # pytest wrapper for mock module
30+
31+
32+
# https://coverage.readthedocs.io/en/6.3.2/config.html
33+
[coverage:run]
34+
# Measure branch coverage
35+
branch = True
36+
# To omit certain files
37+
# omit = # e.g. src/db/env.py,src/db/versions/*
38+
# Indicate the directories to evaluate
39+
source = MODNAME/
40+
41+
[coverage:report]
42+
# show missing line numbers
43+
show_missing = True
44+
# Omit files with 100% coverage from the report
45+
# skip_covered = True

tests/test_node.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from MODNAME import node
2+
3+
4+
def test_do_thing():
5+
assert node.do_thing is True

0 commit comments

Comments
 (0)