sekoia-hwl
sekoia-hwl is a library and command-line tool for the Sekoia HTTP Workflow Language (HWL). It validates YAML
documents, and runs workflows and connectors, so that an integration can be written and tested locally
before it is deployed on Sekoia.io:
| Kind | Purpose |
|---|---|
workflow |
A pipeline of HTTP, GraphQL and output stages (a document without kind is a workflow) |
connection |
An API: its account fields (config), base URL, auth method, HTTP options and query engine |
table |
A table queryable with SOL, backed by an API (filters, pagination, hydration, aggregations) or by a query in the language of the connection's engine |
connector |
A collector of events or assets (checkpoint, window, events pipeline, asset mapping) |
dialect |
How SOL commands are written in a query language |
Table and dialect documents are validated here; they are queried on Sekoia.io. The library has no connection to Sekoia.io: collected events and workflow outputs are printed on stdout, accounts come from a local file and connector state lives in a local directory.
Installation
pip install sekoia-hwl
The hwl command is installed with the package. The older shwl-runner and shwl-validator commands are installed
too, as aliases of hwl run and hwl validate.
Command line
run, validate and connector run share their exit codes: 0 success, 1 invalid documents, 2 file not found, 3
invalid file (not readable, not YAML, an invalid accounts or state file), 4 runtime error. Usage errors (an unknown
option, a missing argument) exit with 2, as in every click command. connector run prints records only on stdout,
one JSON object per line; logs and warnings go to stderr.
Validate documents
hwl validate workflow.yml # one workflow, human-readable summary
hwl validate --json workflow.yml # {"valid": ..., "errors": [...]}
hwl validate documents/ more/connection.yml # several files and directories, validated as one set
hwl validate --jsonl documents/ # one diagnostic per line; nothing at all when valid
Run a workflow
hwl run workflow.yml -i query=sekoia.io -i limit=10
hwl run workflow.yml --inputs inputs.yaml -i limit=10 # --input values win over the file
The workflow outputs are printed as one JSON object. Validation diagnostics go to stderr; --no-validate skips
validation and --strict-validation also reports W101 warnings.
Run a connector
hwl connector run example_events --documents documents/ --accounts accounts.yml
hwl connector run example_assets --documents documents/ --accounts accounts.yml --account eu --follow
The connector's checkpoint, deduplication keys and rotated secrets are stored in
<state-dir>/<connector>/<account>.json (--state-dir, default .hwl-state). With --follow, a run that emitted
something is followed immediately by another one; otherwise the next run waits for schedule.every.
Documents
A connection declares the fields of an account and how to authenticate:
hwl: "1.1"
kind: connection
name: example
config:
base_url: {type: string, format: uri}
api_token: {type: string, secret: true}
base_url: "{{ config.base_url }}"
auth:
bearer: {token: "{{ config.api_token }}"}
Tables and connectors reference their connection by name. The JSON Schema of each kind, shipped in
sekoia_hwl/schemas/, describes every key; editors that read JSON Schemas complete and check documents with them.
In the new kinds, a string that is exactly one {{ expression }} evaluates to the expression's native value
(a datetime, a list, a number...), other templated strings are rendered to text, and request parameters, headers,
cookies and JSON body members whose value is null are omitted. Paths such as $.data[*].id are RFC 9535 JSONPath.
Accounts file
connections:
example:
- name: eu
config: {base_url: "https://eu.api.example.com", api_token: "${EXAMPLE_EU_TOKEN}"}
- name: us
config: {base_url: "https://us.api.example.com", api_token: "${EXAMPLE_US_TOKEN}"}
${VAR} is replaced from the environment (a missing variable is an error), and each config is validated against
the connection's config. Fields declared with secret: true, workflow inputs declared with secret: true and all
credentials are masked (***) in logs, errors, warnings and command output.
Python API
Run a workflow:
from sekoia_hwl.workflow.configuration import Configuration
from sekoia_hwl.workflow.runner import WorkflowRunner
runner = WorkflowRunner(definition, Configuration())
outputs = runner.run({"query": "sekoia.io"}) # from synchronous code
outputs = await runner.arun({"query": "sekoia.io"}) # from a running event loop
Validate documents, then run a connector once:
import sys
from pathlib import Path
from sekoia_hwl.accounts import load_accounts, resolve_config
from sekoia_hwl.connectors import ConnectorRunner, JsonLinesSink, StateStore
from sekoia_hwl.validation.documents import load_document_set
# Raises InvalidDocumentsError (with the diagnostics of every file) when a document is invalid
documents = load_document_set([Path("documents")])
connector = documents.connectors["example_events"]
connection = documents.connection_of(connector)
account = load_accounts(Path("accounts.yml")).account(connection.name, "eu")
runner = ConnectorRunner(
connector,
connection,
account.name,
resolve_config(connection, account),
sink=JsonLinesSink(sys.stdout.buffer),
state=StateStore.for_account(Path(".hwl-state"), connector.name, account.name),
)
result = await runner.run_once() # RunResult(emitted=..., warnings=[...])
sekoia_hwl.validation.documents.validate_documents returns per-file diagnostics without raising, and
python -m sekoia_hwl.schemas regenerates the JSON Schemas of the new kinds in sekoia_hwl/schemas/.
Extensions
Other distributions add hwl commands through the sekoia_hwl.commands entry point group (a click command, named
after its entry point) and rules across a document set through sekoia_hwl.set_rules (a callable taking a
sekoia_hwl.validation.documents.SetContext and yielding (SourceDocument, ValidationError) pairs).
Development
uv sync --all-extras --dev
uv run pytest --keepalive tests
uv run ruff check && uv run ruff format --check
uv run mypy sekoia_hwl tests
License
Apache-2.0, see LICENSE.
Metadata
Release files for sekoia-hwl 0.11.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sekoia_hwl-0.11.1.tar.gz | 161.8 kB | Without provenance | Details for sekoia_hwl-0.11.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sekoia_hwl-0.11.1-py3-none-any.whl | Python 3 | none | any | Details for sekoia_hwl-0.11.1-py3-none-any.whl |
Total release size: 380.1 kB
Release files / sekoia_hwl-0.11.1.tar.gz
| Download URL | sekoia_hwl-0.11.1.tar.gz |
|---|---|
| Size | 161.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101be043e9a68db716473a85f8312df27b73d8e117b780a456fdc601f8ac693c
|
|
BLAKE2b-256 checksum How to use checksums |
878f187f9b159776a33a64bf28293b4c2b4ab12f01ae6a3e11b48808a61f6fce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sekoia_hwl-0.11.1-py3-none-any.whl
| Download URL | sekoia_hwl-0.11.1-py3-none-any.whl |
|---|---|
| Size | 218.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
94b1aa0432a9fa0f0473fb5bea76246211ad1829650121b0044ebc45b04a9839
|
|
BLAKE2b-256 checksum How to use checksums |
88b8ee8adf4b1e17f2cffa72511d081faad7bacbe3fb13d76ac8b5ec70407b2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sekoia-hwl 0.11.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.