Skip to content

Conversation

@ax3l
Copy link
Member

@ax3l ax3l commented Oct 27, 2025

@ax3l ax3l added the bug Something isn't working label Oct 27, 2025
@ax3l ax3l mentioned this pull request Oct 27, 2025
6 tasks
@ax3l ax3l added the element kinds beamline elements & segments/lines label Oct 27, 2025
@ax3l ax3l changed the title Topic unionele Implement UnionEle.elements Oct 27, 2025
@EZoni
Copy link
Member

EZoni commented Oct 28, 2025

@ax3l

Just merged #33, so this one can be rebased.

@ax3l ax3l requested a review from EZoni October 28, 2025 20:53
Deduplicate logic with `BeamLine` for allowed types
and (de)serialization.


class BaseElement(BaseModel):
class BaseElement(BaseModel, validate_assignment=True):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sufficient to define validate_assignment=True once -- in our BaseElement.

@EZoni
Copy link
Member

EZoni commented Oct 28, 2025

What is the meaning of the word "mixin"? I searched it in the PALS documentation and the search didn't return any result. I understand that it may be the squash of "mix in", but I wonder if there's a better word that does match the PALS documentation.


@model_validator(mode="before")
@classmethod
def unpack_yaml_structure(cls, data):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this model validator is format-agnostic maybe we should not call it unpack_yaml_structure.

Copy link
Member Author

@ax3l ax3l Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could rename to json, which is the default model for pedantic, since this overwrites/enhances a pedantic internal unpacking routine.

A more generic name might be obfuscating/hard to grasp.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this - if the data that the function receives as input is format-agnostic, I don't see why the function should be called unpack_yaml_structure or unpack_json_structure.

I think a function name that is format-agnostic would be fine and less misleading, e.g., unpack_data, unpack_structure, unpack_union_data, unpack_union_structure, unpack_data_structure, etc.

This said, I don't have veto power, so I will approve the changes.

@EZoni
Copy link
Member

EZoni commented Oct 28, 2025

The changes to the tests look fine to me, though I don't know if they cover everything that this PR added.

@ax3l
Copy link
Member Author

ax3l commented Oct 29, 2025

What is the meaning of the word "mixin"?

https://en.wikipedia.org/wiki/Mixin

We use the same name in ImpactX for mixin classes. They can be base classes, but don't have to.

They are a standard programming technique for implementation details, not PALS objects.

@EZoni
Copy link
Member

EZoni commented Oct 29, 2025

In my opinion, it would makes sense to finalize this after the union element has been clarified on the PALS end. See originally pals-project/pals#86, now moved to pals-project/pals#100. If you believe otherwise, of course feel free to merge.

@ax3l
Copy link
Member Author

ax3l commented Oct 29, 2025

The primary thing that will change is the class name, thus I would go ahead and merge the logic already. We have versions on PALS-Python to iterate and break things.

@EZoni
Copy link
Member

EZoni commented Oct 29, 2025

Okay. Based on this morning's discussion it seemed to me that there was more debate about what a union element is than just the class name, but probably I misread the room and/or misinterpreted the comments.

Good to explain this pydantic term a little
@ax3l
Copy link
Member Author

ax3l commented Oct 29, 2025

Yes, I think for now we should expect that there will be some kind of element like Union/Girder, that behaves so far 99% like a Beamline with minor differences: pals-project/pals#100

@EZoni EZoni merged commit a4d9f23 into pals-project:main Oct 29, 2025
5 checks passed
@ax3l ax3l deleted the topic-unionele branch October 29, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working element kinds beamline elements & segments/lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Union Element

2 participants