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

sis_hash_helper on enum.Enums is Python version dependent #188

Closed
albertz opened this issue May 7, 2024 · 2 comments · Fixed by #189
Closed

sis_hash_helper on enum.Enums is Python version dependent #188

albertz opened this issue May 7, 2024 · 2 comments · Fixed by #189
Assignees

Comments

@albertz
Copy link
Member

albertz commented May 7, 2024

The use of enum.Enum currently results in different Sisyphus hashes depending on the Python version…

E.g. from i6_core, we have:

class MergeStrategy(enum.Enum):
    SUBCORPORA = 0
    FLAT = 1
    CONCATENATE = 2

sis_hash_helper(MergeStrategy.FLAT) gives:

  • Python 3.11: b"(MergeStrategy, (dict, (tuple, (str, '__objclass__'), (EnumType, (tuple, (str, 'i6_core.corpus.transform'), (str, 'MergeStrategy')))), (tuple, (str, '_name_'), (str, 'FLAT')), (tuple, (str, '_sort_order_'), (int, 1)), (tuple, (str, '_value_'), (int, 1))))"
  • Python 3.10: b"(MergeStrategy, (dict, (tuple, (str, '__objclass__'), (EnumMeta, (tuple, (str, 'i6_core.corpus.transform'), (str, 'MergeStrategy')))), (tuple, (str, '_name_'), (str, 'FLAT')), (tuple, (str, '_value_'), (int, 1))))"

I think most people still use Python <=3.10? Am i the only one using a more recent Python? I would suggest a fix on Sisyphus side to always keep the old python <=3.10 hash of enum, even on newer Python versions. That will require a special check for enum, but I think that’s ok.

@michelwi
Copy link
Contributor

michelwi commented May 7, 2024

Am i the only one using a more recent Python?

It seems so.

suggest a fix on Sisyphus side to always keep the old python <=3.10 hash of enum

yes, agreed.

@critias
Copy link
Contributor

critias commented May 7, 2024

I didn't expect the enum state to blow up like that. There would also be the option to encode it into something shorter, e.g. b'(Enum, i6_core.corpus.transform. MergeStrategy.Flat)', but that would now change the hash. Keeping the old behavior looks reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants