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

workflows: update durabletask dependency #757

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

famarting
Copy link
Contributor

@famarting famarting commented Dec 3, 2024

Description

Update durabletask dependency to use new dapr fork

Also implements support for purge API #711

Implements support for reuse id policy and set custom status from #739

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@famarting famarting requested review from a team as code owners December 3, 2024 10:25
Copy link
Contributor

@elena-kolevska elena-kolevska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments. Please run tox -e ruff and tox -e flake8 to fix linter errors.

We'll also need to update the grpc library to >= 1.67.0, for compatibility with durabletask.

And finally, we'll need to update the tests in test_dapr_workflow_context.py to cover set-custom_status. Something like

class FakeOrchestrationContext:
    def __init__(self):
        self.instance_id = mock_instance_id
        self.custom_status = None. # <- adding this
    def set_custom_status(self, custom_status):
        self.custom_status = custom_status
        
...

class DaprWorkflowContextTest(unittest.TestCase):
...
def test_workflow_context_functions(self):
...
            dapr_wf_ctx.set_custom_status(mock_status)
            assert fakeContext.custom_status == mock_status            

setup.cfg Outdated
@@ -26,8 +26,8 @@ include_package_data = True
zip_safe = False
install_requires =
protobuf >= 4.22
grpcio >= 1.37.0
grpcio-status>=1.37.0
grpcio >= 1.67.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@berndverst any objections on bumping the grpc library version?
This has been updated in the durable task fork and it's a dependency here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 1.37.0 is very old, it's from April 2021. I think we're safe to update.

Copy link
Member

@berndverst berndverst Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not mean it would use 1.37 but that 1.37 would be possible to be used. Pip by default will always install the latest version matching the constraint unless an older version is cached (that behavior can be changed by the way). But if another library a customer is using required grpcio==1.47.0 for example it would be possible for that specific version to be used.

In Python two versions cannot coexist unlike in other languages. So it's really really important not to force the minimum version to something recent unless this is absolutely necessary.

To provide a specific example, at this time the tensorflow development test container pins grpcio 1.42.0 and this is common for folks using Python 3.9 with compatible tensorflow packages for example. A lot of people use libraries in production that pin specific grpcio versions and they want to use Dapr for added functionality.

Pinning a recent grpcio as the minimum version prevents a lot of compatibility with other packages.

For this reason I must strongly disagree with pinning 1.67.0 as the minimum version. You could argue it is the fault of those other packages for constraining the maximum version of grpcio - and that would be true, but that is a pedantic viewpoint. We need to ensure a good experience for customers.

Note - I have been here before: I made this very mistake as a Dapr maintainer - then several ML users complained about incompatibilities between Dapr and their ML package and a hotfix release had to be made.

Now from a security perspective it is wrong to say that a low minimum version (which includes vulnerable package versions) is a security issue in Dapr. Python resolves dependency versions at install time.

Installing dapr via pip install dapr --no-cache-dir would ensure to install the latest version of all dependencies from pypi. Folks who do not want this can manually add specific dependencies to their own requirements.txt to control the transitive dependency versions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grpcio >= 1.67.0
grpcio >= 1.42.0

Short of auditing the Dapr community to figure out what libraries everyone uses and what the dependencies are pinning... here is a quick thing I identified. This is evidence of at least 1.42.0 being used for something.

https://github.com/tensorflow/tensorflow/blob/8fd1cd0826ef2b12c00540f3acc5a6e3c249f5b2/ci/official/containers/linux_arm64/devel.usertools/test.requirements.txt#L2

If as a project we want to say that we do not care about ML users - or that ML users must be on the latest official grpcio packages (highly unlikely because ML package authors are very slow to update packages) then we could consider increasing the minimum version of grpcio.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this version is imposed by the protos used in the durable task library.

@cgillum and @famarting, can we regenerate the protos with an older grpcio version? I suggest we pin it to a version we agree on in the requirements file. I'll check for any CVEs and share here, so we can decide which version would make sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes let's please do that -- you should not use the latest grpcio-tools to generate the protos -- instead use an older version for wider compatibility with more versions of grpcio.

Is this only an issue in the "fork" or also the upstream version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's coming from the upstream, here's the commit: microsoft/durabletask-python#31.

Copy link
Contributor Author

@famarting famarting Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have to update the protos, I would suggest doing it here https://github.com/dapr/durabletask-protobuf , since dapr is already based on that one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the PR: dapr/durabletask-python#6
Once that's merged I'll publish a new version and we can update this PR.

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.14%. Comparing base (bffb749) to head (ab833e2).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...ext-workflow/dapr/ext/workflow/workflow_context.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #757      +/-   ##
==========================================
- Coverage   86.63%   86.14%   -0.50%     
==========================================
  Files          84       89       +5     
  Lines        4473     4993     +520     
==========================================
+ Hits         3875     4301     +426     
- Misses        598      692      +94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

elena-kolevska
elena-kolevska previously approved these changes Dec 4, 2024
Copy link
Contributor

@elena-kolevska elena-kolevska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending @berndverst 's approval on the grpcio version bump

@elena-kolevska elena-kolevska changed the base branch from main to release-1.15 January 2, 2025 13:03
@elena-kolevska elena-kolevska changed the base branch from release-1.15 to main January 7, 2025 17:41
@elena-kolevska elena-kolevska dismissed their stale review January 7, 2025 17:41

