Ensure that adapters can be constructed in a simpler manner than they are currently

Open
#272 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python

Research direction

Start by comparing the adapter patterns in examples/04_writing_adapters/e2_pullinput.py, e3_adaptermanager_pullinput.py, and e5_adaptermanager_pushinput.py, then inspect csp/adapters/kafka.py for the anonymous wrapper pattern. Done means proposing and implementing a coherent simpler construction approach that covers pull adapters, managed adapters, and push/output adapter definitions while reducing unnecessary classes.

Written by the indexing model from the issue text.

Description

adapter: general type: enhancement

1. Adapters + Impls where the Impl is tiny:

https://github.com/Point72/csp/blob/234f94cfd9924ca479485b97d56f7cc91141f3d2/examples/04_writing_adapters/e2_pullinput.py#L19

MyPullAdapter = py_pull_adapter_def("MyPullAdapter", MyPullAdapterImpl, ts[int], interval=timedelta, num_ticks=int)

One would expect we could do this via type annotations in some form or another, or something like pydantic since the py_pull_adapter_def mostly serves to wrap the impl inputs.

2. Minimal Managers / other places where excess classes are needed

https://github.com/Point72/csp/blob/234f94cfd9924ca479485b97d56f7cc91141f3d2/examples/04_writing_adapters/e3_adaptermanager_pullinput.py
https://github.com/Point72/csp/blob/main/examples/04_writing_adapters/e5_adaptermanager_pushinput.py

These examples requires 4+ classes (!!):

  • MyAdapterManager
  • MyAdapterManagerImpl
  • MyManagedSimAdapterImpl
  • MyManagedSimAdapter

This is pretty bad UX/design.

3. Automatic py_push_adapter_def / py_output_adapter_def, etc

Similar to the above, we often create these "anonymous" objects for binding the adapter-specific code to the engine wrapping necessary, I think we can consolidate this in some form
https://github.com/Point72/csp/blob/234f94cfd9924ca479485b97d56f7cc91141f3d2/csp/adapters/kafka.py#L187

Dominant language
Python
Stars
450
Forks
91
Avg merge
18h 8m
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from Point72/csp

All issues in Point72/csp

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.