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

prevent compile err for ReferenceWorkflow #3102

Merged

Conversation

machichima
Copy link
Contributor

@machichima machichima commented Feb 1, 2025

Tracking issue

Related to flyteorg/flyte#6097

Why are the changes needed?

Return the entity itself without trying to compile if the entity is Reference workflow

What changes were proposed in this pull request?

How was this patch tested?

Integration test

Setup process

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

Fixed compilation error in remote.py by adding condition checks for ReferenceWorkflow entities. Enhanced the remote workflow testing framework with reference workflow testing capabilities, including new module imports and test cases. These changes ensure proper handling of reference workflow entities without compilation.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 1

Signed-off-by: machichima <nary12321@gmail.com>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 1, 2025

Code Review Agent Run #60519c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: b9c4e6c..b9c4e6c
    • flytekit/remote/remote.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 1, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Bug Fix - Fix ReferenceWorkflow Compilation Error

remote.py - Added check to return ReferenceWorkflow entity without compilation

test_remote.py - Added integration test for ReferenceWorkflow execution and updated imports

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.59%. Comparing base (4208a64) to head (b9c4e6c).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/remote/remote.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3102       +/-   ##
===========================================
+ Coverage   51.81%   78.59%   +26.77%     
===========================================
  Files         202      220       +18     
  Lines       21469    22235      +766     
  Branches     2766     2768        +2     
===========================================
+ Hits        11125    17475     +6350     
+ Misses       9735     3951     -5784     
- Partials      609      809      +200     

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

Signed-off-by: machichima <nary12321@gmail.com>
@machichima machichima changed the title [WIP] prevent compile err for ReferenceWorkflow prevent compile err for ReferenceWorkflow Feb 1, 2025
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 1, 2025

Code Review Agent Run #faa8fa

Actionable Suggestions - 1
  • tests/flytekit/integration/remote/test_remote.py - 1
    • Consider reordering workflow registration and reference · Line 536-543
Review Details
  • Files reviewed - 1 · Commit Range: b9c4e6c..ea1d181
    • tests/flytekit/integration/remote/test_remote.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

Comment on lines +536 to +543
remote_entity = remote.register_script(
my_wf,
project=PROJECT,
domain=DOMAIN,
image_config=ImageConfig.auto(img_name=IMAGE),
destination_dir=DEST_DIR,
source_path=MODULE_PATH,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider reordering workflow registration and reference

Consider moving the register_script call before the reference_workflow decorator since the registration should happen before referencing the workflow.

Code suggestion
Check the AI-generated fix before applying
  def test_execute_reference_workflow(register):
 +    remote = FlyteRemote(Config.auto(config_file=CONFIG), PROJECT, DOMAIN)
 +    remote_entity = remote.register_script(
 +        my_wf,
 +        project=PROJECT,
 +        domain=DOMAIN,
 +        image_config=ImageConfig.auto(img_name=IMAGE),
 +        destination_dir=DEST_DIR,
 +        source_path=MODULE_PATH,
 +    )
      @reference_workflow(
          project=PROJECT,
          domain=DOMAIN,
          name="basic.basic_workflow.my_wf",
          version=VERSION,
      )
      def my_wf(a: int, b: str) -> (int, str):
          return a + 2, b + "world"
 -
 -    remote = FlyteRemote(Config.auto(config_file=CONFIG), PROJECT, DOMAIN)
 -    remote_entity = remote.register_script(
 -        my_wf,
 -        project=PROJECT,
 -        domain=DOMAIN,
 -        image_config=ImageConfig.auto(img_name=IMAGE),
 -        destination_dir=DEST_DIR,
 -        source_path=MODULE_PATH,
 -    )

Code Review Run #faa8fa


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

@Future-Outlier Future-Outlier merged commit 5607b0d into flyteorg:master Feb 1, 2025
31 of 32 checks passed
@machichima machichima deleted the 6097-execute-reference-entities branch February 2, 2025 03:38
@@ -1275,6 +1275,8 @@ def register_script(
:param fast_package_options: Options to customize copy_all behavior, ignored when copy_all is False.
:return:
"""
if isinstance(entity, ReferenceWorkflow):
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add all reference entities too? including launch plan and task? there's a base class for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Let me have a look and open a new PR for it

UmerAhmad pushed a commit to UmerAhmad/flytekit that referenced this pull request Feb 8, 2025
* fix: prevent compile err for ReferenceWorkflow

Signed-off-by: machichima <nary12321@gmail.com>

* test: ref workflow integration test with register script

Signed-off-by: machichima <nary12321@gmail.com>

---------

Signed-off-by: machichima <nary12321@gmail.com>
Signed-off-by: Umer Ahmad <umer2ahmad@gmail.com>
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.

4 participants