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

Cannot pickle types such as metrics #318

Closed
hunterhector opened this issue Sep 11, 2020 · 0 comments · Fixed by #319
Closed

Cannot pickle types such as metrics #318

hunterhector opened this issue Sep 11, 2020 · 0 comments · Fixed by #319
Assignees
Labels
bug Something isn't working topic: executor Issue about the executor and related utilities

Comments

@hunterhector
Copy link
Member

hunterhector commented Sep 11, 2020

Description

Users may encounter the following error when trying to pickle the objects with generic types, such as Texar metrics (https://github.com/asyml/texar-pytorch/blob/master/texar/torch/evals/metrics.py), as shown in the following stack trace:

image

This is a known bug in Python 3.6 when pickling the genric types python/typing#511

Workaround

The easiest way to get around this is to upgrade to 3.7, which fixes this problem here python/cpython#6216

Action needed.

However, we may consider providing workarounds in Texar. It is also suggested to add unit tests on serialization for affected classes including the metrics class.

@hunterhector hunterhector added bug Something isn't working topic: executor Issue about the executor and related utilities labels Sep 11, 2020
huzecong added a commit to huzecong/texar-pytorch that referenced this issue Sep 11, 2020
Worked around this limitation by using a dummy `Generic` in Python 3.6
and below.
@huzecong huzecong self-assigned this Sep 12, 2020
hunterhector pushed a commit that referenced this issue Sep 12, 2020
* Change executor test

Pickling certain metrics while specifying input type as generic type
parameter would result in a failure in Python 3.6. Previous tests didn't
cover this case.

* Fix #318: cannot pickle metrics in Python 3.6

Worked around this limitation by using a dummy `Generic` in Python 3.6
and below.

* Fix stupid linting issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic: executor Issue about the executor and related utilities
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants