Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Conversation

@BenediktBurger
Copy link
Contributor

proper implementation of ThreadCommand serialization instead of the self written part in PyMoDAQ/PyMoDAQ#405

This allows sending ThreadCommands via LECO, so should make status changes easier to transmit.

I'm not sure, whether I adjusted the SerializableTypes correctly.

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.06%. Comparing base (12c7f4e) to head (0ec27e4).
Report is 4 commits behind head on 1.0.x_dev.

Additional details and impacted files
@@              Coverage Diff              @@
##           1.0.x_dev      #51      +/-   ##
=============================================
+ Coverage      73.43%   74.06%   +0.63%     
=============================================
  Files             18       18              
  Lines           1611     1635      +24     
=============================================
+ Hits            1183     1211      +28     
+ Misses           428      424       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BenediktBurger BenediktBurger force-pushed the serialize-thread-command branch from 9711553 to 31f8003 Compare July 16, 2025 12:43

# List of all objects serializable via the serializer
SERIALIZABLE = Union[bytes, str, int, float, complex, list, NDArray, SerializableBase]
SERIALIZABLE = Union[None, bytes, str, int, float, complex, list, NDArray, SerializableBase]
Copy link
Contributor

Choose a reason for hiding this comment

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

As None as been defined as a class inheriting from SerializerBase, I'm not sure it's necessary to add it here. Indeed for ThreadCommand or other class elsewhere, thay are not added in there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, None is still the built-in and not a subclass of SerializableBase.

There is a class (NoneSerializaDeserialize), which is based on that other class, but is just a container for the serialization.

Similar to the other built-in types bytes, str, ...

Copy link
Contributor

Choose a reason for hiding this comment

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

well yes but all these builtins are also encapsulated so is it necessary to add them namely in the SERIALIZABLE variable? You introduced this for pylecco I think, could you recall me what is it for exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SERIALIZABLE is there as a type to use for type hints:

def whatever(obj: SERIALIZABLE) -> bytes:
   ...

here, a type checker (like mypy, pylance...) will complain if obj is not any of the classes in SERIALIZABLE. The builtins are not a subclass of SerializableBase. Therefore, they must be explicitly included in SERIALIZABLE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is mainly used in this pymodaq_utils repo for typing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this typing to two more methods (feel free to revert):

Now get_apply_serializer(not_serializable_object) will complain in a type checker, that not_serializable_object is neither one of the builtins nor a subclass of the SerializableBase (if it is so).
The previous Any won't complain at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok


class SerializableTypes(Enum):
"""Type names of serializable types"""
NONE = "NoneType"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't remember either how this is needed... but from what I see other types defined elsewhere as dwa, dte or parameterWithPath are defined in here. But then when commenting this object: al tests pass... I'm not sure what we should do about it...

Copy link
Contributor

Choose a reason for hiding this comment

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

we should comment it in here, check the director/actor communication is still fine...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it was used earlier, before the type() value was used?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I think so too. So comment it lefting a comment saying this just in case...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


# List of all objects serializable via the serializer
SERIALIZABLE = Union[bytes, str, int, float, complex, list, NDArray, SerializableBase]
SERIALIZABLE = Union[None, bytes, str, int, float, complex, list, NDArray, SerializableBase]
Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@seb5g seb5g merged commit 17b617b into PyMoDAQ:1.0.x_dev Jul 18, 2025
11 of 12 checks passed
@BenediktBurger BenediktBurger deleted the serialize-thread-command branch July 18, 2025 08:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants