pymc-devs / pymc-devs/pytensor

Make props related functionality a part of the Op baseclass

Open
#1,459 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

graph objects Op implementation refactor
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

This is in MetaType, but AFAICT only ops ever have props

https://github.com/pymc-devs/pytensor/blob/17748b7d3419e78e7dfad3dc768908ac240aa6df/pytensor/graph/utils.py#L193-L234

Generating them dynamically like this means linters / mypy don't believe in op._props() or op._props_dict(). I don't know why this has to be implemented as methods in the MetaClass instead of just in the Op baseclass. Would be great if someone gave a try at it. It also means we could probably get rid of the whole MetaType class, since the only other thing is a string convenience, which definitely need not be defined there.

May also be worth investigating if we can use frozen dataclasses for Ops and automate the props logic (see aesara discussion, but that needs not be done together with addressing the main issue here.

Contributor guide

Open the contributing guide

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 with pytensor/graph/utils.py at the linked MetaType implementation and inspect how Op classes use props, _props(), and _props_dict(). Determine whether the props behavior and string convenience can move into Op without changing existing behavior. Done means the refactor is covered by the relevant existing checks and static typing recognizes the props methods; no pull request or test path is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.