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

Webhook tasks using FlyteAgents #3058

Merged
merged 27 commits into from
Feb 20, 2025
Merged

Webhook tasks using FlyteAgents #3058

merged 27 commits into from
Feb 20, 2025

Conversation

kumare3
Copy link
Contributor

@kumare3 kumare3 commented Jan 14, 2025

There have been numerous requests from folks to support invoking arbitrary apis or using webhooks to notify.

This agent supports calling webhooks like slack, github etc directly from a flyte workflow

Possible to write workflows like,

from flytekit.extras.webhook import WebhookTask


@fk.task
def hello(s: str) -> str:
    return "Hello " + s

simple_get = WebhookTask(
    name="simple-get",
    url="http://localhost:8000/",
    method=http.HTTPMethod.GET,
    headers={"Content-Type": "application/json"},
)

get_with_params = WebhookTask(
    name="get-with-params",
    url="http://localhost:8000/items/{inputs.item_id}",
    method=http.HTTPMethod.GET,
    headers={"Content-Type": "application/json"},
    dynamic_inputs={"s": str, "item_id": int},
    show_data=True,
    show_url=True,
    description="Test Webhook Task",
    data={"q": "{inputs.s}"},
)


@fk.workflow
def wf(s: str) -> (dict, dict, dict):
    v = hello(s=s)
    w = WebhookTask(
        name="invoke-slack",
        url="https://hooks.slack.com/services/asdasdasd/asdasdasd",
        headers={"Content-Type": "application/json"},
        data={"text": "{inputs.s}"},
        show_data=True,
        show_url=True,
        description="Test Webhook Task",
        dynamic_inputs={"s": str},
    )
    return simple_get(), get_with_params(s=v, item_id=10), w(s=v)

Summary by Bito

This PR enhances Flytekit with WebhookTask and WebhookAgent implementations, enabling direct HTTP requests to external services like Slack and GitHub. It includes httpx integration, caching system improvements, and enhanced agent execution model. The update increases timeout duration from 15 to 20 minutes for remote execution tests and improves the testing framework with better error assertions.

Unit tests added: True

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

@flyte-bot
Copy link
Contributor

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.58%. Comparing base (80ddcda) to head (deb37b9).
Report is 2 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (80ddcda) and HEAD (deb37b9). Click for more details.

HEAD has 24 uploads less than BASE
Flag BASE (80ddcda) HEAD (deb37b9)
25 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3058      +/-   ##
==========================================
- Coverage   92.24%   83.58%   -8.66%     
==========================================
  Files         118        3     -115     
  Lines        4991      195    -4796     
==========================================
- Hits         4604      163    -4441     
+ Misses        387       32     -355     

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

@flyte-bot
Copy link
Contributor

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

Signed-off-by: Ketan Umare <[email protected]>
@kumare3 kumare3 changed the title [WIP] Webhook tasks using FlyteAgents Webhook tasks using FlyteAgents Jan 14, 2025
@kumare3 kumare3 marked this pull request as ready for review January 14, 2025 23:22
@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 15, 2025

Code Review Agent Run #8c3d4c

Actionable Suggestions - 6
  • flytekit/extras/webhook/constants.py - 1
    • Consider adding type hints to constants · Line 1-8
  • flytekit/extras/webhook/agent.py - 2
  • tests/flytekit/unit/extras/webhook/test_agent.py - 1
    • Consider async mock pattern improvement · Line 35-35
  • flytekit/utils/dict_formatter.py - 1
    • Consider simplifying token truncation logic · Line 31-31
  • tests/flytekit/unit/extras/webhook/test_task.py - 1
    • Consider adding error case test coverage · Line 40-40
Additional Suggestions - 1
  • tests/flytekit/unit/extras/webhook/test_agent.py - 1
    • Add async context simulation to session mock · Line 26-28
Review Details
  • Files reviewed - 8 · Commit Range: 1ccea6f..ef2fd14
    • flytekit/extras/webhook/__init__.py
    • flytekit/extras/webhook/agent.py
    • flytekit/extras/webhook/constants.py
    • flytekit/extras/webhook/task.py
    • flytekit/utils/dict_formatter.py
    • plugins/flytekit-aws-sagemaker/flytekitplugins/awssagemaker_inference/boto3_mixin.py
    • tests/flytekit/unit/extras/webhook/test_agent.py
    • tests/flytekit/unit/extras/webhook/test_task.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 Jan 15, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
