ChimeraPy / Engine

Distributed computing framework for Multimodal data written in Python
https://chimerapy-engine.readthedocs.io
GNU General Public License v3.0
8 stars 0 forks source link

Async functions were never awaited #275

Closed albertna closed 11 months ago

albertna commented 11 months ago

When I try to run a test config for a node with async setup and step functions I get exceptions like the following:

2023-10-03 12:15:59 [DEBUG] chimerapy-engine-worker.local: <Worker name=local id=5a521e5d-a754-4799-bfc3-666975186409>-HttpServerService: note_status_update:
Exception in thread Thread-3 (send_loop):
2023-10-03 12:15:59 [DEBUG] chimerapy-engine-node.client(NodeID-[a33da1f7-a548-43e5-8ae0-420ceeecd822]): <Client a33da1f7-a548-43e5-8ae0-420ceeecd822>: send_msg -> NODE_MESSAGE.STATUS with OK=False
Traceback (most recent call last):
C:\Users\***\.conda\envs\CPPipelines\Lib\site-packages\chimerapy\engine\networking\data_chunk.py:23: RuntimeWarning: coroutine 'G3.step' was never awaited
  "image": (self._serialize_image, self._deserialize_image),
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  File "C:\Users\***\.conda\envs\CPPipelines\Lib\threading.py", line 1038, in _bootstrap_inner
C:\Users\***\.conda\envs\CPPipelines\Lib\site-packages\chimerapy\engine\networking\data_chunk.py:28: RuntimeWarning: coroutine 'G3.step' was never awaited
  "image": self._check_image,
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\***\.conda\envs\CPPipelines\Lib\site-packages\chimerapy\engine\networking\data_chunk.py:27: RuntimeWarning: coroutine 'G3.step' was never awaited
  self._content_type_2_checks_mapping = {
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Ready to start? (Y/n)2023-10-03 12:15:59 [DEBUG] chimerapy-engine-node(NodeID-[a33da1f7-a548-43e5-8ae0-420ceeecd822]): <Node name=show id=a33da1f7-a548-43e5-8ae0-420ceeecd822>-ProcessorService: started processor while loop
    self.run()
C:\Users\***\.conda\envs\CPPipelines\Lib\site-packages\chimerapy\engine\networking\data_chunk.py:35: RuntimeWarning: coroutine 'G3.step' was never awaited
  "created": datetime.datetime.now(),
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
edavalosanaya commented 11 months ago

Hello @albertna!

Do you mind sharing what version of ChimeraPy you have? Could you provide the pip freeze dump?

Also, could you share a snippet or the code that you are running?

Best, Eduardo Davalos

albertna commented 11 months ago

pip freeze dump:

aiofiles==23.2.1
aiohttp==3.8.5
aiortsp @ git+https://github.com/m4reko/aiortsp@16b0e084e2520759ed32ff1dd911d82db84b8f34
aiosignal==1.3.1
annotated-types==0.5.0
anyio==3.7.1
async-timeout==4.0.3
attrs==23.1.0
av==10.0.0
blosc==1.11.1
certifi==2023.7.22
cfgv==3.4.0
charset-normalizer==3.2.0
chimerapy==0.0.10
chimerapy-engine==0.1.0
chimerapy-orchestrator==0.0.2
-e git+https://github.com/albertna/Pipelines.git@a03f3ff6cc8c2827d19c3945b2c147b662aca1c1#egg=chimerapy_pipelines
click==8.1.6
colorama==0.4.6
comtypes==1.2.0
contourpy==1.1.0
cycler==0.11.0
dataclasses-json==0.5.14
dill==0.3.7
distlib==0.3.7
dnspython==2.4.2
dpkt==1.9.8
dxcam==0.0.5
email-validator==2.0.0.post2
fastapi==0.101.1
filelock==3.12.2
fonttools==4.42.0
frozenlist==1.4.0
g3pylib @ git+https://github.com/albertna/g3pylib.git@43340cdeeac9afb7d8ac0507441701b78e10d35a
h11==0.14.0
httpcore==0.17.3
httptools==0.6.0
httpx==0.24.1
identify==2.5.26
idna==3.4
ifaddr==0.2.0
importlib-metadata==6.8.0
imutils==0.5.4
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
kiwisolver==1.4.4
MarkupSafe==2.1.3
marshmallow==3.20.1
matplotlib==3.7.2
mpmath==1.3.0
mss==9.0.1
multidict==6.0.4
multiprocess==0.70.15
mypy-extensions==1.0.0
netifaces==0.11.0
networkx==3.1
nodeenv==1.8.0
numpy==1.25.2
opencv-python==4.8.0.76
orjson==3.9.4
packaging==23.1
pandas==2.0.3
Pillow==10.0.0
platformdirs==3.10.0
pluggy==1.2.0
pre-commit==3.3.3
PyAudio==0.2.13
pydantic==2.1.1
pydantic-extra-types==2.0.0
pydantic-settings==2.0.3
pydantic_core==2.4.0
pyparsing==3.0.9
pytest==7.4.0
pytest-lazy-fixture==0.6.3
pytest-repeat==0.9.1
pytest-rerunfailures==12.0
python-dateutil==2.8.2
python-dotenv==1.0.0
python-multipart==0.0.6
pytz==2023.3
PyYAML==6.0.1
pyzmq==25.1.1
requests==2.31.0
seaborn==0.12.2
simplejpeg==1.7.1
six==1.16.0
sniffio==1.3.0
starlette==0.27.0
sympy==1.12
torch==2.0.1
torchvision==0.15.2
tqdm==4.66.1
typing-inspect==0.9.0
typing_extensions==4.7.1
tzdata==2023.3
ujson==5.8.0
urllib3==2.0.4
uvicorn==0.23.2
virtualenv==20.24.3
watchfiles==0.19.0
websockets==10.4
yarl==1.9.2
zeroconf==0.47.4
zipp==3.16.2

Code that I'm running:

async def setup(self) -> None:
    self.g3 = await connect_to_glasses.with_hostname(
        self.hostname, using_zeroconf=True
    )

    streams = await self.g3.stream_rtsp(scene_camera=True, gaze=True)
    self.scene_stream = streams.scene_camera.decode()
    self.gaze_stream = streams.gaze.decode()

async def step(self) -> cpe.DataChunk:
    ret_chunk = cpe.DataChunk()

    frame_data, frame_timestamp = await self.scene_stream.get()
    gaze_data, gaze_timestamp = await self.gaze_stream.get()

    # Match frame and gaze timestamps
    while gaze_timestamp is None or frame_timestamp is None:
        if frame_timestamp is None:
            frame_data, frame_timestamp = await self.scene_stream.get()
        if gaze_timestamp is None:
            gaze_data, gaze_timestamp = await self.gaze_stream.get()
    while gaze_timestamp < frame_timestamp:
        gaze_data, gaze_timestamp = await self.gaze_stream.get()
        while gaze_timestamp is None:
            gaze_data, gaze_timestamp = await self.gaze_stream.get()

    # logging.info(f"Frame timestamp: {frame_timestamp}")
    # logging.info(f"Gaze timestamp: {gaze_timestamp}")
    frame_data = frame_data.to_ndarray(format="bgr24")

    if self.show_gaze and "gaze2d" in gaze_data:
        gaze2d = gaze_data["gaze2d"]
        logging.info(f"Gaze2d: {gaze2d[0]:9.4f},{gaze2d[1]:9.4f}")

        # Convert rational (x,y) to pixel location (x,y)
        h, w = frame_data.shape[:2]
        fix = (int(gaze2d[0] * w), int(gaze2d[1] * h))

        # Draw gaze
        frame_data = cv2.circle(frame_data, fix, 10, (0, 0, 255), 3)

    ret_chunk.add(self.frame_key, frame_data, "image")
    ret_chunk.add("gaze_data", gaze_data)
    # ret_chunk.add("frame_timestamp", frame_timestamp)
    # ret_chunk.add("gaze_timestamp", gaze_timestamp)

    return ret_chunk
edavalosanaya commented 11 months ago

We are at the moment trying to push for a new release to PIPY with the fix. For now, could you try updating your version of ChimeraPy Engine via the GitHub repo, use the following command:

git clone git@github.com:ChimeraPy/Engine.git
cd Engine
pip install -e .

Then try again to run the pipeline. Also, how are you running the pipeline? Via the Orchestrator or via the engine directly?

albertna commented 11 months ago

We are at the moment trying to push for a new release to PIPY with the fix. For now, could you try updating your version of ChimeraPy Engine via the GitHub repo, use the following command:

git clone git@github.com:ChimeraPy/Engine.git
cd Engine
pip install -e .

Then try again to run the pipeline. Also, how are you running the pipeline? Via the Orchestrator or via the engine directly?

I'm running it via thecp-orchestrator orchestrate --config command.

albertna commented 11 months ago

Looks like I'm getting a different bunch of errors now, which is progress! Is there a way to halt CP execution? I tried keyboard interrupt with Ctrl-C but it doesn't do anything (CP recognizes that and prints it out but it doesn't stop). I need to see the error messages at the start of the execution. Right now the only way to stop is to kill the shell and I get empty log files with it.

albertna commented 11 months ago

Issue is solved by updating Orchestrator to latest. Closing.