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

Save language restoration #154

Merged
merged 14 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pytoda/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = 'pytoda'
__version__ = '1.0.1'
__version__ = '1.0.2'
13 changes: 11 additions & 2 deletions pytoda/proteins/protein_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,17 @@ def load(filepath: str) -> 'ProteinLanguage':
Returns:
ProteinLanguage: the loaded Protein language object.
"""
with open(filepath, 'rb') as f:
protein_language = dill.load(f)
try:
with open(filepath, 'rb') as f:
protein_language = dill.load(f)
except TypeError:
# Necessary to load python3.7 pickled objects with >=3.8
# For details see: https://github.com/uqfoundation/dill/pull/406
storage = dill._dill._reverse_typemap['CodeType']
dill._dill._reverse_typemap['CodeType'] = dill._dill._create_code
with open(filepath, 'rb') as f:
protein_language = dill.load(f)
dill._dill._reverse_typemap['CodeType'] = storage
return protein_language

@staticmethod
Expand Down
13 changes: 11 additions & 2 deletions pytoda/smiles/smiles_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,17 @@ def load(filepath: str) -> 'SMILESLanguage':
warnings.warn(
"Loading languages will use a text files in the future", FutureWarning
)
with open(filepath, 'rb') as f:
smiles_language = dill.load(f)
try:
with open(filepath, 'rb') as f:
smiles_language = dill.load(f)
except TypeError:
# Necessary to load python3.7 pickled objects with >=3.8:
# For details see: https://github.com/uqfoundation/dill/pull/406
storage = dill._dill._reverse_typemap['CodeType']
dill._dill._reverse_typemap['CodeType'] = dill._dill._create_code
with open(filepath, 'rb') as f:
smiles_language = dill.load(f)
dill._dill._reverse_typemap['CodeType'] = storage
return smiles_language

@staticmethod
Expand Down