New Feature - Webhook Task and Agent Implementation

__init__.py - Added new webhook module initialization

agent.py - Implemented WebhookAgent for handling HTTP requests

constants.py - Defined webhook-related constants

task.py - Implemented WebhookTask for webhook integration

Feature Improvement - Agent and Event Loop Enhancement

base_agent.py - Added local agent event loop for synchronous execution

serve.py - Added webhook task import for agent support

Testing - Webhook Feature Testing

test_agent.py - Added unit tests for WebhookAgent

test_end_to_end.py - Added end-to-end tests for webhook functionality

test_task.py - Added unit tests for WebhookTask

test_remote.py - Increased timeout for remote execution test

Other Improvements - Code Refactoring and Dependencies

dict_formatter.py - Added utility for dictionary formatting

dev-requirements.in - Added httpx dependency

setup.py - Updated flytekit version requirement

boto3_mixin.py - Refactored dictionary formatting logic

Comment on lines 1 to 8
TASK_TYPE = "webhook"

URL_KEY = "url"
METHOD_KEY = "method"
HEADERS_KEY = "headers"
BODY_KEY = "body"
SHOW_BODY_KEY = "show_body"
SHOW_URL_KEY = "show_url"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding type hints to constants

Consider adding type hints to the constant declarations to improve code maintainability and IDE support. For example: TASK_TYPE: str = "webhook"

Code suggestion
Check the AI-generated fix before applying
Suggested change
TASK_TYPE = "webhook"
URL_KEY = "url"
METHOD_KEY = "method"
HEADERS_KEY = "headers"
BODY_KEY = "body"
SHOW_BODY_KEY = "show_body"
SHOW_URL_KEY = "show_url"
TASK_TYPE: str = "webhook"
URL_KEY: str = "url"
METHOD_KEY: str = "method"
HEADERS_KEY: str = "headers"
BODY_KEY: str = "body"
SHOW_BODY_KEY: str = "show_body"
SHOW_URL_KEY: str = "show_url"

Code Review Run #8c3d4c


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

  • it was incorrectly flagged

Comment on lines 41 to 78
url = final_dict.get(URL_KEY)
body = final_dict.get(BODY_KEY)
headers = final_dict.get(HEADERS_KEY)
method = final_dict.get(METHOD_KEY)
method = http.HTTPMethod(method)
show_body = final_dict.get(SHOW_BODY_KEY, False)
show_url = final_dict.get(SHOW_URL_KEY, False)

session = await self._get_session()

text = None
if method == http.HTTPMethod.GET:
response = await session.get(url, headers=headers)
text = await response.text()
else:
response = await session.post(url, json=body, headers=headers)
text = await response.text()
if response.status != 200:
return Resource(
phase=TaskExecution.FAILED,
message=f"Webhook failed with status code {response.status}, response: {text}",
)
final_response = {
"status_code": response.status,
"body": text,
}
if show_body:
final_response["input_body"] = body
if show_url:
final_response["url"] = url

return Resource(
phase=TaskExecution.SUCCEEDED,
outputs={"info": final_response},
message="Webhook was successfully invoked!",
)
except Exception as e:
return Resource(phase=TaskExecution.FAILED, message=str(e))
Copy link
Contributor

@flyte-bot flyte-bot Jan 15, 2025

Choose a reason for hiding this comment

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

Consider breaking down long method

The do method is quite long and handles multiple responsibilities including HTTP request handling, response processing, and error handling. Consider breaking it down into smaller, focused methods for better maintainability.

