Skip to content
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

[docs] Reformat index page #580

Merged
merged 13 commits into from
Jul 18, 2023
122 changes: 109 additions & 13 deletions daprdocs/content/en/python-sdk-docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,142 @@ no_list: true

Dapr offers a variety of packages to help with the development of Python applications. Using them you can create Python clients, servers, and virtual actors with Dapr.

## Available packages
## Prerequisites

- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
- [Python 3.7+](https://www.python.org/downloads/) installed

- [**Dapr client**]({{< ref python-client.md >}}) for writing Python applications to interact with the Dapr sidecar and other Dapr applications
- [**Dapr actor**]({{< ref python-actor.md >}}) for creating and interacting with stateful virtual actors in Python
- [**Extensions**]({{< ref python-sdk-extensions >}}) for adding Dapr capabilities to other Python frameworks
- [**gRPC extension**]({{< ref python-grpc.md >}}) for creating a gRPC server with Dapr
- [**FastAPI extension**]({{< ref python-fastapi.md >}}) for adding Dapr actor capabilities to FastAPI applications
- [**Flask extension**]({{< ref python-flask.md >}}) for adding Dapr actor capabilities to Flask applications
## Installation

## Install the Dapr module
To get started with the Python SDK, install the main Dapr Python SDK package.

{{< tabs Stable Development>}}

{{% codetab %}}
<!--stable-->
```bash
pip install dapr
```
{{% /codetab %}}

{{% codetab %}}
{{% alert title="Note" color="warning" %}}
The development package will contain features and behavior that will be compatible with the pre-release version of the Dapr runtime. Make sure to uninstall any stable versions of the Python SDK before installing the dapr-dev package.
<!--dev-->
> **Note:** The development package will contain features and behavior that will be compatible with the pre-release version of the Dapr runtime. Make sure to uninstall any stable versions of the Python SDK before installing the dapr-dev package.
{{% /alert %}}

```bash
pip install dapr-dev
```

{{% /codetab %}}

{{< /tabs >}}


## Available packages

Once you've installed the main Python SDK, you can:
- Import additional packages as part of the main SDK package
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
- Install extensions on top of the main Python SDK
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

### SDK imports

Python SDK imports are included with the main SDK install, but need to be imported when used. The most common imports provided by the Dapr Python SDK are:

<div class="card-deck">
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>Client</b></h5>
<p class="card-text">Write Python applications to interact with a Dapr sidecar and other Dapr applications, including stateful virtual actors in Python</p>
<a href="{{< ref python-client >}}" class="stretched-link"></a>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>Actors</b></h5>
<p class="card-text">Create and interact with Dapr's Actor framework.</p>
<a href="{{< ref python-actor >}}" class="stretched-link"></a>
</div>
</div>
</div>

Learn more about _all_ of the [available Dapr Python SDK imports](https://github.com/dapr/python-sdk/tree/master/dapr).

### SDK extensions

SDK extensions mainly work as utilities for receiving pub/sub events, programatically creating pub/sub subscriptions, and handling input binding events. While you can acheive all of these tasks without an extension, using a Python SDK extension proves convenient.

<div class="card-deck">
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>gRPC</b></h5>
<p class="card-text">Create Dapr services with the gRPC server extension module</p>
<a href="{{< ref python-grpc >}}" class="stretched-link"></a>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>FastAPI</b></h5>
<p class="card-text">Integrate with Dapr Python virtual actors and pub/sub using the Dapr FastAPI extension module.</p>
<a href="{{< ref python-fastapi >}}" class="stretched-link"></a>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>Flask</b></h5>
<p class="card-text">Integrate with Dapr Python virtual actors using the Dapr Flask extension module.</p>
<a href="{{< ref python-sdk-extensions >}}" class="stretched-link"></a>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>Workflow</b></h5>
<p class="card-text">Author workflows that work with other Dapr APIs in Python.</p>
<a href="{{< ref python-workflow >}}" class="stretched-link"></a>
</div>
</div>
</div>

Learn more about [the Dapr Python SDK extensions](https://github.com/dapr/python-sdk/tree/master/ext).

## Try it out

Clone the Python SDK repo to try out some of the [examples](https://github.com/dapr/python-sdk/tree/master/examples).
Clone the Python SDK repo.

```bash
git clone https://github.com/dapr/python-sdk.git
```

Walk through the Python quickstarts, tutorials, and examples to see Dapr in action:

| SDK samples | Description |
| ----------- | ----------- |
| [Quickstarts]({{< ref quickstarts >}}) | Experience Dapr's API building blocks in just a few minutes using the Python SDK. |
| [SDK samples](https://github.com/dapr/python-sdk/tree/master/examples) | Clone the SDK repo to try out some examples and get started. |
| [Bindings tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/bindings) | See how Dapr Python SDK works alongside other Dapr SDKs to enable bindings. |
| [Distributed Calculator tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/distributed-calculator/python) | Use the Dapr Python SDK to handle method invocation and state persistent capabilities. |
| [Hello World tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/hello-world) | Learn how to get Dapr up and running locally on your machine with the Python SDK. |
| [Hello Kubernetes tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/hello-kubernetes) | Get up and running with the Dapr Python SDK in a Kubernetes cluster. |
| [Observability tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/observability) | Explore Dapr's metric collection, tracing, logging and health check capabilities using the Python SDK. |
| [Pub/sub tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub) | See how Dapr Python SDK works alongside other Dapr SDKs to enable pub/sub applications. |


## More information

- [Python Package Index (PyPI)](https://pypi.org/user/dapr.io/)
- [Dapr SDK serialization]({{< ref sdk-serialization.md >}})
<div class="card-deck">
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>Serialization</b></h5>
<p class="card-text">Learn more about serialization in Dapr SDKs.</p>
<a href="{{< ref sdk-serialization >}}" class="stretched-link"></a>
</div>
</div>
<div class="card">
<div class="card-body">
<h5 class="card-title"><b>PyPI</b></h5>
<p class="card-text">Python Package Index</p>
<a href="https://pypi.org/user/dapr.io/" class="stretched-link"></a>
</div>
</div>
</div>
34 changes: 19 additions & 15 deletions daprdocs/content/en/python-sdk-docs/python-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ description: How to get up and running with the Dapr Python SDK

The Dapr client package allows you to interact with other Dapr applications from a Python application.

## Pre-requisites
{{% alert title="Note" color="primary" %}}
If you haven't already, [try out one of the quickstarts]({{< ref quickstarts >}}) for a quick walk-through on how to use the Dapr Python SDK with an API building block.

- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
- [Python 3.7+](https://www.python.org/downloads/) installed
- [Dapr Python module]({{< ref "python#install-the0dapr-module" >}}) installed
{{% /alert %}}

## Prerequisites

[Install the Dapr Python module]({{< ref "python-sdk-docs/_index.md" >}}) before getting started.

## Import the client package

The dapr package contains the `DaprClient` which will be used to create and use a client.
The Dapr package contains the `DaprClient`, which is used to create and use a client.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

```python
from dapr.clients import DaprClient
Expand All @@ -42,7 +44,7 @@ with DaprClient() as d:
```

- For a full guide on service invocation visit [How-To: Invoke a service]({{< ref howto-invoke-discover-services.md >}}).
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/invoke-simple) for code samples and instructions to try out service invocation
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/invoke-simple) for code samples and instructions to try out service invocation.

### Save & get application state

Expand All @@ -61,7 +63,7 @@ with DaprClient() as d:
```

- For a full list of state operations visit [How-To: Get & save state]({{< ref howto-get-save-state.md >}}).
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/state_store) for code samples and instructions to try out state management
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/state_store) for code samples and instructions to try out state management.

### Query application state (Alpha)

Expand Down Expand Up @@ -95,7 +97,7 @@ with DaprClient() as d:

### Publish & subscribe to messages

##### Publish messages
#### Publish messages

```python
from dapr.clients import DaprClient
Expand All @@ -104,7 +106,7 @@ with DaprClient() as d:
resp = d.publish_event(pubsub_name='pubsub', topic_name='TOPIC_A', data='{"message":"Hello World"}')
```

##### Subscribe to messages
#### Subscribe to messages

```python
from cloudevents.sdk.event import v1
Expand Down Expand Up @@ -143,7 +145,7 @@ with DaprClient() as d:
```

- For a full guide on output bindings visit [How-To: Use bindings]({{< ref howto-bindings.md >}}).
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/invoke-binding) for code samples and instructions to try out output bindings
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/invoke-binding) for code samples and instructions to try out output bindings.

### Retrieve secrets

Expand All @@ -157,7 +159,9 @@ with DaprClient() as d:
- For a full guide on secrets visit [How-To: Retrieve secrets]({{< ref howto-secrets.md >}}).
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/secret_store) for code samples and instructions to try out retrieving secrets

### Get configuration
### Configuration

#### Get configuration

```python
from dapr.clients import DaprClient
Expand All @@ -167,7 +171,7 @@ with DaprClient() as d:
configuration = d.get_configuration(store_name='configurationstore', keys=['orderId'], config_metadata={})
```

### Subscribe to configuration
#### Subscribe to configuration

```python
import asyncio
Expand Down Expand Up @@ -198,7 +202,7 @@ asyncio.run(executeConfiguration())
```

- Learn more about managing configurations via the [How-To: Manage configuration]({{< ref howto-manage-configuration.md >}}) guide.
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/configuration) for code samples and instructions to try out configuration
- Visit [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples/configuration) for code samples and instructions to try out configuration.

### Distributed Lock

Expand Down Expand Up @@ -316,4 +320,4 @@ def main():


## Related links
- [Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples)
[Python SDK examples](https://github.com/dapr/python-sdk/tree/master/examples)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ weight: 30000
description: How to get up and running with workflows using the Dapr Python SDK
---

{{% alert title="Note" color="primary" %}}
Dapr Workflow is currently in alpha.
{{% /alert %}}

Let’s create a Dapr workflow and invoke it using the console. With the [provided hello world workflow example](https://github.com/dapr/python-sdk/tree/master/examples/demo_workflow), you will:

- Run a [Python console application using `DaprClient`](https://github.com/dapr/python-sdk/blob/master/examples/demo_workflow/app.py)
Expand Down
Loading