Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
70ee6b6
Update pr-validation.yml
berndverst Mar 10, 2025
5dfe0c4
Making token credential optional (#45)
RyanLettieri Mar 10, 2025
9a7569a
Creating of pipeline to publish dts python package to pypi
RyanLettieri Mar 5, 2025
2431d2f
Upgrading version of durabletask-azuremanaged from 0.1b1 to 0.1
RyanLettieri Mar 5, 2025
67fe8c1
Updating versioning on packages
RyanLettieri Mar 6, 2025
58f0f36
Incrementing version to allign with pypi
RyanLettieri Mar 6, 2025
4f7615a
Adressing majority of first round of feedback
RyanLettieri Mar 6, 2025
46364b6
Updating pipeline to have linting
RyanLettieri Mar 6, 2025
4c4e6bf
Updating versions in pyproject.toml
RyanLettieri Mar 6, 2025
717ab88
Updating working dirs in yml
RyanLettieri Mar 6, 2025
e46d90a
Adding requirements.txt
RyanLettieri Mar 7, 2025
30bce57
Moving durabletask tests into specific dir and more
RyanLettieri Mar 11, 2025
59b21ce
Fixing more paths
RyanLettieri Mar 11, 2025
29ddd2f
ATtemptign to ignore durabletask-azuremanaged folder
RyanLettieri Mar 11, 2025
8716a9e
installing dts dependencies
RyanLettieri Mar 11, 2025
406d83c
Changing path for requirements.txt
RyanLettieri Mar 11, 2025
a654c0d
Moving init.py
RyanLettieri Mar 11, 2025
fe7e102
Updating readme and some tests
RyanLettieri Mar 11, 2025
9628875
Running all dts tests in publish pipeline
RyanLettieri Mar 11, 2025
7337186
Removing PYTHONPATH and installing regular deps
RyanLettieri Mar 11, 2025
cb824d8
Adding timeout to dts orchestration e2e test
RyanLettieri Mar 11, 2025
76307eb
Removing suspend and continue as new tests from dts
RyanLettieri Mar 19, 2025
3c065ae
Removing raise event timeout tests
RyanLettieri Mar 19, 2025
faa3d91
Only runnign publish on tag push
RyanLettieri Mar 19, 2025
89373e2
Changing dts action to run on tag creation
RyanLettieri Mar 19, 2025
aa1a8aa
Updating tag name
RyanLettieri Mar 19, 2025
7cda76c
Adressing review feedback
RyanLettieri Mar 20, 2025
b53adda
Fixing run requirements in actions and adding exit-zero
RyanLettieri Mar 20, 2025
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
108 changes: 58 additions & 50 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Build Validation

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 . --count --show-source --statistics --exit-zero
- name: Pytest unit tests
run: |
pytest -m "not e2e" --verbose

# Sidecar for running e2e tests requires Go SDK
- name: Install Go SDK
uses: actions/setup-go@v5
with:
go-version: 'stable'

# Install and run the durabletask-go sidecar for running e2e tests
- name: Pytest e2e tests
run: |
go install github.com/microsoft/durabletask-go@main
durabletask-go --port 4001 &
pytest -m "e2e" --verbose
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Build Validation

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
merge_group:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install durabletask dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Install durabletask-azuremanaged dependencies
working-directory: examples/dts
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 . --count --show-source --statistics --exit-zero
- name: Pytest unit tests
working-directory: tests/durabletask
run: |
pytest -m "not e2e and not dts" --verbose

# Sidecar for running e2e tests requires Go SDK
- name: Install Go SDK
uses: actions/setup-go@v5
with:
go-version: 'stable'

# Install and run the durabletask-go sidecar for running e2e tests
- name: Pytest e2e tests
working-directory: tests/durabletask
run: |
go install github.com/microsoft/durabletask-go@main
durabletask-go --port 4001 &
pytest -m "e2e and not dts" --verbose
110 changes: 110 additions & 0 deletions .github/workflows/publish-dts-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Publish Durable Task Scheduler to PyPI

on:
push:
branches:
- "main"
tags:
- "azuremanaged-v*" # Only run for tags starting with "azuremanaged-v"
pull_request:
branches:
- "main"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
working-directory: durabletask-azuremanaged
run: |
python -m pip install --upgrade pip
pip install setuptools wheel tox
pip install flake8
- name: Run flake8 Linter
working-directory: durabletask-azuremanaged
run: flake8 .

run-docker-tests:
env:
EMULATOR_VERSION: "v0.0.4" # Define the variable
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Pull Docker image
run: docker pull mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION

- name: Run Docker container
run: |
docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:$EMULATOR_VERSION

- name: Wait for container to be ready
run: sleep 10 # Adjust if your service needs more time to start

- name: Set environment variables
run: |
echo "TASKHUB=default" >> $GITHUB_ENV
echo "ENDPOINT=http://localhost:8080" >> $GITHUB_ENV

- name: Install durabletask dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt

- name: Install durabletask-azuremanaged dependencies
working-directory: examples/dts
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run the tests
working-directory: tests/durabletask-azuremanaged
run: |
pytest -m "dts" --verbose

publish:
if: startsWith(github.ref, 'refs/tags/azuremanaged-v') # Only run if a matching tag is pushed
needs: run-docker-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Extract version from tag
run: echo "VERSION=${GITHUB_REF#refs/tags/azuremanaged-v}" >> $GITHUB_ENV # Extract version from the tag

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12" # Adjust Python version as needed

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build package from directory durabletask-azuremanaged
working-directory: durabletask-azuremanaged
run: |
python -m build

- name: Check package
working-directory: durabletask-azuremanaged
run: |
twine check dist/*

- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN_AZUREMANAGED }} # Store your PyPI API token in GitHub Secrets
working-directory: durabletask-azuremanaged
run: |
twine upload dist/*
3 changes: 2 additions & 1 deletion durabletask-azuremanaged/durabletask/azuremanaged/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

from azure.core.credentials import TokenCredential
from typing import Optional

from durabletask.azuremanaged.internal.durabletask_grpc_interceptor import \
DTSDefaultClientInterceptorImpl
Expand All @@ -13,7 +14,7 @@ class DurableTaskSchedulerClient(TaskHubGrpcClient):
def __init__(self, *,
host_address: str,
taskhub: str,
token_credential: TokenCredential,
token_credential: Optional[TokenCredential],
secure_channel: bool = True):

if not taskhub:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Licensed under the MIT License.

import grpc
from typing import Optional

from azure.core.credentials import TokenCredential

from durabletask.azuremanaged.internal.access_token_manager import \
Expand All @@ -15,7 +17,7 @@ class DTSDefaultClientInterceptorImpl (DefaultClientInterceptorImpl):
StreamUnaryClientInterceptor and StreamStreamClientInterceptor from grpc to add an
interceptor to add additional headers to all calls as needed."""

def __init__(self, token_credential: TokenCredential, taskhub_name: str):
def __init__(self, token_credential: Optional[TokenCredential], taskhub_name: str):
self._metadata = [("taskhub", taskhub_name)]
super().__init__(self._metadata)

Expand Down
3 changes: 2 additions & 1 deletion durabletask-azuremanaged/durabletask/azuremanaged/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

from azure.core.credentials import TokenCredential
from typing import Optional

from durabletask.azuremanaged.internal.durabletask_grpc_interceptor import \
DTSDefaultClientInterceptorImpl
Expand All @@ -13,7 +14,7 @@ class DurableTaskSchedulerWorker(TaskHubGrpcWorker):
def __init__(self, *,
host_address: str,
taskhub: str,
token_credential: TokenCredential,
token_credential: Optional[TokenCredential],
secure_channel: bool = True):

if not taskhub:
Expand Down
2 changes: 1 addition & 1 deletion durabletask-azuremanaged/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "durabletask.azuremanaged"
version = "0.1b1"
version = "0.1.2"
description = "Extensions for the Durable Task Python SDK for integrating with the Durable Task Scheduler in Azure"
keywords = [
"durable",
Expand Down
30 changes: 29 additions & 1 deletion examples/dts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ This directory contains examples of how to author durable orchestrations using t

## Prerequisites

All the examples assume that you have a Durable Task Scheduler taskhub created.
There are 2 separate ways to run an example:
1. Using the emulator.
2. Using a real scheduler and taskhub.

All the examples by defualt assume that you have a Durable Task Scheduler taskhub created.

## Running with a scheduler and taskhub resource
The simplest way to create a taskhub is by using the az cli commands:

1. Create a scheduler:
Expand Down Expand Up @@ -46,6 +51,29 @@ The simplest way to create a taskhub is by using the az cli commands:

1. Grant yourself the `Durable Task Data Contributor` role over your scheduler

## Running with the emulator
The emulator is a simulation of a scheduler and taskhub. It is the 'backend' of the durabletask-azuremanaged system packaged up into an easy to use docker container. For these steps, it is assumed that you are using port 8080.

In order to use the emulator for the examples, perform the following steps:
1. Install docker if it is not already installed.

2. Pull down the docker image for the emulator:
`docker pull mcr.microsoft.com/dts/dts-emulator:v0.0.4`

3. Run the emulator and wait a few seconds for the container to be ready:
`docker run --name dtsemulator -d -p 8080:8080 mcr.microsoft.com/dts/dts-emulator:v0.0.4`

4. Set the environment variables that are referenced and used in the examples:
1. If you are using windows powershell:
`$env:TASKHUB="default"`
`$env:ENDPOINT="http://localhost:8080"`
2. If you are using bash:
`export TASKHUB=default`
`export ENDPOINT=http://localhost:8080`

5. Finally, edit the examples to change the `token_credential` input of both the `DurableTaskSchedulerWorker` and `DurableTaskSchedulerClient` to a value of `None`


## Running the examples

Now, you can simply execute any of the examples in this directory using `python3`:
Expand Down
6 changes: 6 additions & 0 deletions examples/dts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
autopep8
grpcio>=1.60.0 # 1.60.0 is the version introducing protobuf 1.25.X support, newer versions are backwards compatible
protobuf
azure-identity
durabletask-azuremanaged
durabletask
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "durabletask"
version = "0.2b1"
version = "0.2.0"
description = "A Durable Task Client SDK for Python"
keywords = [
"durable",
Expand Down
Empty file.
Loading
Loading