Skip to content

Conversation

thomasjhuang
Copy link
Contributor

@thomasjhuang thomasjhuang commented Jun 6, 2025

Tracking issue

This is associated to flyte change flyteorg/flyte#6475, and RFC flyteorg/flyte#5659

Why are the changes needed?

These are the necessary changes needed to implement the ConcurrencyPolicy within flytekit. Namely, it will allow users to manage concurrency control via LaunchPlan.create() or LaunchPlan.get_or_create()

How was this patch tested?

Unit tests are added, local testing is also done.

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

This pull request introduces a new concurrency policy feature in the Flytekit library, enhancing concurrency control through LaunchPlan methods. It updates existing models and launch plan parameters to incorporate these settings, improving overall functionality. Comprehensive unit tests have been added to ensure reliability and system integrity.

Copy link

welcome bot commented Jun 6, 2025

Thank you for opening this pull request! 🙌

These tips will help get your PR across the finish line:

  • Most of the repos have a PR template; if not, fill it out to the best of your knowledge.
  • Sign off your commits (Reference: DCO Guide).

@Sovietaced
Copy link
Member

@thomasjhuang Can you sign off on these commits? And can someone else let the CI run?

@thomasjhuang thomasjhuang force-pushed the thomasjhuang/concurrency branch from 167ea31 to 57e7827 Compare July 22, 2025 21:39
@thomasjhuang
Copy link
Contributor Author

@thomasjhuang Can you sign off on these commits? And can someone else let the CI run?

Sorry about that, added the signoff



class ConcurrencyLimitBehavior(object):
SKIP = _launch_plan_idl.ConcurrencyLimitBehavior.SKIP
Copy link
Contributor

Choose a reason for hiding this comment

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

I encountered some errors in my local execution, According to the latest flyteidl, should we use SKIP = _launch_plan_idl.ConcurrencyLimitBehavior.CONCURRENCY_LIMIT_BEHAVIOR_SKIP here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I need to update this according to the merged PR in flyte. Thanks for the callout

kumare3
kumare3 previously approved these changes Aug 25, 2025
@kumare3
Copy link
Contributor

kumare3 commented Aug 25, 2025

LGTM

kumare3
kumare3 previously approved these changes Sep 11, 2025
@thomasjhuang
Copy link
Contributor Author

@kumare3 @davidmirror-ops These test failures are a little odd to me, they seem transient? would a rerun suffice here?

@kumare3
Copy link
Contributor

kumare3 commented Sep 22, 2025

Hmm weird how did the event loop vanish

@machichima
Copy link
Member

machichima commented Sep 23, 2025

I fixed the failed test in https://github.com/flyteorg/flytekit/pull/3265/files#r2354426173
@thomasjhuang could you please merge/rebase master and see if tests can pass? Thank you!

@thomasjhuang thomasjhuang force-pushed the thomasjhuang/concurrency branch from 012276c to 55bf831 Compare September 24, 2025 20:35
@thomasjhuang
Copy link
Contributor Author

I fixed the failed test in https://github.com/flyteorg/flytekit/pull/3265/files#r2354426173 @thomasjhuang could you please merge/rebase master and see if tests can pass? Thank you!

Ah got it, thanks I've rebased and pushed again.



def test_concurrency_limit_behavior():
assert ConcurrencyLimitBehavior.SKIP == _launch_plan_idl.ConcurrencyLimitBehavior.SKIP
Copy link
Member

@machichima machichima Sep 25, 2025

Choose a reason for hiding this comment

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

Suggested change
assert ConcurrencyLimitBehavior.SKIP == _launch_plan_idl.ConcurrencyLimitBehavior.SKIP
assert ConcurrencyLimitBehavior.SKIP == _launch_plan_idl.CONCURRENCY_LIMIT_BEHAVIOR_SKIP

@thomasjhuang
All _launch_plan_idl.ConcurrencyLimitBehavior.SKIP below should be changed to _launch_plan_idl.CONCURRENCY_LIMIT_BEHAVIOR_SKIP. This can solve the error AttributeError: Enum ConcurrencyLimitBehavior has no value defined for name 'SKIP'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, I noticed the issue yesterday as well. Thanks for the callout!

@thomasjhuang thomasjhuang force-pushed the thomasjhuang/concurrency branch from a029dab to a0f6004 Compare September 25, 2025 20:47
@thomasjhuang
Copy link
Contributor Author

thomasjhuang commented Sep 26, 2025

@kumare3 @davidmirror-ops @popojk @machichima Looks like all checks have passed now! Thanks for the help :)

@davidmirror-ops davidmirror-ops enabled auto-merge (squash) September 26, 2025 18:53
@davidmirror-ops
Copy link
Contributor

Thank you @thomasjhuang!

Comment on lines 232 to 234
:param auto_activate: If set to True, the launch plan will be activated automatically on registration.
:param concurrency: Defines execution concurrency limits and policy when limit is reached
Default is False.
Copy link
Member

Choose a reason for hiding this comment

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

Is the docstring here being cut-off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but I don't see the issue with this line?

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
:param auto_activate: If set to True, the launch plan will be activated automatically on registration.
:param concurrency: Defines execution concurrency limits and policy when limit is reached
Default is False.
:param auto_activate: If set to True, the launch plan will be activated automatically on registration.
Default is False.
:param concurrency: Defines execution concurrency limits and policy when limit is reached.

Oh I mean "Default is False" is for auto_activate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see! fixed it, thanks!

auto-merge was automatically disabled September 29, 2025 18:03

Head branch was pushed to by a user without write access

@thomasjhuang thomasjhuang force-pushed the thomasjhuang/concurrency branch from 71f92e4 to 68d189a Compare September 30, 2025 18:46
thomasjhuang and others added 6 commits October 2, 2025 10:29
Signed-off-by: thomasjhuang <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>
@thomasjhuang thomasjhuang force-pushed the thomasjhuang/concurrency branch from 68d189a to e1ba971 Compare October 2, 2025 17:30
Signed-off-by: thomasjhuang <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>
Copy link
Member

@machichima machichima left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!!

@machichima machichima merged commit b4050b6 into flyteorg:master Oct 3, 2025
115 checks passed
Copy link

welcome bot commented Oct 3, 2025

Congrats on merging your first pull request! 🎉

Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 2025
* Add concurrency policy

Signed-off-by: thomasjhuang <[email protected]>

* Update to latest idl

Signed-off-by: thomasjhuang <[email protected]>

* Reformat with ruff

Signed-off-by: thomasjhuang <[email protected]>

* Change reference

Signed-off-by: thomasjhuang <[email protected]>

* Update test

Signed-off-by: thomasjhuang <[email protected]>

* Update tests/flytekit/unit/models/test_concurrency.py

Co-authored-by: Nary Yeh <[email protected]>
Signed-off-by: thomasjhuang <[email protected]>

* Update comment

Signed-off-by: thomasjhuang <[email protected]>

* Fix lint

Signed-off-by: thomasjhuang <[email protected]>

---------

Signed-off-by: thomasjhuang <[email protected]>
Co-authored-by: Nary Yeh <[email protected]>
Signed-off-by: Atharva <[email protected]>
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