Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this as I would like to keep the following usage
gives the same error
No module named 'google.protobuf'
as before
24599
, whenprotobuf
is not in the env.It turns out that, if we just ignore this
else
block, the aboveimport
statement (whenprotobuf
is missing) will find the corresponding file, and import it directly, and we wil get the expected error as before.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, interesting. Just to make sure I've understood, without this
else
statement, we still get the correctNo module named 'google.protobuf'
error still triggers if protobuf isn't in the env?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The
__init__
won't have the namesentencepiece_model_pb2
, but the fileutils/sentencepiece_model_pb2.py
exist. So the import will look at that file and try to import.(I was overthinking, partially I was thinking to have
sentencepiece_model_pb2_old.py
andsentencepiece_model_pb2_new.py
(and need to keep the namesentencepiece_model_pb2
available in the__init__
for backward compatibility)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining 🤗