Code suggestion
Check the AI-generated fix before applying
Suggested change
url = final_dict.get(URL_KEY)
body = final_dict.get(BODY_KEY)
headers = final_dict.get(HEADERS_KEY)
method = final_dict.get(METHOD_KEY)
method = http.HTTPMethod(method)
show_body = final_dict.get(SHOW_BODY_KEY, False)
show_url = final_dict.get(SHOW_URL_KEY, False)
session = await self._get_session()
text = None
if method == http.HTTPMethod.GET:
response = await session.get(url, headers=headers)
text = await response.text()
else:
response = await session.post(url, json=body, headers=headers)
text = await response.text()
if response.status != 200:
return Resource(
phase=TaskExecution.FAILED,
message=f"Webhook failed with status code {response.status}, response: {text}",
)
final_response = {
"status_code": response.status,
"body": text,
}
if show_body:
final_response["input_body"] = body
if show_url:
final_response["url"] = url
return Resource(
phase=TaskExecution.SUCCEEDED,
outputs={"info": final_response},
message="Webhook was successfully invoked!",
)
except Exception as e:
return Resource(phase=TaskExecution.FAILED, message=str(e))
return await self._process_webhook(final_dict)
except Exception as e:
return Resource(phase=TaskExecution.FAILED, message=str(e))
async def _make_http_request(self, method: http.HTTPMethod, url: str, headers: dict, body: dict = None) -> tuple:
session = await self._get_session()
if method == http.HTTPMethod.GET:
response = await session.get(url, headers=headers)
else:
response = await session.post(url, json=body, headers=headers)
text = await response.text()
return response, text
def _build_response(self, response: aiohttp.ClientResponse, text: str, body: dict = None, url: str = None,
show_body: bool = False, show_url: bool = False) -> dict:
final_response = {
"status_code": response.status,
"body": text,
}
if show_body:
final_response["input_body"] = body
if show_url:
final_response["url"] = url
return final_response
async def _process_webhook(self, final_dict: dict) -> Resource:
url = final_dict.get(URL_KEY)
body = final_dict.get(BODY_KEY)
headers = final_dict.get(HEADERS_KEY)
method = http.HTTPMethod(final_dict.get(METHOD_KEY))
show_body = final_dict.get(SHOW_BODY_KEY, False)
show_url = final_dict.get(SHOW_URL_KEY, False)
response, text = await self._make_http_request(method, url, headers, body)
if response.status != 200:
return Resource(
phase=TaskExecution.FAILED,
message=f"Webhook failed with status code {response.status}, response: {text}",
)
final_response = self._build_response(response, text, body, url, show_body, show_url)
return Resource(
phase=TaskExecution.SUCCEEDED,
outputs={"info": final_response},
message="Webhook was successfully invoked!",
)

Code Review Run #8c3d4c

Consider validating timeout parameter value

Consider adding a timeout type check to ensure timeout is a positive integer before making the HTTP request. The current implementation assumes timeout is always valid.

Code suggestion
Check the AI-generated fix before applying
 @@ -53,8 +53,11 @@ class WebhookAgent(SyncAgentBase):
      async def _make_http_request(
          self, method: http.HTTPMethod, url: str, headers: dict, data: dict, timeout: int
      ) -> tuple:
 +        if not isinstance(timeout, int) or timeout <= 0:
 +            raise ValueError(f'timeout must be a positive integer, got {timeout}')
 +
          if method == http.HTTPMethod.GET:
              response = await self._client.get(url, headers=headers, params=data, timeout=timeout)

Code Review Run #49f39f


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

  • it was incorrectly flagged

outputs={"info": final_response},
message="Webhook was successfully invoked!",
)
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Too broad exception handling

Catching generic 'Exception' may hide bugs. Consider catching specific exceptions like 'aiohttp.ClientError'.

Code suggestion
Check the AI-generated fix before applying
Suggested change
except Exception as e:
except (aiohttp.ClientError, ValueError) as e:

Code Review Run #8c3d4c


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

  • it was incorrectly flagged

async def test_do_post_success(mock_task_template, mock_aiohttp_session):
mock_response = AsyncMock()
mock_response.status = 200
mock_response.text = "Success"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider async mock pattern improvement

Consider using AsyncMock(return_value='Success') directly for text instead of assigning it as a property. This would better match the async nature of the response.

Code suggestion
Check the AI-generated fix before applying
Suggested change
mock_response.text = "Success"
mock_response.text = AsyncMock(return_value="Success")

Code Review Run #8c3d4c


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

  • it was incorrectly flagged

show_url=True
)

settings = SerializationSettings(image_config=ImageConfig.auto_default_image())
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding error case test coverage

Consider adding test cases to verify error handling when invalid inputs are provided to WebhookTask. For example, testing with invalid URLs, unsupported HTTP methods, or malformed headers/body.

