codepy icon indicating copy to clipboard operation
codepy copied to clipboard

All args for Toolchain subclasses now mandatory with release of v2025.1

Open EdCaunt opened this issue 9 months ago • 3 comments

With this change (repeated for each class in the file), bundled in the most recent PyPi release, it appears that all args for instantiating subclasses of Toolchain are now mandatory which has forced us to fix our dependencies on a previous release and burn a new version.

I believe @dataclass(frozen=True, kw_only=True) would fix this issue.

EdCaunt avatar May 01 '25 13:05 EdCaunt

Sorry that the release broke your code!

I think more than kw_only would be required, there would (I think) need to be a default for all the attributes. I believe the change was made based on the thinking that all those attributes are required for the toolchain to function properly anyway (and, particularly, since there weren't previously defaults). @EdCaunt could you describe your use case? (in which, I imagine, you end up not setting all possible attributes?)

cc @alexfikl who made the change in question.

inducer avatar May 01 '25 23:05 inducer

I'm guessing the issue is that the GCCToolchain class gets subclassed here https://github.com/devitocodes/devito/blob/f815f385f820d9f5989e2e2fb7d2758ff2a26ab7/devito/arch/compiler.py#L187-L194 and that heavily breaks with dataclasses and with frozen=True.

We could try reverting the frozen part, but the default arguments would still need to be provided somewhere. From what I can tell, it would be a lot of work to fix this on your end (basically rework the whole Compiler infrastructure). @inducer Maybe we can just add some vaguely sensible defaults to all the attributes?

alexfikl avatar May 02 '25 07:05 alexfikl

@EdCaunt Could you provide more info on your use case, especially around why not all attributes are needed?

inducer avatar May 07 '25 14:05 inducer