Skip to content

Commit

Permalink
Merge branch 'release-1.15' into jobs-dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
WhitWaldo authored Feb 3, 2025
2 parents 07eb19b + 45133b8 commit d23294d
Show file tree
Hide file tree
Showing 54 changed files with 2,256 additions and 224 deletions.
4 changes: 2 additions & 2 deletions .github/env/global.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DAPR_CLI_VERSION: 1.15.0-rc.2
DAPR_RUNTIME_VERSION: 1.15.0-rc.5
DAPR_CLI_VERSION: 1.15.0-rc.4
DAPR_RUNTIME_VERSION: 1.15.0-rc.9
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v${DAPR_CLI_VERSION}/install/
DAPR_DEFAULT_IMAGE_REGISTRY: ghcr

Expand Down
2 changes: 1 addition & 1 deletion actors/csharp/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Let's take a look at the Dapr [Actors building block](https://docs.dapr.io/devel
For this example, you will need:

- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- [.NET 7 SDK](https://dotnet.microsoft.com/download).
- [.NET 8 SDK](https://dotnet.microsoft.com/download).
- Docker Desktop

### Step 2: Set up the environment
Expand Down
2 changes: 1 addition & 1 deletion actors/csharp/sdk/client/SmartDevice.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapr.Actors" Version="1.14.*-*" />
<PackageReference Include="Dapr.Actors" Version="1.15.0-rc02" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions actors/csharp/sdk/service/SmartDevice.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapr.Actors" Version="1.14.*-*" />
<PackageReference Include="Dapr.Actors.AspNetCore" Version="1.14.*-*" />
<PackageReference Include="Dapr.Actors" Version="1.15.0-rc02" />
<PackageReference Include="Dapr.Actors.AspNetCore" Version="1.15.0-rc02" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion bindings/csharp/sdk/batch/batch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapr.AspNetCore" Version="1.14.*-*" />
<PackageReference Include="Dapr.AspNetCore" Version="1.15.0-rc02" />
</ItemGroup>

</Project>
9 changes: 5 additions & 4 deletions bindings/csharp/sdk/batch/program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ limitations under the License.
options.SupportedCultures = [invariantCulture];
});

builder.Services.AddDaprClient();

var app = builder.Build();

if (app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); }

app.UseRequestLocalization();