The base branch was changed.

setup.cfg Outdated
@@ -26,8 +26,8 @@ include_package_data = True
zip_safe = False
install_requires =
protobuf >= 4.22
grpcio >= 1.37.0
grpcio-status>=1.37.0
grpcio >= 1.67.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
grpcio >= 1.67.0
grpcio >= 1.42.0

Short of auditing the Dapr community to figure out what libraries everyone uses and what the dependencies are pinning... here is a quick thing I identified. This is evidence of at least 1.42.0 being used for something.

https://github.com/tensorflow/tensorflow/blob/8fd1cd0826ef2b12c00540f3acc5a6e3c249f5b2/ci/official/containers/linux_arm64/devel.usertools/test.requirements.txt#L2

If as a project we want to say that we do not care about ML users - or that ML users must be on the latest official grpcio packages (highly unlikely because ML package authors are very slow to update packages) then we could consider increasing the minimum version of grpcio.

@@ -1 +1 @@
grpcio-tools>=1.57.0
grpcio-tools>=1.67.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful. Changing this version is prone to huge changes to the resulting compiled protos, which therefore requires new versions of grpcio.

New versions of grpcio can load compiled protos from older grpcio-tools. But older grpcio versions cannot load compiled protos from the newest grpcio-tools.

I strongly recommend carefully testing this compatibility matrix - it is best not to change this version here (which is only used once as part of the release process -- it is a build dependency for maintainers only).

Unless you have a reason to change this, don't.

dependabot bot and others added 19 commits January 9, 2025 12:36
      Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v4...v5)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Hannah Hunter <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
This option was replaced in 2020, deprecated, and eventually removed in
tox 4. The correct option already appears elseware in this tox.ini file.

This fix is necessary to run `tox -e doc` per the README.md
instructions on tox 4.

Signed-off-by: Eric Searcy <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
* Moved files to new branch to avoid weird git bug

Signed-off-by: Lorenzo Curcio <[email protected]>

* requested documentation changes

Signed-off-by: Lorenzo Curcio <[email protected]>

* forgot to move file back to starting point

Signed-off-by: Lorenzo Curcio <[email protected]>

* result of ruff format

Signed-off-by: Lorenzo Curcio <[email protected]>

* fixed minor formatting issues, fixed type issues

Signed-off-by: Lorenzo Curcio <[email protected]>

* minor test fix

Signed-off-by: Lorenzo Curcio <[email protected]>

* fixes try_add_state

Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Revert "fixes try_add_state"

This reverts commit 254ad17.

Signed-off-by: Lorenzo Curcio <[email protected]>

* Update dapr/actor/runtime/mock_state_manager.py

Fixing bug in try_add_state as mentioned in PR dapr#756

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update dapr/actor/runtime/mock_actor.py

Whoops missed this

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* minor error in docs

Signed-off-by: Lorenzo Curcio <[email protected]>

* fixed and added more unit tests. Added example

Signed-off-by: Lorenzo Curcio <[email protected]>

* unittest fix

Signed-off-by: Lorenzo Curcio <[email protected]>

* Update examples/demo_actor/README.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* concentrated some tests

Signed-off-by: Lorenzo Curcio <[email protected]>

* removed unnecessary type hint

Signed-off-by: Lorenzo Curcio <[email protected]>

* Update daprdocs/content/en/python-sdk-docs/python-actor.md

didnt see this earlier whoops

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* Update examples/demo_actor/README.md

Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>

* documentation changes

Signed-off-by: Lorenzo Curcio <[email protected]>

* now requires #type: ignore

Signed-off-by: Lorenzo Curcio <[email protected]>

* small docs change

Signed-off-by: Elena Kolevska <[email protected]>

* examples test fix

Signed-off-by: Elena Kolevska <[email protected]>

---------

Signed-off-by: Lorenzo Curcio <[email protected]>
Signed-off-by: Lorenzo Curcio <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Co-authored-by: Lorenzo Curcio <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
* workflows, remove deprecated functions

Signed-off-by: Fabian Martinez <[email protected]>

* revert changes to example

Signed-off-by: Fabian Martinez <[email protected]>

* update warning messages

Signed-off-by: Fabian Martinez <[email protected]>

* Typos

Signed-off-by: Elena Kolevska <[email protected]>

* fixes linter

Signed-off-by: Elena Kolevska <[email protected]>

* Apply suggestions from code review

Signed-off-by: Elena Kolevska <[email protected]>

* Apply suggestions from code review

Signed-off-by: Elena Kolevska <[email protected]>

---------

Signed-off-by: Fabian Martinez <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Co-authored-by: Elena Kolevska <[email protected]>
Signed-off-by: Elena Kolevska <[email protected]>
elena-kolevska and others added 4 commits January 9, 2025 12:36
Signed-off-by: Elena Kolevska <[email protected]>
* Updates protos and fixes grpc-tools for protos generation

Signed-off-by: Elena Kolevska <[email protected]>

* bumps grpcio tools version

Signed-off-by: Elena Kolevska <[email protected]>

---------

Signed-off-by: Elena Kolevska <[email protected]>
@elena-kolevska elena-kolevska force-pushed the update-durabletask-fork branch from 85cdc62 to 73e5ac9 Compare January 9, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants