Hello, I am trying to use Sensors with Flyte agent...
# ask-the-community
m
Hello, I am trying to use Sensors with Flyte agents but the sensor tasks fail with
Copy code
failed to get grpc connection with error: failed to exit idle mode: passthrough: received empty target in Build()
and I see the same error message in propeller
Copy code
Failed to create resource....
using
v1.11.1-b1
version. These are my helm values(flyte-core)(relavant parts)
Copy code
flyteagent:
  enabled: true

configmap:  
  enabled_plugins:
    tasks:
      task-plugins:
        enabled-plugins:
          - agent-service
        default-for-task-types:
          sensor: agent-service
    plugins:
      agent-service:
        supportedTaskTypes:
          - sensor
agent logs
Copy code
Starting up the server to expose the prometheus metrics...                                                      
Starting the agent service...
Am I missing something out?
s
cc @Kevin Su / @L godlike
l
Hi, can you help me try this example?
Copy code
from flytekit.sensor.file_sensor import FileSensor
from flytekit import task, workflow

sensor = FileSensor(name="test_sensor")

@task()
def t1():
    return

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

if __name__ == "__main__":
    wf()
try this.
Copy code
pyflyte run --remote sensor_example.py sensor --path "<s3://my-s3-bucket>"
m
I get the same error
l
Can you show me your agent image?
m
Copy code
image: <http://ghcr.io/flyteorg/flyteagent:1.11.0|ghcr.io/flyteorg/flyteagent:1.11.0>
l
Thanks
Do you have this in your config map?
Copy code
agent-service:
	defaultAgent:
	  defaultTimeout: 10s
	  endpoint: dns:///flyteagent.flyte.svc.cluster.local:8000
	  insecure: true
	  timeouts:
	    GetTask: 10s
	supportedTaskTypes:
	- default_task
It works for me
I think the main reason is about your grpc connection
m
I only had this part
Copy code
agent-service:
        supportedTaskTypes:
          - sensor
after updating with yours, it started working now!
but this configuration is not aligned with the configuration documented https://docs.flyte.org/en/latest/deployment/agents/sensor.html#deployment-agent-setup-sensor
l
Thank you
I will discuss with Kevin how to update the doc
thanks
m
thank you as well!
l
Hi, @Mücahit I've created a PR here, thank you again. https://github.com/flyteorg/flyte/pull/5208
image.png
looks more clear now : )
m
Awesome @L godlike 🙌
l
apologies for leeching on this thread, i was hitting the same error and workaround after adding the same config. Still have issue with custom sync agent. From what i understood in the code, only async agent needs to implement the create method but not sync agent, did i configure anything wrongly? err msg
Copy code
USER::rpc error: code = Internal desc = failed to create caramlnotification task with error: 'CustomAgent' object has no attribute 'create'
helm
Copy code
enabled_plugins:
    tasks:
        enabled-plugins:
          - container
          - sidecar
          - k8s-array
          - agent-service
        default-for-task-types:
          container: container
          sidecar: sidecar
          container_array: k8s-array
          customagent: agent-service
    plugins:
      agent-service:
        supportedTaskTypes:
        - customagent
        defaultAgent:
          defaultTimeout: 10s
          endpoint: dns:///flyteagent.flyte.svc.cluster.local:8000
          insecure: true
          timeouts:
            GetTask: 10s
Task
Copy code
class CustomAgentTask(SyncAgentExecutorMixin, PythonTask):
    _TASK_TYPE = "customagent"
super().__init__(
            task_type=self._TASK_TYPE,
            ...
        )
Agent
Copy code
class CustomAgent(SyncAgentBase):
    _TASK_TYPE = "customagent"
    def __init__(self):
        super().__init__(task_type_name=TASK_TYPE)
I tried printing the agent registry locally while running
pyflyte serve agent --port 8000
Copy code
agent is name: "Sensor"
supported_task_types: "sensor"
supported_task_categories {
  name: "sensor"
}
Starting Sensor that supports task categories ['sensor']

agent is name: "Custom Agent"
supported_task_types: "customagent"
is_sync: true
supported_task_categories {
  name: "customagent"
}
Starting Custom Agent that supports task categories ['customagent']

 agent is name: "ChatGPT Agent"
supported_task_types: "chatgpt"
is_sync: true
supported_task_categories {
  name: "chatgpt"
}
Starting ChatGPT Agent that supports task categories ['chatgpt']
m
@Lee Ning Jie Leon not sure if this will help, but I'll just dump my working configuration. I'm using FileSensor only at the moment
Copy code
plugins:
      agent-service:
        supportedTaskTypes:
          - sensor
        defaultAgent:
          defaultTimeout: 10s
          endpoint: dns:///flyteagent.flyte.svc.cluster.local:8000
          insecure: true
l
oh nvm ignore me, it work after i restarted the propeller, although i dont know why. Thanks @Mücahit, i was hitting the same grpc error you had initially too
l
it work after i restarted the propeller
It's because propeller needs to read the
supported task type
from the configmap again. It is not dynamically changing now.