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.4

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.4
File Size Uploaded Provenance Actions
sw_serverless-10.2.4.tar.gz 25.4 kB Without provenance Details for sw_serverless-10.2.4.tar.gz

Built distribution (wheel)

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

Total release size: 48.9 kB

Release files / sw_serverless-10.2.4.tar.gz

Download URL sw_serverless-10.2.4.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2abceca30ab790d93431af7601b2191ad128ba53f9119ade0ecb5a3160875389
BLAKE2b-256 checksum
How to use checksums
8bdaaa0f4e69cfdda152a8d162bb021bfdd3bc80000ee02dabadd8746f5e9772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

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

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

Security for sw-serverless 10.2.4

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