-
Notifications
You must be signed in to change notification settings - Fork 19
Use protobuf instead of dot to communicate between parsers and core #13
Conversation
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 asked for a few small changes. Mostly nits
That said, let me understand the context. You have moved entirely away from using jdeps for obtaining the class dependency graph? That was why we previously used the dot/graphviz format for representing the class graph.
@@ -108,6 +111,7 @@ private void run(String[] args) throws Exception { | |||
cmdLineParser.parseArgument(args); | |||
|
|||
List<String> dotFile = readDotFileFromStdIn(); |
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.
Do you need this (or line 223) anymore?
If so, in what context will both exist?
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.
Sorry, didn't do a good job cleaning up. Removed.
// In the Java case, we have (u, v) if 'u' mentions [1] 'v'. | ||
// [1] - By mention, we mean either imports or references in code, either as a fully qualified | ||
// name, or an implied same-package name. | ||
map<string, Strings> class_to_class = 1; |
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.
can you rename to class_dependencies
.
getClassDependencyMap()
is much clearer than getClassToClassMap()
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.
"dependencies" can mean several things, I think that "class to class" describes it more precisely.
There are soon going to be additional fields (class_to_file, file_to_rule_kind) which will be consistent with the new name.
What do you think?
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.
There are soon going to be additional fields (class_to_file, file_to_rule_kind) which will be consistent with the new name.
This is the portion that is unclear to me, the future direction. Can you expand on when and how these additional fields would be used? How would you obtain these file_to_rule dependencies?
That aside, from my limited vantage point, these are all dependency graphs. The nodes, (i.e. type of dependency) may differ but at their core, they are dependencies. For example, an edge between a file and another rule indicates a dependency between that file and that rule. Consequently, I am curious why not define something like
message ParserOutput {
map<Deps, Deps> dependency_map = 1;
}
message Dep {
string name;
string type;
}
message Deps {
repeated Dep deps;
}
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.
Note, the main takeaway you should get out of my message is not the specific proto I defined. It's that I don't understand what the direction is.
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 concede on this
map<string, Strings> class_to_class = 1; | ||
} | ||
|
||
message Strings { |
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.
like above, can you make this some variant of dependency
like deps
or what have you?
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'm going to reuse this for other graphs (class_to_file, file_to_rule_kind) so "dependency" doesn't fit.
OTOH defining extra messages just for the name sounds wasteful.
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 am fine accepting class_to_class
, but Strings
(and s
) is... sketchy. It's overly broad.
OTOH defining extra messages just for the name sounds wasteful.
Understandable complaint. However, using overly broad or single letter variable names in Java is inappropriate and non-idiomatic. Perhaps it's not an issue when looking at the proto in isolation, but it's hard to argue the below is proper java code
private static HashMap<String, Bfg.Strings> writeGraphToProtoMap;
// you defined your own special Strings class. Why???
...
adj.addAllS(graph.adjacentNodes(u));
// what is S???
I'm going to reuse this for other graphs (class_to_file, file_to_rule_kind)
there has to be some unifying quality about each of those, beyond Strings
. Perhaps node.
As a side note, if we move to scala, i will be l
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.
How about repeated string elements
instead of repeated string s
?
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.
That works
java_proto_library( | ||
name = "bfg_java_proto" | ||
, deps = [":bfg_proto" ], | ||
) |
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.
nit: new line
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.
done
@@ -108,6 +111,7 @@ private void run(String[] args) throws Exception { | |||
cmdLineParser.parseArgument(args); | |||
|
|||
List<String> dotFile = readDotFileFromStdIn(); | |||
ParserOutput parserOutput = ParserOutput.parseFrom(System.in); | |||
if (dotFile.isEmpty()) { |
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.
remove?
what arguments are you testing this against?
From what I understand of the change, there will be no more dotfiles, and also no more jdeps. Consequently, this should result in error.
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.
Done.
@@ -1,18 +1,6 @@ | |||
licenses(["notice"]) # Apache 2.0 | |||
|
|||
java_test( | |||
name = "DotFileParserTest", |
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.
is it customary to test protobuffs?
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.
do you mean if's customary to test the proto parser?
the parser has tons of tests in its own codebase, so no.
That's one big reason to use other's well tested code, you don't need to test it yourself :)
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.
do you mean if's customary to test the proto parser?
Somewhat. What I was more concerned about was how we were unable to detect that dotfile.isEmpty()
was not removed. Does bfg currently have e2e tests?
That's one big reason to use other's well tested code, you don't need to test it yourself :)
SGTM
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.
Agreed, there are no e2e tests which would've caught it.
My approach is to hold off e2e tests as long as possible because they're really annoying to set up, at least inside Google. I think it's still fine to hold off, because there's little complexity in Bfg.java.
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.
My approach is to hold off e2e tests as long as possible because they're really annoying to set up, at least inside Google. I think it's still fine to hold off, because there's little complexity in Bfg.java.
SGTM
that is, between the language-specific parsers and the language-agnostic core.
retest this please |
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.
@cgrushko you're free to merge. :)
There was one nit that annoyed me. Can you make sure to change that.
map<string, Strings> class_to_class = 1; | ||
} | ||
|
||
message Strings { |
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 am fine accepting class_to_class
, but Strings
(and s
) is... sketchy. It's overly broad.
OTOH defining extra messages just for the name sounds wasteful.
Understandable complaint. However, using overly broad or single letter variable names in Java is inappropriate and non-idiomatic. Perhaps it's not an issue when looking at the proto in isolation, but it's hard to argue the below is proper java code
private static HashMap<String, Bfg.Strings> writeGraphToProtoMap;
// you defined your own special Strings class. Why???
...
adj.addAllS(graph.adjacentNodes(u));
// what is S???
I'm going to reuse this for other graphs (class_to_file, file_to_rule_kind)
there has to be some unifying quality about each of those, beyond Strings
. Perhaps node.
As a side note, if we move to scala, i will be l
// In the Java case, we have (u, v) if 'u' mentions [1] 'v'. | ||
// [1] - By mention, we mean either imports or references in code, either as a fully qualified | ||
// name, or an implied same-package name. | ||
map<string, Strings> class_to_class = 1; |
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 concede on this
test this please |
… is resolved" This reverts commit 8ff7abe.
…azelbuild#13) * Use protobuf instead of dot to communicate between parsers and core that is, between the language-specific parsers and the language-agnostic core. * Move .bazelrc to tools/ so ci.bazel.build will not override it * Remove our .bazelrc until bazelbuild/continuous-integration#141 is resolved * Revert "Remove our .bazelrc until bazelbuild/continuous-integration#141 is resolved" This reverts commit 8ff7abe. * Rename tools/.bazelrc to tools/bazel.rc * Rename proto field to 'elements'
Re commit message - I think it would be better to only use the initial commit message (e.g., without 'Revert "Remove out"...'). |
SGTM |
that is, between the language-specific parsers and the language-agnostic core.