Code suggestion
Check the AI-generated fix before applying
 @@ -48,0 +49,25 @@
 + def test_webhook_task_invalid_inputs():
 +     # Test invalid URL
 +     with pytest.raises(ValueError):
 +         WebhookTask(
 +             name="test_task",
 +             url="invalid-url",
 +             method=http.HTTPMethod.POST
 +         )
 +     
 +     # Test invalid method
 +     with pytest.raises(ValueError):
 +         WebhookTask(
 +             name="test_task", 
 +             url="http://example.com",
 +             method="INVALID"
 +         )
 +         
 +     # Test invalid headers
 +     with pytest.raises(ValueError):
 +         WebhookTask(
 +             name="test_task",
 +             url="http://example.com",
 +             method=http.HTTPMethod.POST,
 +             headers="invalid-headers"
 +         )

Code Review Run #8c3d4c


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

  • it was incorrectly flagged

Signed-off-by: Ketan Umare <[email protected]>
Signed-off-by: Ketan Umare <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 16, 2025

Code Review Agent Run #cec794

Actionable Suggestions - 5
  • flytekit/extras/webhook/agent.py - 2
    • Consider broader exception handling for webhook · Line 78-78
    • Missing error handling in HTTP request · Line 36-47
  • flytekit/extras/webhook/task.py - 2
    • Consider validating data parameter JSON serialization · Line 86-86
    • Consider backward compatibility for parameter rename · Line 95-96
  • tests/flytekit/unit/extras/webhook/test_agent.py - 1
    • Consider error handling for text mock · Line 36-36
Additional Suggestions - 1
  • tests/flytekit/unit/extras/webhook/test_agent.py - 1
    • Consider consolidating info dictionary assertions · Line 63-64
Review Details
  • Files reviewed - 6 · Commit Range: ef2fd14..5c1537b
    • flytekit/extras/webhook/agent.py
    • flytekit/extras/webhook/constants.py
    • flytekit/extras/webhook/task.py
    • flytekit/utils/dict_formatter.py
    • tests/flytekit/unit/extras/webhook/test_agent.py
    • tests/flytekit/unit/extras/webhook/test_end_to_end.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

