gray-ram-51379
05/07/2024, 4:16 AMrpc error: code = Internal desc = failed to get sensor task with error: No module named 'sensor'.
this is the stack trace:
{"json":{"routine":"agent-service-worker-0","src":"cache.go:84"},"level":"debug","msg":"Sync loop - processing resource with cache key [f677097c1e4564916ad6-n0-0]","ts":"2024-05-07T04:12:02Z"}
{"json":{"routine":"agent-service-worker-0","src":"cache.go:113"},"level":"debug","msg":"Querying AsyncPlugin for f677097c1e4564916ad6-n0-0","ts":"2024-05-07T04:12:02Z"}
{"json":{"routine":"agent-service-worker-0","src":"cache.go:116"},"level":"info","msg":"Error retrieving resource [f677097c1e4564916ad6-n0-0]. Error: rpc error: code = Internal desc = failed to get sensor task with error: No module named 'sensor'.","ts":"2024-05-07T04:12:02Z"}
this is the workflow with sensor I’m testing with, it’s very simple:
from flytekit import task, workflow
from flytekit.sensor.base_sensor import BaseSensor
import time
class TimeDeltaSensor(BaseSensor):
def __init__(self, name: str, **kwargs):
super().__init__(name=name, **kwargs)
async def poke(self, timeDelta: int) -> bool:
print("Before the sleep sensor")
time.sleep(timeDelta)
print("After the time sleep sensor")
return True
time_delta_sensor = TimeDeltaSensor(name="Time_Delta_mySensor")
@task()
def t1():
print("SUCCEEDED")
@workflow()
def wf():
time_delta_sensor(timeDelta=11) >> t1()
if __name__ == "__main__":
wf()
any idea why this is failing? any help is appreciated 🙏 cc: @glamorous-carpet-83516gray-ram-51379
05/07/2024, 4:17 AM(venv) yaou@yaou-mn1 sensor % pip list | grep flyte
flyteidl 1.12.0
flytekit 1.12.0
glamorous-carpet-83516
05/07/2024, 4:23 AMgray-ram-51379
05/07/2024, 4:24 AMglamorous-carpet-83516
05/07/2024, 4:29 AMgray-ram-51379
05/07/2024, 4:35 AMfrom flytekit.sensor.file_sensor import FileSensor
and use it.
What’s the reason why I cannot do that in my workflow?glamorous-carpet-83516
05/07/2024, 4:37 AMTimeDeltaSensor
doesn’t exist in the agent server, so agent can’t not import this classglamorous-carpet-83516
05/07/2024, 4:38 AMgray-ram-51379
05/07/2024, 4:40 AMglamorous-carpet-83516
05/07/2024, 4:41 AM--remote
glamorous-carpet-83516
05/07/2024, 4:43 AMTimeDeltaSensor
gray-ram-51379
05/07/2024, 4:47 AMpip install
line in here?
Do I do flytectl demo start
(which also starts the agent service) first then run the dockerfile that would “restart” the agent ?freezing-airport-6809
glamorous-carpet-83516
05/07/2024, 5:01 AMflytectl demo start
first, and then replace the agent’s image with the image you built.damp-lion-88352
05/07/2024, 5:29 AMdamp-lion-88352
05/07/2024, 5:29 AMdamp-lion-88352
05/07/2024, 5:36 AMdamp-lion-88352
05/07/2024, 5:36 AMgray-ram-51379
05/07/2024, 5:38 AMgray-ram-51379
05/23/2024, 4:56 AMflytekit-timesensor
plugin, I `pip install -e .`the whole local flytekit as well as pip installed this new plugin I developed. The logic of the timeDeltaSensor is the same as the one pasted above ^
I edited the Dockerfile.agent to look like this, pushed it and re-deployed the flyteagent:
FROM python:3.10-slim-bookworm as agent-slim
MAINTAINER Flyte Team <users@flyte.org>
LABEL org.opencontainers.image.source=<https://github.com/flyteorg/flytekit>
RUN apt-get update && apt-get install build-essential -y
COPY ./plugins/flytekit-timesensor /root/timesensor
RUN pip install /root/timesensor
RUN pip install prometheus-client grpcio-health-checking
RUN pip install --no-cache-dir -U flytekit \
flytekitplugins-airflow \
flytekitplugins-bigquery \
flytekitplugins-openai \
flytekitplugins-snowflake \
flytekitplugins-awssagemaker \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& :
CMD pyflyte serve agent --port 8000
but when I tried to run a workflow that uses this timeDeltaSensor, it is giving error
rpc error: code = DeadlineExceeded desc = context deadline exceeded
.
Any advice? cc: @glamorous-carpet-83516 thank you 🙏woohoogray-ram-51379
05/23/2024, 4:57 AMflytectl demo start
for the whole setupgray-ram-51379
05/23/2024, 5:28 AMdamp-lion-88352
05/23/2024, 5:30 AMdamp-lion-88352
05/23/2024, 5:30 AMdamp-lion-88352
05/23/2024, 5:30 AMdamp-lion-88352
05/23/2024, 5:30 AMgray-ram-51379
05/23/2024, 5:33 AMdamp-lion-88352
05/23/2024, 5:33 AMFROM python:3.9-slim-bookworm
RUN apt-get update && apt-get install build-essential git -y
RUN pip install prometheus-client grpcio-health-checking
RUN pip install --no-cache-dir -U \
git+<https://github.com/flyteorg/flytekit.git@><gitsha>
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& :
CMD pyflyte serve agent --port 8000
damp-lion-88352
05/23/2024, 5:33 AMgit+<https://github.com/flyteorg/flytekit.git@><gitsha>
damp-lion-88352
05/23/2024, 5:33 AMdamp-lion-88352
05/23/2024, 5:33 AMdamp-lion-88352
05/23/2024, 5:34 AM<http://github.com/sally/flytekit.git@gitsha|github.com/sally/flytekit.git@gitsha>
damp-lion-88352
05/23/2024, 5:34 AMalias gitsha="git rev-parse HEAD";
damp-lion-88352
05/23/2024, 5:34 AMdamp-lion-88352
05/23/2024, 5:35 AMFROM python:3.9-slim-bookworm
RUN apt-get update && apt-get install build-essential git -y
RUN pip install prometheus-client grpcio-health-checking
RUN pip install --no-cache-dir -U \
git+<https://github.com/Sally-Yang-Jing-Ou/flytekit.git@a829b1893a86ecbaa64ede871de1a723ae329d3c>
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& :
CMD pyflyte serve agent --port 8000
damp-lion-88352
05/23/2024, 5:35 AMdamp-lion-88352
05/23/2024, 5:36 AMFROM python:3.9-slim-bookworm
RUN apt-get update && apt-get install build-essential git -y
RUN pip install prometheus-client grpcio-health-checking
RUN pip install --no-cache-dir -U \
git+<https://github.com/Sally-Yang-Jing-Ou/flytekit.git@a829b1893a86ecbaa64ede871de1a723ae329d3c>
git+<https://github.com/Sally-Yang-Jing-Ou/flytekit.git@a829b1893a86ecbaa64ede871de1a723ae329d3c#subdirectory=plugins/flytekit-timesensor> \
&& apt-get clean autoclean \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ \
&& :
CMD pyflyte serve agent --port 8000
damp-lion-88352
05/23/2024, 5:36 AMclean-glass-36808
05/23/2024, 5:37 AMgray-ram-51379
05/23/2024, 5:38 AMdamp-lion-88352
05/23/2024, 5:38 AMdamp-lion-88352
05/23/2024, 5:39 AMdamp-lion-88352
05/23/2024, 5:39 AMdamp-lion-88352
05/23/2024, 5:40 AMdamp-lion-88352
05/23/2024, 5:40 AMGetTask
gray-ram-51379
05/23/2024, 5:40 AMdamp-lion-88352
05/23/2024, 5:40 AMCreateTask
clean-glass-36808
05/23/2024, 5:42 AMgray-ram-51379
05/23/2024, 5:43 AMdamp-lion-88352
05/23/2024, 5:44 AMdamp-lion-88352
05/23/2024, 5:44 AMdamp-lion-88352
05/23/2024, 5:44 AMdamp-lion-88352
05/23/2024, 5:45 AMgray-ram-51379
05/23/2024, 5:46 AMdamp-lion-88352
05/23/2024, 5:46 AMdamp-lion-88352
05/23/2024, 5:54 AM