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

[wip] FileSensor Timeout (Remote Execution Only) #2745

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Sep 11, 2024

Tracking issue

flyteorg/flyte#5035

Why are the changes needed?

timout is important for agent tasks.

What changes were proposed in this pull request?

How was this patch tested?

from flytekit import task, workflow
from flytekit.sensor.file_sensor import FileSensor

sensor = FileSensor(name="test_file_sensor", timeout=10)


# %%
@task()
def t1():
    print("SUCCEEDED")


@workflow()
def wf():
    sensor(path=".") >> t1()


if __name__ == "__main__":
    from flytekit.clis.sdk_in_container import pyflyte
    from click.testing import CliRunner

    runner = CliRunner()
    path = "/Users/future-outlier/code/dev/flytekit/build/PR/agent/sensor_task.py"
    result = runner.invoke(pyflyte.main, ["run", path, "wf",])

    print("Local Execution: ", result.output)
    #
    result = runner.invoke(pyflyte.main, ["run", "--remote", path, "wf"])
    print("Remote Execution: ", result.output)

Setup process

Screenshots

image image image

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

Signed-off-by: Future-Outlier <[email protected]>
@Future-Outlier
Copy link
Member Author

Future-Outlier commented Sep 11, 2024

Hi, @pingsutw
Do you think it's a good idea to support timeout by Resource Wrapper in flyteplugins/agent?
https://github.com/flyteorg/flyte/blob/master/flyteplugins/go/tasks/plugins/webapi/agent/plugin.go#L40-L48

Or should we make this feature more generic?

Update: it's done already!

@Future-Outlier Future-Outlier changed the title [wip] FileSensor Timeout FileSensor Timeout Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.03%. Comparing base (ae9c6f8) to head (6206175).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2745      +/-   ##
==========================================
+ Coverage   90.87%   95.03%   +4.16%     
==========================================
  Files          74       42      -32     
  Lines        3331     2095    -1236     
==========================================
- Hits         3027     1991    -1036     
+ Misses        304      104     -200     

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

@Future-Outlier Future-Outlier changed the title FileSensor Timeout FileSensor Timeout (Remote Execution Only) Sep 11, 2024
@Future-Outlier Future-Outlier changed the title FileSensor Timeout (Remote Execution Only) [wip] FileSensor Timeout (Remote Execution Only) Sep 11, 2024
@@ -203,12 +203,13 @@ def __init__(
task_type_version=0,
security_ctx: Optional[SecurityContext] = None,
docs: Optional[Documentation] = None,
timeout: Optional[Union[datetime.timedelta, int]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to expose metadata to the PythonTask and have BaseSensor initialize the metadata w/ TaskMetadata(timeout=timeout)?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes it will make more sense.

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Future-Outlier <[email protected]>
Comment on lines +218 to +219
# put timeout to metadata here
# raise error if metadata and timeout are both set
Copy link
Member

Choose a reason for hiding this comment

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

I do not like how timeout can be defined in two places. If we really want a easy way to set timeout, I would do this logic FileSensor and not complicate the Task API.

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.

3 participants