Skip to main content

sw-serverless

Write SW-Serverless adapters in Python 3.12 or later. The package has no dependencies: it speaks the host's protocol — gRPC over a Unix socket — with the standard library alone, so it vendors into an adapter package as plain files, for any platform.

import sw_serverless as sw


class Greeter:
    def __init__(self):
        sw.expect("Greeting", "Hello", description="What to say")
        sw.expect("ApiKey", secret=True)

    @sw.command(description="Greets someone")
    def greet(self, name: str) -> str:
        return f"{sw.value_of('Greeting')}, {name}"


if __name__ == "__main__":
    sw.run(Greeter)
  • Settings are declared with sw.expect(name, default=None, *, required, secret, description, type) and read with sw.value_of(name): the call's own properties, then the values the adapter was started with, then the default.
  • Commands are methods marked @sw.command(name, description=...). A command takes at most one argument. A str argument or result is raw text, bytes are passed as they are, and anything else is JSON; a dataclass is read from and written as a JSON object. Commands may be sync or async; sync ones run on a worker thread.
  • Errors raised by a command reach the caller with their type and message. Raise sw.AdapterError(message, type="Acme.Rejected") to choose the type.
  • Resident adapters have a start method and run until stopped, with optional stop, status (returns connected, state, details…) and reset(session_id). In a command, sw.context() publishes events (await ctx.publish(...)), keeps small state (get_state/set_state/delete_state) and records metrics.
  • Logging through Python's logging reaches the host.
  • python main.py --describe prints what the adapter is; sw-serverless build writes it into the manifest.

An application with a contract of its own declares it with @sw.implements("orders", 1, "processor") on the adapter class, and can give its adapter authors base classes that do it for them. sw-serverless init --lang python starts an adapter.

Tests: PYTHONPATH=src python -m unittest discover -s tests.

Metadata

Release files for sw-serverless 10.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sw-serverless 10.2.6
File Size Uploaded Provenance Actions
sw_serverless-10.2.6.tar.gz 25.4 kB Without provenance Details for sw_serverless-10.2.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sw-serverless 10.2.6
File Interpreter ABI Platform Actions
sw_serverless-10.2.6-py3-none-any.whl Python 3 none any Details for sw_serverless-10.2.6-py3-none-any.whl

Total release size: 48.9 kB

Release files / sw_serverless-10.2.6.tar.gz

Download URL sw_serverless-10.2.6.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e79dbcc36873f8a713e2f36b40ec972a133259bf18aef8aa01f215ce9e83aa53
BLAKE2b-256 checksum
How to use checksums
0f36398f5246f7533eec0b2d828ad4d379668bb68879d05ca22f72c3ef0e5e96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / sw_serverless-10.2.6-py3-none-any.whl

Download URL sw_serverless-10.2.6-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c7985368f43913159be0322c165df35f9a139802c73422903e0087db04908a7
BLAKE2b-256 checksum
How to use checksums
238e1f0eb7855eb88f9e753df4b4597c516ed05565869595ebc039fe3c5f5e38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for sw-serverless 10.2.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page