Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParentOperator serialization in case of custom class #215

Closed
MangaBoba opened this issue Oct 12, 2023 · 3 comments
Closed

ParentOperator serialization in case of custom class #215

MangaBoba opened this issue Oct 12, 2023 · 3 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@MangaBoba
Copy link
Contributor

MangaBoba commented Oct 12, 2023

If as a mutation function provided instance of custom class or partial, GOLEM rises TypeError exception on serialization parent_operator field of individual.

  File "f:\GEFEST\.venv\lib\site-packages\golem\serializers\serializer.py", line 224, in default
    return JSONEncoder.default(self, obj)
  File "C:\Users\user\.pyenv\pyenv-win\versions\3.9.13\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type CustomMutationWrap is not JSON serializable

GOLEM verison: 0.3.3

@MangaBoba MangaBoba added bug Something isn't working enhancement New feature or request labels Oct 12, 2023
This was referenced Oct 13, 2023
@YamLyubov YamLyubov self-assigned this Oct 20, 2023
@YamLyubov
Copy link
Collaborator

YamLyubov commented Oct 20, 2023

You can use @register_serializable decorator. To set custom coder and decoder methods just implement to_json and from_json methods for your class or default serialisation will be used.

Example from FEDOT.

@maypink
Copy link
Collaborator

maypink commented Oct 23, 2023

@MangaBoba получилось сделать так, как предлложили выше?

@MangaBoba
Copy link
Contributor Author

#215 (comment) solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants