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

typing.Any not handled properly as an output from a csp.node #436

Open
NeejWeej opened this issue Jan 31, 2025 · 0 comments
Open

typing.Any not handled properly as an output from a csp.node #436

NeejWeej opened this issue Jan 31, 2025 · 0 comments
Labels
type: bug Concrete, reproducible bugs

Comments

@NeejWeej
Copy link
Collaborator

Describe the bug
typing.Any is not handled properly. This occurs both if CSP_PYDANTIC is set as an environment behavior or not

To Reproduce

import csp
import typing

from datetime import datetime, timedelta

import sys

print(csp.__version__); print(sys.version); print(sys.platform)

@csp.node
def val(x: csp.ts[object]) -> csp.ts[typing.Any]:
    return x

@csp.node
def val2(x: csp.ts[typing.Any]) -> csp.ts[object]:
    return x

csp.run(val2, csp.const(1), starttime=datetime.utcnow(), endtime=timedelta(seconds=3))
csp.run(val, csp.const(1), starttime=datetime.utcnow(), endtime=timedelta(seconds=3))  # fails here

Expected behavior
Both of these should pass

Error Message

TypeError                                 Traceback (most recent call last)
Cell In[22], [line 20](vscode-notebook-cell:?execution_count=22&line=20)
     [17](vscode-notebook-cell:?execution_count=22&line=17)     return x
     [19](vscode-notebook-cell:?execution_count=22&line=19) csp.run(val2, csp.const(1), starttime=datetime.utcnow(), endtime=timedelta(seconds=3))
---> [20](vscode-notebook-cell:?execution_count=22&line=20) csp.run(val, csp.const(1), starttime=datetime.utcnow(), endtime=timedelta(seconds=3))  # fails here

File csp/csp/impl/wiring/runtime.py:167, in run(g, starttime, endtime, queue_wait_time, realtime, output_numpy, *args, **kwargs)
    [157](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.netcsp/csp/impl/wiring/runtime.py:157) def run(
    [158](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.netcsp/csp/impl/wiring/runtime.py:158)     g,
    [159](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:159)     *args,
   (...)
    [165](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:165)     **kwargs,
    [166](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:166) ):
--> [167](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:167)     with ExceptionContext():
    [168](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:168)         starttime, endtime = _normalize_run_times(starttime, endtime, realtime)
    [170](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/wiring/runtime.py:170)         engine_settings = {"queue_wait_time": queue_wait_time, "realtime": realtime, "output_numpy": output_numpy}

File csp/csp/impl/error_handling.py:40, in ExceptionContext.__exit__(self, exc_type, exc_val, exc_tb)
     [37](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/error_handling.py:37) if exc_type is CspParseError and exc_val.filename is not None and exc_val.lineno is not None:
     [38](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/error_handling.py:38)     new_tb = _cspimpl.create_traceback(new_tb, exc_val.frame, exc_val.lineno, exc_val.lineno)
---> [40](https://vscode-remote+ssh-002dremote-002bdev06.vscode-resource.vscode-cdn.net/csp/csp/impl/error_handling.py:40) raise exc_val.with_traceback(new_tb)

Cell In[22], [line 13](vscode-notebook-cell:?execution_count=22&line=13)
     [11](vscode-notebook-cell:?execution_count=22&line=11) @csp.node
     [12](vscode-notebook-cell:?execution_count=22&line=12) def val(x: csp.ts[object]) -> csp.ts[typing.Any]:
---> [13](vscode-notebook-cell:?execution_count=22&line=13)     return x

TypeError: PyOutputProxy.h:outputTick:56:TypeError: "val" node expected output type on output #0 to be of type "Any" got type "int"

Runtime Environment
0.0.7
3.12.7 | packaged by conda-forge | (main, Oct 4 2024, 16:05:46) [GCC 13.3.0]
linux

@NeejWeej NeejWeej added the type: bug Concrete, reproducible bugs label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Concrete, reproducible bugs
Projects
None yet
Development

No branches or pull requests

1 participant