-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bonobo for Ekaterina Draft Dirty #128
base: master
Are you sure you want to change the base?
Conversation
@lyriccoder can you please remove unused (commented) code and make the PR "clean"? |
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 commit just the high-level graph? and remove commented code?
I am doing it right now |
@KatGarmash done, we can discuss it |
return {'input_dir': str(input_dir), 'output_dir': str(output_dir)} | ||
|
||
|
||
def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]): |
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 u come up with a more informative name of the method please?
return {'input_dir': str(input_dir), 'output_dir': str(output_dir)} | ||
|
||
|
||
def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]): |
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.
come up with a custom type for the contents of the em_item dictionary? it's hard to interpret otw
return {'input_dir': str(input_dir), 'output_dir': str(output_dir)} | ||
|
||
|
||
def pass_params_to_next_node(dirs_dict, em_item: Dict[Tuple, Tuple]): |
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.
dirs_dict type?
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.
return type?
from bonobo.config import Exclusive | ||
|
||
|
||
def aggregate(dirs, dct): |
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 u come up with a more informative name of the method, and also type-annotate it?
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.
what does this methid do?
@@ -0,0 +1,128 @@ | |||
digraph { |
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.
delete this file?
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 we keep it? If we loose it, Egor will be disappointed. Managers need pictures
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 dont think he meant such a graph
ASTNodeType.METHOD_INVOCATION): | ||
extracted_m_decl = method_declarations.get(method_invoked.member, []) | ||
if len(extracted_m_decl) == 1: | ||
t = tuple([input_filename, class_declaration.name, method_invoked.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.
I'd come up with a custom class to store the data in the keys and the values
directory.mkdir(parents=True) | ||
|
||
|
||
def preprocess(file: str): |
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.
return type?
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.
each node returns a dict
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.
so please specify that, including the contents of the dict
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.
it's ugly, I've done this. 'Cause it can have any value -> Dict[str, Any]
doesn't tell you smth important
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 s why i asked to come up with custom types
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.
see inline comments
|
||
maybe_if = parent.parent | ||
is_not_method_inv_single_statement_in_if = True | ||
if maybe_if.node_type == ASTNodeType.IF_STATEMENT: |
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.
if blabla
inv()
if total_return_statements > 0: | ||
is_not_several_returns = False | ||
|
||
has_not_throw = len([ |
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.
where throw is last element
func() {
if () {
}
throw Exception();
}
func() {
if () {
throw Exception();
}
}
has_not_throw = len([ | ||
x for x in extracted_m_decl.body | ||
if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1 | ||
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE) |
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.
???
x for x in extracted_m_decl.body | ||
if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1 | ||
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE) | ||
is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children |
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.
chaijn().func()
if x.node_type == ASTNodeType.THROW_STATEMENT]) < 1 | ||
is_not_parent_member_ref = not (method_invoked.parent.node_type == ASTNodeType.MEMBER_REFERENCE) | ||
is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children | ||
chains_after = [x for x in method_invoked.children if x.node_type == ASTNodeType.METHOD_INVOCATION] |
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.
func().chain()
is_not_chain_before = not (parent.node_type == ASTNodeType.METHOD_INVOCATION) and no_children | ||
chains_after = [x for x in method_invoked.children if x.node_type == ASTNodeType.METHOD_INVOCATION] | ||
is_not_chain_after = not chains_after | ||
is_not_inside_if = not (parent.node_type == ASTNodeType.IF_STATEMENT) |
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.
probably special case
is_not_ternary = not (parent.node_type == ASTNodeType.TERNARY_EXPRESSION) | ||
# if a parameter is any expression, we ignore it, | ||
# since it is difficult to extract with AST | ||
is_actual_parameter_simple = all([hasattr(x, 'member') for x in method_invoked.arguments]) |
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 s no expression among parameters
# if a parameter is any expression, we ignore it, | ||
# since it is difficult to extract with AST | ||
is_actual_parameter_simple = all([hasattr(x, 'member') for x in method_invoked.arguments]) | ||
is_not_actual_param_cast = True |
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.
whether some param has a type cast
if len(found_casts) > 0: | ||
is_not_actual_param_cast = False | ||
|
||
is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR) |
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.
new Constr(method())
is_not_actual_param_cast = False | ||
|
||
is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR) | ||
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST) |
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.
a = (int) func()
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.
func((a)a)
|
||
is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR) | ||
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST) | ||
is_not_array_creator = not (parent.node_type == ASTNodeType.ARRAY_CREATOR) |
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.
new int [func()]
is_not_class_creator = not (parent.node_type == ASTNodeType.CLASS_CREATOR) | ||
is_not_cast_of_return_type = not (parent.node_type == ASTNodeType.CAST) | ||
is_not_array_creator = not (parent.node_type == ASTNodeType.ARRAY_CREATOR) | ||
is_not_lambda = not (parent.node_type == ASTNodeType.LAMBDA_EXPRESSION) |
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.
inside lambda expression
is_not_lambda = not (parent.node_type == ASTNodeType.LAMBDA_EXPRESSION) | ||
is_not_at_the_same_line_as_prohibited_stats = check_nesting_statements(method_invoked) | ||
|
||
are_functional_arguments_eq = False |
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.
names of passed arguments equal to names of parameters in the definition
Bonobo for Ekaterina Draft Dirty