status, text = await self._make_http_request(method, url, headers, body)
if status != 200:
return Resource(
phase=TaskExecution.FAILED,
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider broader exception handling for webhook

Consider adding error handling for the _process_webhook call. The method could raise other exceptions besides aiohttp.ClientError that should be caught.

Code suggestion
Check the AI-generated fix before applying
Suggested change
phase=TaskExecution.FAILED,
return Resource(phase=TaskExecution.FAILED, message=f"HTTP client error: {str(e)}")
except Exception as e:
return Resource(phase=TaskExecution.FAILED, message=f"Webhook processing error: {str(e)}")

Code Review Run #cec794


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

  • it was incorrectly flagged

Signed-off-by: Kevin Su <[email protected]>
pingsutw
pingsutw previously approved these changes Feb 14, 2025
Signed-off-by: Kevin Su <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 14, 2025

Code Review Agent Run #fa3491

Actionable Suggestions - 4
  • flytekit/extend/backend/base_agent.py - 3
    • Consider function-scoped event loop initialization · Line 37-39
    • Consider local event loop management · Line 291-291
    • Consider using event loop context manager · Line 341-344
  • plugins/flytekit-aws-sagemaker/setup.py - 1
    • Consider using >= for version constraint · Line 8-8
Review Details
  • Files reviewed - 4 · Commit Range: a2cb871..17df670
    • dev-requirements.in
    • flytekit/extend/backend/base_agent.py
    • plugins/flytekit-aws-sagemaker/setup.py
    • tests/flytekit/unit/extras/webhook/test_task.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 +37 to +39
# It's used to force agent to run in the same event loop in the local execution.
local_agent_loop = asyncio.new_event_loop()

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider function-scoped event loop initialization

Consider moving the local_agent_loop initialization inside a function or method to avoid potential issues with module-level event loop creation. Module-level event loop initialization might cause problems if the module is imported multiple times or in different contexts.

Code suggestion
Check the AI-generated fix before applying
Suggested change
# It's used to force agent to run in the same event loop in the local execution.
local_agent_loop = asyncio.new_event_loop()
# It's used to force agent to run in the same event loop in the local execution.
_local_agent_loop = None
def get_local_agent_loop():
global _local_agent_loop
if _local_agent_loop is None:
_local_agent_loop = asyncio.new_event_loop()
return _local_agent_loop

Code Review Run #fa3491


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

  • it was incorrectly flagged

@@ -285,7 +288,7 @@ def execute(self: PythonTask, **kwargs) -> LiteralMap:
output_prefix = ctx.file_access.get_random_remote_directory()

agent = AgentRegistry.get_agent(task_template.type, task_template.task_type_version)
resource = asyncio.run(
resource = local_agent_loop.run_until_complete(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider local event loop management

Consider using asyncio.get_event_loop() instead of a global local_agent_loop. Using a global event loop can lead to issues in concurrent scenarios and makes testing more difficult. The event loop should be managed within the scope where it's needed.

Code suggestion
Check the AI-generated fix before applying
 -local_agent_loop = asyncio.new_event_loop()
 @@ -291,1 +291,1 @@
 -        resource = local_agent_loop.run_until_complete(
 +        resource = asyncio.get_event_loop().run_until_complete(

Code Review Run #fa3491


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

  • it was incorrectly flagged

Comment on lines +341 to +344
resource_meta = local_agent_loop.run_until_complete(
self._create(task_template=task_template, output_prefix=output_prefix, inputs=kwargs)
)
resource = asyncio.run(self._get(resource_meta=resource_meta))
resource = local_agent_loop.run_until_complete(self._get(resource_meta=resource_meta))
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using event loop context manager

Consider using a context manager with local_agent_loop to ensure proper cleanup of resources. The current approach of directly using run_until_complete could lead to resource leaks if exceptions occur.

Code suggestion
Check the AI-generated fix before applying
 -        resource_meta = local_agent_loop.run_until_complete(
 -            self._create(task_template=task_template, output_prefix=output_prefix, inputs=kwargs)
 -        )
 -        resource = local_agent_loop.run_until_complete(self._get(resource_meta=resource_meta))
 +        async with local_agent_loop:
 +            resource_meta = await self._create(task_template=task_template, output_prefix=output_prefix, inputs=kwargs)
 +            resource = await self._get(resource_meta=resource_meta)

Code Review Run #fa3491


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

  • it was incorrectly flagged

@@ -5,7 +5,7 @@

microlib_name = f"flytekitplugins-{PLUGIN_NAME}"

plugin_requires = ["flytekit>=1.11.0", "aioboto3>=12.3.0", "xxhash"]
plugin_requires = ["flytekit>1.14.6", "aioboto3>=12.3.0", "xxhash"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using >= for version constraint

Consider using >= instead of > for the flytekit dependency version. Using > might exclude compatible patch versions unnecessarily. The pattern >=1.14.6 would be more conventional and allow for patch updates while maintaining compatibility.

Code suggestion
Check the AI-generated fix before applying
Suggested change
plugin_requires = ["flytekit>1.14.6", "aioboto3>=12.3.0", "xxhash"]
plugin_requires = ["flytekit>=1.14.6", "aioboto3>=12.3.0", "xxhash"]

Code Review Run #fa3491


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

  • it was incorrectly flagged

pingsutw
pingsutw previously approved these changes Feb 15, 2025
@kumare3
Copy link
Contributor Author

kumare3 commented Feb 15, 2025

We should probably delete great expectations plugin?

Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
pingsutw
pingsutw previously approved these changes Feb 19, 2025
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 19, 2025

Code Review Agent Run #7908fc

Actionable Suggestions - 0
Additional Suggestions - 10
  • flytekit/core/cache.py - 1
    • Consider adding error details to message · Line 93-93
  • tests/flytekit/unit/utils/test_rate_limiter.py - 1
    • Consider adding edge case test coverage · Line 27-31
  • tests/flytekit/unit/core/test_type_engine.py - 1
  • tests/flytekit/unit/core/test_cache.py - 1
    • Consider more descriptive error message · Line 16-17
  • flytekit/utils/rate_limiter.py - 1
    • Consider configurable RPM validation limits · Line 13-14
  • flytekit/core/worker_queue.py - 2
  • flytekit/core/python_auto_container.py - 1
    • Consider adding parameter validation checks · Line 258-258
  • tests/flytekit/integration/remote/test_remote.py - 1
    • Consider error check before printing error · Line 165-165
  • tests/flytekit/unit/core/test_resources.py - 1
Review Details
  • Files reviewed - 32 · Commit Range: 17df670..6cb7967
    • flytekit/__init__.py
    • flytekit/clis/sdk_in_container/init.py
    • flytekit/core/cache.py
    • flytekit/core/constants.py
    • flytekit/core/node.py
    • flytekit/core/python_auto_container.py
    • flytekit/core/resources.py
    • flytekit/core/task.py
    • flytekit/core/type_engine.py
    • flytekit/core/worker_queue.py
    • flytekit/interaction/click_types.py
    • flytekit/interaction/string_literals.py
    • flytekit/remote/data.py
    • flytekit/remote/remote.py
    • flytekit/utils/rate_limiter.py
    • plugins/flytekit-aws-sagemaker/flytekitplugins/awssagemaker_inference/boto3_agent.py
    • plugins/flytekit-aws-sagemaker/tests/test_boto3_agent.py
    • plugins/flytekit-openai/flytekitplugins/openai/batch/agent.py
    • plugins/flytekit-openai/tests/openai_batch/test_agent.py
    • plugins/flytekit-ray/flytekitplugins/ray/task.py
    • pyproject.toml
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/dataclass_wf.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_cache.py
    • tests/flytekit/unit/core/test_node_creation.py
    • tests/flytekit/unit/core/test_resources.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/interaction/test_click_types.py
    • tests/flytekit/unit/interaction/test_string_literals.py
    • tests/flytekit/unit/models/test_tasks.py
    • tests/flytekit/unit/utils/test_rate_limiter.py
  • Files skipped - 3
    • .github/workflows/build_image.yml - Reason: Filter setting
    • .github/workflows/pythonbuild.yml - Reason: Filter setting
    • .github/workflows/pythonpublish.yml - Reason: Filter setting
  • 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

Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 19, 2025

Code Review Agent Run #809ba3

Actionable Suggestions - 1
  • tests/flytekit/integration/remote/test_remote.py - 1
    • Consider longer timeout for test stability · Line 919-920
Review Details
  • Files reviewed - 1 · Commit Range: 6cb7967..deb37b9
    • 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 919 to 920
execution = remote.wait(execution=execution, timeout=datetime.timedelta(minutes=5))
print("Execution Error:", execution.error)
assert execution.error is None, f"Execution failed with error: {execution.error}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider longer timeout for test stability

Consider keeping the timeout at 10 minutes instead of reducing to 5 minutes. The test may need more time to complete in certain environments. Additionally, the error assertion has been improved to provide better failure messages, which is good.

Code suggestion
Check the AI-generated fix before applying
Suggested change
execution = remote.wait(execution=execution, timeout=datetime.timedelta(minutes=5))
print("Execution Error:", execution.error)
assert execution.error is None, f"Execution failed with error: {execution.error}"
execution = remote.wait(execution=execution, timeout=datetime.timedelta(minutes=10))
assert execution.error is None, f"Execution failed with error: {execution.error}"

Code Review Run #809ba3


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Signed-off-by: Kevin Su <[email protected]>
pingsutw
pingsutw previously approved these changes Feb 20, 2025
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 20, 2025

Code Review Agent Run #3dcbb2

Actionable Suggestions - 0
Review Details
  • Files reviewed - 8 · Commit Range: deb37b9..b29ca68
    • flytekit/clis/sdk_in_container/serve.py
    • flytekit/core/type_engine.py
    • flytekit/remote/remote.py
    • plugins/flytekit-greatexpectations/tests/test_schema.py
    • plugins/flytekit-ray/flytekitplugins/ray/task.py
    • plugins/flytekit-ray/tests/test_ray.py
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/deep_child_workflow.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

Signed-off-by: Kevin Su <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 20, 2025

Code Review Agent Run #28b84f

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/flytekit/integration/remote/test_remote.py - 1
Review Details
  • Files reviewed - 1 · Commit Range: b29ca68..755e735
    • 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

@pingsutw pingsutw merged commit 6d7c738 into master Feb 20, 2025
108 of 110 checks passed
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