Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
dc8c3239
Commit
dc8c3239
authored
9 years ago
by
Nathaniel Manista
Browse files
Options
Downloads
Patches
Plain Diff
Remove Python alpha code generation
parent
ecda59b6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/compiler/python_generator.cc
+2
-261
2 additions, 261 deletions
src/compiler/python_generator.cc
src/compiler/python_generator.h
+0
-1
0 additions, 1 deletion
src/compiler/python_generator.h
src/compiler/python_plugin.cc
+0
-1
0 additions, 1 deletion
src/compiler/python_plugin.cc
with
2 additions
and
263 deletions
src/compiler/python_generator.cc
+
2
−
261
View file @
dc8c3239
...
...
@@ -148,91 +148,6 @@ class IndentScope {
// END FORMATTING BOILERPLATE //
////////////////////////////////
bool
PrintAlphaServicer
(
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
grpc
::
string
doc
=
"<fill me in later!>"
;
map
<
grpc
::
string
,
grpc
::
string
>
dict
=
ListToDict
({
"Service"
,
service
->
name
(),
"Documentation"
,
doc
,
});
out
->
Print
(
dict
,
"class EarlyAdopter$Service$Servicer(object):
\n
"
);
{
IndentScope
raii_class_indent
(
out
);
out
->
Print
(
dict
,
"
\"\"\"
$Documentation$
\"\"\"\n
"
);
out
->
Print
(
"__metaclass__ = abc.ABCMeta
\n
"
);
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
auto
meth
=
service
->
method
(
i
);
grpc
::
string
arg_name
=
meth
->
client_streaming
()
?
"request_iterator"
:
"request"
;
out
->
Print
(
"@abc.abstractmethod
\n
"
);
out
->
Print
(
"def $Method$(self, $ArgName$, context):
\n
"
,
"Method"
,
meth
->
name
(),
"ArgName"
,
arg_name
);
{
IndentScope
raii_method_indent
(
out
);
out
->
Print
(
"raise NotImplementedError()
\n
"
);
}
}
}
return
true
;
}
bool
PrintAlphaServer
(
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
grpc
::
string
doc
=
"<fill me in later!>"
;
map
<
grpc
::
string
,
grpc
::
string
>
dict
=
ListToDict
({
"Service"
,
service
->
name
(),
"Documentation"
,
doc
,
});
out
->
Print
(
dict
,
"class EarlyAdopter$Service$Server(object):
\n
"
);
{
IndentScope
raii_class_indent
(
out
);
out
->
Print
(
dict
,
"
\"\"\"
$Documentation$
\"\"\"\n
"
);
out
->
Print
(
"__metaclass__ = abc.ABCMeta
\n
"
);
out
->
Print
(
"@abc.abstractmethod
\n
"
);
out
->
Print
(
"def start(self):
\n
"
);
{
IndentScope
raii_method_indent
(
out
);
out
->
Print
(
"raise NotImplementedError()
\n
"
);
}
out
->
Print
(
"@abc.abstractmethod
\n
"
);
out
->
Print
(
"def stop(self):
\n
"
);
{
IndentScope
raii_method_indent
(
out
);
out
->
Print
(
"raise NotImplementedError()
\n
"
);
}
}
return
true
;
}
bool
PrintAlphaStub
(
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
grpc
::
string
doc
=
"<fill me in later!>"
;
map
<
grpc
::
string
,
grpc
::
string
>
dict
=
ListToDict
({
"Service"
,
service
->
name
(),
"Documentation"
,
doc
,
});
out
->
Print
(
dict
,
"class EarlyAdopter$Service$Stub(object):
\n
"
);
{
IndentScope
raii_class_indent
(
out
);
out
->
Print
(
dict
,
"
\"\"\"
$Documentation$
\"\"\"\n
"
);
out
->
Print
(
"__metaclass__ = abc.ABCMeta
\n
"
);
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
const
MethodDescriptor
*
meth
=
service
->
method
(
i
);
grpc
::
string
arg_name
=
meth
->
client_streaming
()
?
"request_iterator"
:
"request"
;
auto
methdict
=
ListToDict
({
"Method"
,
meth
->
name
(),
"ArgName"
,
arg_name
});
out
->
Print
(
"@abc.abstractmethod
\n
"
);
out
->
Print
(
methdict
,
"def $Method$(self, $ArgName$):
\n
"
);
{
IndentScope
raii_method_indent
(
out
);
out
->
Print
(
"raise NotImplementedError()
\n
"
);
}
out
->
Print
(
methdict
,
"$Method$.async = None
\n
"
);
}
}
return
true
;
}
// TODO(protobuf team): Export `ModuleName` from protobuf's
// `src/google/protobuf/compiler/python/python_generator.cc` file.
grpc
::
string
ModuleName
(
const
grpc
::
string
&
filename
)
{
...
...
@@ -268,172 +183,6 @@ bool GetModuleAndMessagePath(const Descriptor* type,
return
true
;
}
bool
PrintAlphaServerFactory
(
const
grpc
::
string
&
package_qualified_service_name
,
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
out
->
Print
(
"def early_adopter_create_$Service$_server(servicer, port, "
"private_key=None, certificate_chain=None):
\n
"
,
"Service"
,
service
->
name
());
{
IndentScope
raii_create_server_indent
(
out
);
map
<
grpc
::
string
,
grpc
::
string
>
method_description_constructors
;
map
<
grpc
::
string
,
pair
<
grpc
::
string
,
grpc
::
string
>>
input_message_modules_and_classes
;
map
<
grpc
::
string
,
pair
<
grpc
::
string
,
grpc
::
string
>>
output_message_modules_and_classes
;
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
const
MethodDescriptor
*
method
=
service
->
method
(
i
);
const
grpc
::
string
method_description_constructor
=
grpc
::
string
(
method
->
client_streaming
()
?
"stream_"
:
"unary_"
)
+
grpc
::
string
(
method
->
server_streaming
()
?
"stream_"
:
"unary_"
)
+
"service_description"
;
pair
<
grpc
::
string
,
grpc
::
string
>
input_message_module_and_class
;
if
(
!
GetModuleAndMessagePath
(
method
->
input_type
(),
&
input_message_module_and_class
))
{
return
false
;
}
pair
<
grpc
::
string
,
grpc
::
string
>
output_message_module_and_class
;
if
(
!
GetModuleAndMessagePath
(
method
->
output_type
(),
&
output_message_module_and_class
))
{
return
false
;
}
// Import the modules that define the messages used in RPCs.
out
->
Print
(
"import $Module$
\n
"
,
"Module"
,
input_message_module_and_class
.
first
);
out
->
Print
(
"import $Module$
\n
"
,
"Module"
,
output_message_module_and_class
.
first
);
method_description_constructors
.
insert
(
make_pair
(
method
->
name
(),
method_description_constructor
));
input_message_modules_and_classes
.
insert
(
make_pair
(
method
->
name
(),
input_message_module_and_class
));
output_message_modules_and_classes
.
insert
(
make_pair
(
method
->
name
(),
output_message_module_and_class
));
}
out
->
Print
(
"method_service_descriptions = {
\n
"
);
for
(
auto
name_and_description_constructor
=
method_description_constructors
.
begin
();
name_and_description_constructor
!=
method_description_constructors
.
end
();
name_and_description_constructor
++
)
{
IndentScope
raii_descriptions_indent
(
out
);
const
grpc
::
string
method_name
=
name_and_description_constructor
->
first
;
auto
input_message_module_and_class
=
input_message_modules_and_classes
.
find
(
method_name
);
auto
output_message_module_and_class
=
output_message_modules_and_classes
.
find
(
method_name
);
out
->
Print
(
"
\"
$Method$
\"
: alpha_utilities.$Constructor$(
\n
"
,
"Method"
,
method_name
,
"Constructor"
,
name_and_description_constructor
->
second
);
{
IndentScope
raii_description_arguments_indent
(
out
);
out
->
Print
(
"servicer.$Method$,
\n
"
,
"Method"
,
method_name
);
out
->
Print
(
"$InputTypeModule$.$InputTypeClass$.FromString,
\n
"
,
"InputTypeModule"
,
input_message_module_and_class
->
second
.
first
,
"InputTypeClass"
,
input_message_module_and_class
->
second
.
second
);
out
->
Print
(
"$OutputTypeModule$.$OutputTypeClass$.SerializeToString,
\n
"
,
"OutputTypeModule"
,
output_message_module_and_class
->
second
.
first
,
"OutputTypeClass"
,
output_message_module_and_class
->
second
.
second
);
}
out
->
Print
(
"),
\n
"
);
}
out
->
Print
(
"}
\n
"
);
out
->
Print
(
"return early_adopter_implementations.server("
"
\"
$PackageQualifiedServiceName$
\"
,"
" method_service_descriptions, port, private_key=private_key,"
" certificate_chain=certificate_chain)
\n
"
,
"PackageQualifiedServiceName"
,
package_qualified_service_name
);
}
return
true
;
}
bool
PrintAlphaStubFactory
(
const
grpc
::
string
&
package_qualified_service_name
,
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
map
<
grpc
::
string
,
grpc
::
string
>
dict
=
ListToDict
({
"Service"
,
service
->
name
(),
});
out
->
Print
(
dict
,
"def early_adopter_create_$Service$_stub(host, port,"
" metadata_transformer=None,"
" secure=False, root_certificates=None, private_key=None,"
" certificate_chain=None, server_host_override=None):
\n
"
);
{
IndentScope
raii_create_server_indent
(
out
);
map
<
grpc
::
string
,
grpc
::
string
>
method_description_constructors
;
map
<
grpc
::
string
,
pair
<
grpc
::
string
,
grpc
::
string
>>
input_message_modules_and_classes
;
map
<
grpc
::
string
,
pair
<
grpc
::
string
,
grpc
::
string
>>
output_message_modules_and_classes
;
for
(
int
i
=
0
;
i
<
service
->
method_count
();
++
i
)
{
const
MethodDescriptor
*
method
=
service
->
method
(
i
);
const
grpc
::
string
method_description_constructor
=
grpc
::
string
(
method
->
client_streaming
()
?
"stream_"
:
"unary_"
)
+
grpc
::
string
(
method
->
server_streaming
()
?
"stream_"
:
"unary_"
)
+
"invocation_description"
;
pair
<
grpc
::
string
,
grpc
::
string
>
input_message_module_and_class
;
if
(
!
GetModuleAndMessagePath
(
method
->
input_type
(),
&
input_message_module_and_class
))
{
return
false
;
}
pair
<
grpc
::
string
,
grpc
::
string
>
output_message_module_and_class
;
if
(
!
GetModuleAndMessagePath
(
method
->
output_type
(),
&
output_message_module_and_class
))
{
return
false
;
}
// Import the modules that define the messages used in RPCs.
out
->
Print
(
"import $Module$
\n
"
,
"Module"
,
input_message_module_and_class
.
first
);
out
->
Print
(
"import $Module$
\n
"
,
"Module"
,
output_message_module_and_class
.
first
);
method_description_constructors
.
insert
(
make_pair
(
method
->
name
(),
method_description_constructor
));
input_message_modules_and_classes
.
insert
(
make_pair
(
method
->
name
(),
input_message_module_and_class
));
output_message_modules_and_classes
.
insert
(
make_pair
(
method
->
name
(),
output_message_module_and_class
));
}
out
->
Print
(
"method_invocation_descriptions = {
\n
"
);
for
(
auto
name_and_description_constructor
=
method_description_constructors
.
begin
();
name_and_description_constructor
!=
method_description_constructors
.
end
();
name_and_description_constructor
++
)
{
IndentScope
raii_descriptions_indent
(
out
);
const
grpc
::
string
method_name
=
name_and_description_constructor
->
first
;
auto
input_message_module_and_class
=
input_message_modules_and_classes
.
find
(
method_name
);
auto
output_message_module_and_class
=
output_message_modules_and_classes
.
find
(
method_name
);
out
->
Print
(
"
\"
$Method$
\"
: alpha_utilities.$Constructor$(
\n
"
,
"Method"
,
method_name
,
"Constructor"
,
name_and_description_constructor
->
second
);
{
IndentScope
raii_description_arguments_indent
(
out
);
out
->
Print
(
"$InputTypeModule$.$InputTypeClass$.SerializeToString,
\n
"
,
"InputTypeModule"
,
input_message_module_and_class
->
second
.
first
,
"InputTypeClass"
,
input_message_module_and_class
->
second
.
second
);
out
->
Print
(
"$OutputTypeModule$.$OutputTypeClass$.FromString,
\n
"
,
"OutputTypeModule"
,
output_message_module_and_class
->
second
.
first
,
"OutputTypeClass"
,
output_message_module_and_class
->
second
.
second
);
}
out
->
Print
(
"),
\n
"
);
}
out
->
Print
(
"}
\n
"
);
out
->
Print
(
"return early_adopter_implementations.stub("
"
\"
$PackageQualifiedServiceName$
\"
,"
" method_invocation_descriptions, host, port,"
" metadata_transformer=metadata_transformer, secure=secure,"
" root_certificates=root_certificates, private_key=private_key,"
" certificate_chain=certificate_chain,"
" server_host_override=server_host_override)
\n
"
,
"PackageQualifiedServiceName"
,
package_qualified_service_name
);
}
return
true
;
}
bool
PrintBetaServicer
(
const
ServiceDescriptor
*
service
,
Printer
*
out
)
{
grpc
::
string
doc
=
"<fill me in later!>"
;
...
...
@@ -703,9 +452,6 @@ bool PrintPreamble(const FileDescriptor* file,
out
->
Print
(
"import abc
\n
"
);
out
->
Print
(
"from $Package$ import implementations as beta_implementations
\n
"
,
"Package"
,
config
.
beta_package_root
);
out
->
Print
(
"from $Package$ import implementations as early_adopter_implementations
\n
"
,
"Package"
,
config
.
early_adopter_package_root
);
out
->
Print
(
"from grpc.framework.alpha import utilities as alpha_utilities
\n
"
);
out
->
Print
(
"from grpc.framework.common import cardinality
\n
"
);
out
->
Print
(
"from grpc.framework.interfaces.face import utilities as face_utilities
\n
"
);
return
true
;
...
...
@@ -714,7 +460,7 @@ bool PrintPreamble(const FileDescriptor* file,
}
// namespace
pair
<
bool
,
grpc
::
string
>
GetServices
(
const
FileDescriptor
*
file
,
const
GeneratorConfiguration
&
config
)
{
const
GeneratorConfiguration
&
config
)
{
grpc
::
string
output
;
{
// Scope the output stream so it closes and finalizes output to the string.
...
...
@@ -730,12 +476,7 @@ pair<bool, grpc::string> GetServices(const FileDescriptor* file,
for
(
int
i
=
0
;
i
<
file
->
service_count
();
++
i
)
{
auto
service
=
file
->
service
(
i
);
auto
package_qualified_service_name
=
package
+
service
->
name
();
if
(
!
(
PrintAlphaServicer
(
service
,
&
out
)
&&
PrintAlphaServer
(
service
,
&
out
)
&&
PrintAlphaStub
(
service
,
&
out
)
&&
PrintAlphaServerFactory
(
package_qualified_service_name
,
service
,
&
out
)
&&
PrintAlphaStubFactory
(
package_qualified_service_name
,
service
,
&
out
)
&&
PrintBetaServicer
(
service
,
&
out
)
&&
if
(
!
(
PrintBetaServicer
(
service
,
&
out
)
&&
PrintBetaStub
(
service
,
&
out
)
&&
PrintBetaServerFactory
(
package_qualified_service_name
,
service
,
&
out
)
&&
PrintBetaStubFactory
(
package_qualified_service_name
,
service
,
&
out
)))
{
...
...
This diff is collapsed.
Click to expand it.
src/compiler/python_generator.h
+
0
−
1
View file @
dc8c3239
...
...
@@ -43,7 +43,6 @@ namespace grpc_python_generator {
// Data pertaining to configuration of the generator with respect to anything
// that may be used internally at Google.
struct
GeneratorConfiguration
{
grpc
::
string
early_adopter_package_root
;
grpc
::
string
beta_package_root
;
};
...
...
This diff is collapsed.
Click to expand it.
src/compiler/python_plugin.cc
+
0
−
1
View file @
dc8c3239
...
...
@@ -38,7 +38,6 @@
int
main
(
int
argc
,
char
*
argv
[])
{
grpc_python_generator
::
GeneratorConfiguration
config
;
config
.
early_adopter_package_root
=
"grpc.early_adopter"
;
config
.
beta_package_root
=
"grpc.beta"
;
grpc_python_generator
::
PythonGrpcGenerator
generator
(
config
);
return
grpc
::
protobuf
::
compiler
::
PluginMain
(
argc
,
argv
,
&
generator
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment