Skip to content

Clear __init__#39

Closed
vmarkovtsev wants to merge 1 commit intosrc-d:masterfrom
vmarkovtsev:master
Closed

Clear __init__#39
vmarkovtsev wants to merge 1 commit intosrc-d:masterfrom
vmarkovtsev:master

Conversation

@vmarkovtsev
Copy link
Copy Markdown
Collaborator

GRPC is such a huge pile of crap that we should not touch it by
doing a mere package import.

Signed-off-by: Vadim Markovtsev vadim@sourced.tech

GRPC is such a huge pile of crap that we should not touch it by
doing a mere package import.

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
@smacker
Copy link
Copy Markdown
Contributor

smacker commented Nov 29, 2018

what is the problem with it?

I did re-export mostly because of add_AnalyzerServicer_to_server which many linters will complain about.

@vmarkovtsev
Copy link
Copy Markdown
Collaborator Author

We use flake8 and pylint and none of those are crazy enough to complain about third-party naming schemes. If you speak about style check in lookout-sdk project, then # noqa is your friend.
add_AnalyzerServicer_to_server is automatically generated and hence it should not be touched in any way.

But all of those is nothing compared to the problems with grpc and multiprocessing which we had last year. As soon as you make import grpc, you taint your CPython interpreter forever and you can no longer use multiprocessing with subsequent grpc. It was so painful last year that I will remember those deferred imports and poor, really poor grpc threading design (I read the code!!!) for the rest of my life.

If you do import lookout.sdk otherwise, you get poisoned with super weird consequences. The version feature which I am asking in #38 does not involve grpc, and doing import lookout.sdk.version or similar should not import it.

@smacker
Copy link
Copy Markdown
Contributor

smacker commented Nov 29, 2018

thank you for the explanation! It definitely makes sense.

Let me use this PR as an opportunity to raise another question. Currently in python analyzers imports look like this:

from lookout.sdk import service_analyzer_pb2_grpc
from lookout.sdk import service_analyzer_pb2
from lookout.sdk import service_data_pb2_grpc
from lookout.sdk import service_data_pb2
from lookout.sdk.grpc import to_grpc_address, create_channel

and I need to remember which package contains which functions/classes. For example DataStub class defined in service_data_pb2_grpc but ChangesRequest in service_data_pb2.
That annoys me a lot. In Go there is only one package pb with everything.

What do you think about providing similar experience for python?

from lookout.sdk import pb

@vmarkovtsev
Copy link
Copy Markdown
Collaborator Author

vmarkovtsev commented Nov 29, 2018

To be honest, all the team use PyCharm and Alt-Enter, so we never had such problems... And it's only me who deals with GRPC directly, the rest have little idea how everything works at the low level.

But yeah, it definitely looks nicer as long as there are no name collisions.

@smacker
Copy link
Copy Markdown
Contributor

smacker commented Dec 5, 2018

A similar change is merged in the master already.
But thank you for letting us know about the problem!

@smacker smacker closed this Dec 5, 2018
@vmarkovtsev
Copy link
Copy Markdown
Collaborator Author

Encountering problems since 2016!

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 this pull request may close these issues.

2 participants