Point72 / Point72/csp

Push adapter initialization does not forward annotation arguments correctly

Open
#569 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
Python
Stars
441
Forks
90
Avg merge
1d 12m
Merged PRs (30d)
5

Description

Push adapters (potentially all adapters, haven't checked) are normalizing annotation arguments even if they are not within a csp.ts object.

Describe the bug

To Reproduce

from datetime import datetime, timedelta
from typing import Dict, TypeVar

import csp
from csp.impl.pushadapter import PushInputAdapter
from csp.impl.wiring import py_push_adapter_def

T = TypeVar("T")


class _AdapterImpl(PushInputAdapter):
    def __init__(self, ts_typ: T):  # noqa
        print(ts_typ)
        raise

    def start(self, starttime: datetime, endtime: datetime):
        pass

    def stop(self):
        pass

MyPushAdapter = py_push_adapter_def(
    "adapter_def",
    _AdapterImpl,
    csp.ts[T],
    ts_typ=T,
)

@csp.graph
def my_graph() -> csp.ts[Dict[str, int]]:
    data = MyPushAdapter(ts_typ=Dict[str,int])
    return data

csp.run(my_graph, starttime=datetime.utcnow(), endtime=timedelta())

Prints: class <dict> instead of typing.Dict[str, int]

Expected behavior

Should print typing.Dict[str, int]

Error Message

Runtime Environment

0.11.1
3.11.11 (main, Jan 30 2025, 14:30:53) [GCC 13.3.0]
linux

Additional context

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction and inspect PushInputAdapter in csp.impl.pushadapter together with py_push_adapter_def in csp.impl.wiring. Trace how the ts_typ annotation argument is normalized during adapter initialization; done means the adapter receives typing.Dict[str, int] rather than dict, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
stream-processing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.