// Triggered by Dapr input binding
app.MapPost("/" + cronBindingName, async () =>
app.MapPost("/" + cronBindingName, async (DaprClient client) =>
{
Console.WriteLine("Processing batch..");

string jsonFile = File.ReadAllText("../../../orders.json");
var ordersArray = JsonSerializer.Deserialize<Orders>(jsonFile);
using var client = new DaprClientBuilder().Build();
foreach (Order ord in ordersArray?.orders ?? new Order[] { })
{
var sqlText = $"insert into orders (orderid, customer, price) values ({ord.OrderId}, '{ord.Customer}', {ord.Price});";
Expand All @@ -65,5 +66,5 @@ limitations under the License.

await app.RunAsync();

public record Order([property: JsonPropertyName("orderid")] int OrderId, [property: JsonPropertyName("customer")] string Customer, [property: JsonPropertyName("price")] float Price);
public record Orders([property: JsonPropertyName("orders")] Order[] orders);
public sealed record Order([property: JsonPropertyName("orderid")] int OrderId, [property: JsonPropertyName("customer")] string Customer, [property: JsonPropertyName("price")] float Price);
public sealed record Orders([property: JsonPropertyName("orders")] Order[] orders);
5 changes: 3 additions & 2 deletions bindings/python/sdk/batch/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dapr>=1.14.0a,<1.15.0
dapr>=1.15.0rc2
Flask
typing-extensions
typing-extensions
werkzeug>=3.0.3 # not directly required, pinned by Snyk to avoid a vulnerability
2 changes: 1 addition & 1 deletion configuration/python/sdk/order-processor/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dapr>=1.14.0a,<1.15.0
dapr>=1.15.0rc2
typing-extensions
97 changes: 97 additions & 0 deletions conversation/python/http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Dapr Conversation API (Python HTTP)

In this quickstart, you'll send an input to a mock Large Language Model (LLM) using Dapr's Conversation API. This API is responsible for providing one consistent API entry point to talk to underlying LLM providers.

Visit [this](https://v1-15.docs.dapr.io/developing-applications/building-blocks/conversation/conversation-overview/) link for more information about Dapr and the Conversation API.

> **Note:** This example leverages HTTP `requests` only.
This quickstart includes one app:

- `app.py`, responsible for sending an input to the underlying LLM and retrieving an output.

## Run the app with the template file

This section shows how to run the application using the [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) with `dapr run -f .`.

This example uses the default LLM Component provided by Dapr which simply echoes the input provided, for testing purposes. Here are other [supported Conversation components](https://v1-15.docs.dapr.io/reference/components-reference/supported-conversation/).

1. Install dependencies:

<!-- STEP
name: Install Python dependencies
-->

```bash
cd ./conversation
pip3 install -r requirements.txt
cd ..
```

2. Open a new terminal window and run the multi app run template:

<!-- STEP
name: Run multi app run template
expected_stdout_lines:
- '== APP == INFO:root:Input sent: What is dapr?'
- '== APP == INFO:root:Output response: What is dapr?'
expected_stderr_lines:
output_match_mode: substring
match_order: none
background: true
sleep: 15
timeout_seconds: 30
-->

```bash
dapr run -f .
```

The terminal console output should look similar to this, where:

- The app sends an input `What is dapr?` to the `echo` Component mock LLM.
- The mock LLM echoes `What is dapr?`.

```text
== APP - conversation == Input sent: What is dapr?
== APP - conversation == Output response: What is dapr?
```

<!-- END_STEP -->

2. Stop and clean up application processes.

<!-- STEP
name: Stop multi-app run
sleep: 5
-->

```bash
dapr stop -f .
```

<!-- END_STEP -->

## Run the app with the Dapr CLI

1. Install dependencies:

Open a terminal and run:

```bash
cd ./conversation
pip3 install -r requirements.txt
```

2. Run the application:

```bash
dapr run --app-id conversation --resources-path ../../../components -- python3 app.py
```

You should see the output:

```bash
== APP == INFO:root:Input sent: What is dapr?
== APP == INFO:root:Output response: What is dapr?
```
31 changes: 31 additions & 0 deletions conversation/python/http/conversation/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import logging
import requests
import os

logging.basicConfig(level=logging.INFO)

base_url = os.getenv('BASE_URL', 'http://localhost') + ':' + os.getenv(
'DAPR_HTTP_PORT', '3500')

CONVERSATION_COMPONENT_NAME = 'echo'

input = {
'name': 'echo',
'inputs': [{'message':'What is dapr?'}],
'parameters': {},
'metadata': {}
}

# Send input to conversation endpoint
result = requests.post(
url='%s/v1.0-alpha1/conversation/%s/converse' % (base_url, CONVERSATION_COMPONENT_NAME),
json=input
)

logging.info('Input sent: What is dapr?')

# Parse conversation output
data = result.json()
output = data["outputs"][0]["result"]

logging.info('Output response: ' + output)
1 change: 1 addition & 0 deletions conversation/python/http/conversation/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
7 changes: 7 additions & 0 deletions conversation/python/http/dapr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 1
common:
resourcesPath: ../../components/
apps:
- appID: conversation
appDirPath: ./conversation/
command: ["python3", "app.py"]
2 changes: 2 additions & 0 deletions conversation/python/http/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../docker.mk
include ../../../validate.mk
38 changes: 19 additions & 19 deletions jobs/go/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Open a new terminal window and run the multi app run template:
<!-- STEP
name: Run multi app run template
expected_stdout_lines:
- '== APP - job-service == Received job request...'
- '== APP - job-service == Executing maintenance job: Oil Change'
- '== APP - job-scheduler == Job Scheduled: C-3PO'
- '== APP - job-service == Received job request...'
- '== APP - job-service == Executing maintenance job: Limb Calibration'
- '== APP - job-service-http == Received job request...'
- '== APP - job-service-http == Executing maintenance job: Oil Change'
- '== APP - job-scheduler-http == Job Scheduled: C-3PO'
- '== APP - job-service-http == Received job request...'
- '== APP - job-service-http == Executing maintenance job: Limb Calibration'
expected_stderr_lines:
output_match_mode: substring
match_order: none
Expand All @@ -45,20 +45,20 @@ The terminal console output should look similar to this, where:
- The `C-3PO` job is being retrieved.

```text
== APP - job-scheduler == Job Scheduled: R2-D2
== APP - job-service == Received job request...
== APP - job-service == Starting droid: R2-D2
== APP - job-service == Executing maintenance job: Oil Change
== APP - job-scheduler == Job Scheduled: C-3PO
== APP - job-scheduler == Job details: {"name":"C-3PO", "dueTime":"30s", "data":{"@type":"ttype.googleapis.com/google.protobuf.StringValue", "expression":"C-3PO:Limb Calibration"}}
== APP - job-scheduler-http == Job Scheduled: R2-D2
== APP - job-service-http == Received job request...
== APP - job-service-http == Starting droid: R2-D2
== APP - job-service-http == Executing maintenance job: Oil Change
== APP - job-scheduler-http == Job Scheduled: C-3PO
== APP - job-scheduler-http == Job details: {"name":"C-3PO", "dueTime":"30s", "data":{"@type":"ttype.googleapis.com/google.protobuf.StringValue", "expression":"C-3PO:Limb Calibration"}}
```

After 30 seconds, the terminal output should present the `C-3PO` job being processed:

```text
== APP - job-service == Received job request...
== APP - job-service == Starting droid: C-3PO
== APP - job-service == Executing maintenance job: Limb Calibration
== APP - job-service-http == Received job request...
== APP - job-service-http == Starting droid: C-3PO
== APP - job-service-http == Executing maintenance job: Limb Calibration
```

<!-- END_STEP -->
Expand All @@ -83,7 +83,7 @@ dapr stop -f .
1. Open a terminal and run the `job-service` app:

```bash
dapr run --app-id job-service --app-port 6200 --dapr-http-port 6280 -- go run .
dapr run --app-id job-service-http --app-port 6200 --dapr-http-port 6280 -- go run .
```

2. On a new terminal window, schedule the `R2-D2` Job using the Jobs API.
Expand All @@ -104,9 +104,9 @@ curl -X POST \
Back at the `job-service` app terminal window, the output should be:

```text
== APP - job-app == Received job request...
== APP - job-app == Starting droid: R2-D2
== APP - job-app == Executing maintenance job: Oil Change
== APP - job-service-http == Received job request...
== APP - job-service-http == Starting droid: R2-D2
== APP - job-service-http == Executing maintenance job: Oil Change
```

3. On the same terminal window, schedule the `C-3PO` Job using the Jobs API.
Expand Down Expand Up @@ -155,5 +155,5 @@ curl -X GET http://localhost:6280/v1.0-alpha1/jobs/c-3po -H "Content-Type: appli
Back at the `job-service` app terminal window, the output should be:

```text
ERRO[0249] Error getting job c-3po due to: rpc error: code = Unknown desc = job not found: app||default||job-service||c-3po instance=diagrid.local scope=dapr.api type=log ver=1.14.0-rc.2
ERRO[0249] Error getting job c-3po due to: rpc error: code = Unknown desc = job not found: app||default||job-service-http||c-3po instance=diagrid.local scope=dapr.api type=log ver=1.14.0-rc.2
```
9 changes: 4 additions & 5 deletions jobs/go/http/dapr.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
version: 1
apps:
- appDirPath: ./job-service/
appID: job-service
- appID: job-service-http
appDirPath: ./job-service/
appPort: 6200
daprHTTPPort: 6280
schedulerHostAddress: localhost
command: ["go", "run", "."]
- appDirPath: ./job-scheduler/
appID: job-scheduler
- appID: job-scheduler-http
appDirPath: ./job-scheduler/
appPort: 6300
daprHTTPPort: 6380
command: ["go", "run", "."]
Loading

0 comments on commit d23294d

Please sign in to comment.