Hi, I am trying to write a `sensor` which is supp...
# ask-the-community
c
Hi, I am trying to write a
sensor
which is supposed to check if an object exists in an
S3 bucket
or not. I am referring to this tutorial but I would like to know how to package this sensor + workflow together? Do we keep in a docker container? or register sensor in Flyte?
k
@Chandrashekhar Kotekar you should look at Flyte agent framework - which is soft released and is being released in 1.9 that also contains s3/file sensor and auto support for any airflow sensor, and runs as a long running service
y
And a great video talking about agent. The FileSensoerAgent example is at 11:59.

https://www.youtube.com/watch?v=nD98GQ-pyAE&t=881

k
cc @Kevin Su share the example
@Chandrashekhar Kotekar we would love if you could help us "validate it" and share your insights. it is ready but we would love your thoughts
please wait for 1.9
c
Hi @Ketan (kumare3) We are using
flytekit==1.8.1
. Did you meant to say that flytekit 1.9 will come with this s3/ file sensor?
Hi @Ketan (kumare3) there are some differences between the Flyte document and the video: • In the document, sensor inherits
PythonTask
but in the video sensor inherits
PythonTask
and
AsyncAgentExecutorMixin
as well. This
mix-in
has the
execute()
method • In the video apart from sensor, they have written an agent as well but in the document agent is not mentioned
I've asked this question under the comments section of the video as well (just repeating it here for the sake of reference) - it this file sensor example available in some GitHub repo? Code might help me better understand the whole structure and code of the of the plugin in better way.
k
Hi @Chandrashekhar Kotekar • For the sensor, we are adding another class on top of agent, which makes adding a new agent much easier. check out this pr • if you want to submit the job to the external service, such as BigQuery. you can refer to this agent The tasks run on agents, so if you create a new task, you need to create an agent as well. in the sensor pr, I create a sensor task and agent. The task inheriting
AsyncAgentExecutorMixin
can be run locally. In the
execute
, we actually call agent create / get to run the task. if you don’t want to run on agent, you can override the
execute
by yourself.
we’ll love to learn more about your use cases. feel free to DM me. we’re writing more blogs for agent, will share it with you.
c
Thanks @Kevin Su for the examples. I am reading PR now.
k
Here is an airflow agent, allows you to use airflow operator / sensor in the flyte workflow. every airflow tasks are running on this agent. Really appreciate any feedback!
c
my use case is like: we have one pipeline which usess input data from S3 objects. We want to write sensor OR agent OR something else which will allow the pipeline to keep waiting until S3 object has become available . Once S3 object is available, pipeline should start executing the actual tasks.
It seems like this file sensor does similar thing and I just wanted to modify it to look for S3 objects instead of local file.
k
ok, seems like file sensor PR can be used in your use cases. you can pull the PR, and give it a shot.
c
that's great. Thanks 🙂
k
You don’t have to modify it
It will work for s3 or local file automatically
k
yes, we’ll merge it soon
c
that's cool. If I've understood it correctly - this file sensor will be available from flytekit version 1.9 . Am I right?
k
correct
c
Perfect. Do we know when v 1.9 will be available? 🙂
Asking so that I can convey the same thing to my team as well
k
next week. will let you know once 1.9 is out
c
Awesome. Looking forward to it