Skip to content

Link Python articles to v3 Python SDK #95

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

Merged
merged 1 commit into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/v3/http-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ You can find a complete example of using outbound HTTP in the JavaScript SDK rep

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/http/index.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/http/index.html)

HTTP functions and classes are available in the `http` module. The function name is [`send`](https://spinframework.github.io/spin-python-sdk/http/index.html#spin_sdk.http.send). The [request type](https://spinframework.github.io/spin-python-sdk/http/index.html#spin_sdk.http.Request) is `Request`, and the [response type](https://spinframework.github.io/spin-python-sdk/http/index.html#spin_sdk.http.Response) is `Response`. For example:
HTTP functions and classes are available in the `http` module. The function name is [`send`](https://spinframework.github.io/spin-python-sdk/v3/http/index.html#spin_sdk.http.send). The [request type](https://spinframework.github.io/spin-python-sdk/http/index.html#spin_sdk.http.Request) is `Request`, and the [response type](https://spinframework.github.io/spin-python-sdk/v3/http/index.html#spin_sdk.http.Response) is `Response`. For example:

```python
from spin_sdk.http import Request, Response, send
Expand Down
4 changes: 2 additions & 2 deletions content/v3/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/)

In Python, the application must define a top-level class named IncomingHandler which inherits from [IncomingHandler](https://spinframework.github.io/spin-python-sdk/http/index.html#spin_sdk.http.IncomingHandler), overriding the `handle_request` method.
In Python, the application must define a top-level class named IncomingHandler which inherits from [IncomingHandler](https://spinframework.github.io/spin-python-sdk/v3/http/index.html#spin_sdk.http.IncomingHandler), overriding the `handle_request` method.

```python
from spin_sdk import http
Expand Down
4 changes: 2 additions & 2 deletions content/v3/kv-store-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/key_value.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/key_value.html)

The key value functions are provided through the `spin_key_value` module in the Python SDK. For example:

Expand All @@ -148,7 +148,7 @@ class IncomingHandler(http.IncomingHandler):
**General Notes**
- The Python SDK doesn't surface the `close` operation. It automatically closes all stores at the end of the request; there's no way to close them early.

[`get` **Operation**](https://spinframework.github.io/spin-python-sdk/wit/imports/key_value.html#spin_sdk.wit.imports.key_value.Store.get)
[`get` **Operation**](https://spinframework.github.io/spin-python-sdk/v3/wit/imports/key_value.html#spin_sdk.wit.imports.key_value.Store.get)
- If a key does not exist, it returns `None`

{{ blockEnd }}
Expand Down
2 changes: 1 addition & 1 deletion content/v3/language-support-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This page contains information about language support for Spin features:

{{ startTab "Python"}}

**[📄 Visit the Python Spin SDK reference documentation](https://spinframework.github.io/spin-python-sdk/v1) to see specific modules, functions, variables and syntax relating to the following Python SDK.**
**[📄 Visit the Python Spin SDK reference documentation](https://spinframework.github.io/spin-python-sdk/v3) to see specific modules, functions, variables and syntax relating to the following Python SDK.**

| Feature | SDK Supported? |
|-----|-----|
Expand Down
4 changes: 2 additions & 2 deletions content/v3/python-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ With <a href="https://www.python.org/" target="_blank">Python</a> being a very p

> This guide assumes you are familiar with the Python programming language, but if you are just getting started, be sure to check out <a href="https://docs.python.org/3/" target="_blank">the official Python documentation</a> and comprehensive <a href="https://docs.python.org/3/reference/" target="_blank">language reference</a>.

[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk)
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3)

## Prerequisite

Expand Down Expand Up @@ -174,7 +174,7 @@ command = "componentize-py -w spin-http componentize app -o app.wasm"

In Spin, HTTP components are triggered by the occurrence of an HTTP request and must return an HTTP response at the end of their execution. Components can be built in any language that compiles to WASI. If you would like additional information about building HTTP applications you may find [the HTTP trigger page](./http-trigger.md) useful.

Building a Spin HTTP component using the Python SDK means defining a top-level class named IncomingHandler which inherits from [`IncomingHandler`](https://spinframework.github.io/spin-python-sdk/wit/exports/index.html#spin_sdk.wit.exports.IncomingHandler), overriding the `handle_request` method. Here is an example of the default Python code which the previous `spin new` created for us; a simple example of a request/response:
Building a Spin HTTP component using the Python SDK means defining a top-level class named IncomingHandler which inherits from [`IncomingHandler`](https://spinframework.github.io/spin-python-sdk/v3/wit/exports/index.html#spin_sdk.wit.exports.IncomingHandler), overriding the `handle_request` method. Here is an example of the default Python code which the previous `spin new` created for us; a simple example of a request/response:

<!-- @nocpy -->

Expand Down
2 changes: 1 addition & 1 deletion content/v3/rdbms-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/)

The code below is an [Outbound MySQL example](https://github.com/spinframework/spin-python-sdk/tree/main/examples/spin-mysql). There is also an outbound [PostgreSQL example](https://github.com/spinframework/spin-python-sdk/tree/main/examples/spin-postgres) available.

Expand Down
4 changes: 2 additions & 2 deletions content/v3/redis-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ You can find a complete TypeScript example for using outbound Redis from an HTTP

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/redis.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/redis.html)

Redis functions are available in [the `redis` module](https://spinframework.github.io/spin-python-sdk/redis.html). The function names are prefixed `redis_`. You must pass the Redis instance address to _each_ operation as its first parameter. For example:
Redis functions are available in [the `redis` module](https://spinframework.github.io/spin-python-sdk/v3/redis.html). The function names are prefixed `redis_`. You must pass the Redis instance address to _each_ operation as its first parameter. For example:

```python
from spin_sdk import redis
Expand Down
2 changes: 1 addition & 1 deletion content/v3/redis-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The JavaScript/TypeScript SDK doesn't currently support Redis components. Pleas

{{ startTab "Python"}}

In Python, the handler needs to implement the [`InboundRedis`](https://spinframework.github.io/spin-python-sdk/wit/exports/index.html#spin_sdk.wit.exports.InboundRedis) class, and override the `handle_message` method:
In Python, the handler needs to implement the [`InboundRedis`](https://spinframework.github.io/spin-python-sdk/v3/wit/exports/index.html#spin_sdk.wit.exports.InboundRedis) class, and override the `handle_message` method:

```python
from spin_sdk.wit import exports
Expand Down
8 changes: 4 additions & 4 deletions content/v3/serverless-ai-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/llm.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/llm.html)

```python
from spin_sdk import http
Expand All @@ -178,12 +178,12 @@ class IncomingHandler(http.IncomingHandler):

**General Notes**

[`infer` operation](https://spinframework.github.io/spin-python-sdk/llm.html#spin_sdk.llm.infer):
[`infer` operation](https://spinframework.github.io/spin-python-sdk/v3/llm.html#spin_sdk.llm.infer):

- The model name is passed in as a string (as shown above; `"llama2-chat"`).
[`infer_with_options` operation](https://spinframework.github.io/spin-python-sdk/llm.html#spin_sdk.llm.infer_with_options):
[`infer_with_options` operation](https://spinframework.github.io/spin-python-sdk/v3/llm.html#spin_sdk.llm.infer_with_options):

- It takes in a model name, prompt text, and optionally a [parameter object](https://spinframework.github.io/spin-python-sdk/llm.html#spin_sdk.llm.InferencingParams) to control the inferencing.
- It takes in a model name, prompt text, and optionally a [parameter object](https://spinframework.github.io/spin-python-sdk/v3/llm.html#spin_sdk.llm.InferencingParams) to control the inferencing.

{{ blockEnd }}

Expand Down
6 changes: 3 additions & 3 deletions content/v3/sqlite-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/sqlite.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/sqlite.html)

To use SQLite functions, use the `sqlite` module in the Python SDK. The [`sqlite_open`](https://spinframework.github.io/spin-python-sdk/sqlite.html#spin_sdk.sqlite.open) and [`sqlite_open_default`](https://spinframework.github.io/spin-python-sdk/sqlite.html#spin_sdk.sqlite.open_default) functions return a [connection object](https://spinframework.github.io/spin-python-sdk/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.Connection). The connection object provides the [`execute` method](https://spinframework.github.io/spin-python-sdk/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.Connection.execute) as described above. For example:
To use SQLite functions, use the `sqlite` module in the Python SDK. The [`sqlite_open`](https://spinframework.github.io/spin-python-sdk/v3/sqlite.html#spin_sdk.sqlite.open) and [`sqlite_open_default`](https://spinframework.github.io/spin-python-sdk/v3/sqlite.html#spin_sdk.sqlite.open_default) functions return a [connection object](https://spinframework.github.io/spin-python-sdk/v3/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.Connection). The connection object provides the [`execute` method](https://spinframework.github.io/spin-python-sdk/v3/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.Connection.execute) as described above. For example:

```python
from spin_sdk import http, sqlite
Expand All @@ -174,7 +174,7 @@ class IncomingHandler(http.IncomingHandler):
```

**General Notes**
* The `execute` method returns [a `QueryResult` object](https://spinframework.github.io/spin-python-sdk/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.QueryResult) with `rows` and `columns` methods. `columns` returns a list of strings representing column names. `rows` is an array of rows, each of which is an array of [`RowResult`](https://spinframework.github.io/spin-python-sdk/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.RowResult) in the same order as `columns`.
* The `execute` method returns [a `QueryResult` object](https://spinframework.github.io/spin-python-sdk/v3/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.QueryResult) with `rows` and `columns` methods. `columns` returns a list of strings representing column names. `rows` is an array of rows, each of which is an array of [`RowResult`](https://spinframework.github.io/spin-python-sdk/v3/wit/imports/sqlite.html#spin_sdk.wit.imports.sqlite.RowResult) in the same order as `columns`.
* The connection object doesn't surface the `close` function.
* Errors are surfaced as exceptions.

Expand Down
4 changes: 2 additions & 2 deletions content/v3/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ addEventListener('fetch', async (event: FetchEvent) => {

{{ startTab "Python"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/variables.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-python-sdk/v3/variables.html)

The `variables` module has a function called `get`(https://spinframework.github.io/spin-python-sdk/variables.html#spin_sdk.variables.get).
The `variables` module has a function called `get`(https://spinframework.github.io/spin-python-sdk/v3/variables.html#spin_sdk.variables.get).

```py
from spin_sdk.http import IncomingHandler, Request, Response, send
Expand Down
Loading