repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_list
def _safe_match_list(inner_type, argument_value): """Represent the list of "inner_type" objects in MATCH form.""" stripped_type = strip_non_null_from_type(inner_type) if isinstance(stripped_type, GraphQLList): raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, ' ...
python
def _safe_match_list(inner_type, argument_value): """Represent the list of "inner_type" objects in MATCH form.""" stripped_type = strip_non_null_from_type(inner_type) if isinstance(stripped_type, GraphQLList): raise GraphQLInvalidArgumentError(u'MATCH does not currently support nested lists, ' ...
[ "def", "_safe_match_list", "(", "inner_type", ",", "argument_value", ")", ":", "stripped_type", "=", "strip_non_null_from_type", "(", "inner_type", ")", "if", "isinstance", "(", "stripped_type", ",", "GraphQLList", ")", ":", "raise", "GraphQLInvalidArgumentError", "("...
Represent the list of "inner_type" objects in MATCH form.
[ "Represent", "the", "list", "of", "inner_type", "objects", "in", "MATCH", "form", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L59-L75
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
insert_arguments_into_match_query
def insert_arguments_into_match_query(compilation_result, arguments): """Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for e...
python
def insert_arguments_into_match_query(compilation_result, arguments): """Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for e...
[ "def", "insert_arguments_into_match_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "MATCH_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", "com...
Insert the arguments into the compiled MATCH query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for every parameter the query expects. Returns: string, a MATCH query...
[ "Insert", "the", "arguments", "into", "the", "compiled", "MATCH", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L120-L142
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/metadata.py
SqlMetadata.get_table
def get_table(self, schema_type): """Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.""" table_name = schema_type.lower() if not self.has_table(table_name): raise exceptions.GraphQLCompilationError( 'No Table found in SQLAlchemy metadata for...
python
def get_table(self, schema_type): """Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.""" table_name = schema_type.lower() if not self.has_table(table_name): raise exceptions.GraphQLCompilationError( 'No Table found in SQLAlchemy metadata for...
[ "def", "get_table", "(", "self", ",", "schema_type", ")", ":", "table_name", "=", "schema_type", ".", "lower", "(", ")", "if", "not", "self", ".", "has_table", "(", "table_name", ")", ":", "raise", "exceptions", ".", "GraphQLCompilationError", "(", "'No Tabl...
Retrieve a SQLAlchemy table based on the supplied GraphQL schema type name.
[ "Retrieve", "a", "SQLAlchemy", "table", "based", "on", "the", "supplied", "GraphQL", "schema", "type", "name", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/metadata.py#L27-L34
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_per_location_tuple_to_step
def _per_location_tuple_to_step(ir_tuple): """Construct a MatchStep from a tuple of its constituent blocks.""" root_block = ir_tuple[0] if not isinstance(root_block, root_block_types): raise AssertionError(u'Unexpected root block type for MatchStep: ' u'{} {}'.format(roo...
python
def _per_location_tuple_to_step(ir_tuple): """Construct a MatchStep from a tuple of its constituent blocks.""" root_block = ir_tuple[0] if not isinstance(root_block, root_block_types): raise AssertionError(u'Unexpected root block type for MatchStep: ' u'{} {}'.format(roo...
[ "def", "_per_location_tuple_to_step", "(", "ir_tuple", ")", ":", "root_block", "=", "ir_tuple", "[", "0", "]", "if", "not", "isinstance", "(", "root_block", ",", "root_block_types", ")", ":", "raise", "AssertionError", "(", "u'Unexpected root block type for MatchStep:...
Construct a MatchStep from a tuple of its constituent blocks.
[ "Construct", "a", "MatchStep", "from", "a", "tuple", "of", "its", "constituent", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L39-L85
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_split_ir_into_match_steps
def _split_ir_into_match_steps(pruned_ir_blocks): """Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that ...
python
def _split_ir_into_match_steps(pruned_ir_blocks): """Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that ...
[ "def", "_split_ir_into_match_steps", "(", "pruned_ir_blocks", ")", ":", "output", "=", "[", "]", "current_tuple", "=", "None", "for", "block", "in", "pruned_ir_blocks", ":", "if", "isinstance", "(", "block", ",", "OutputSource", ")", ":", "continue", "elif", "...
Split a list of IR blocks into per-location MATCH steps. Args: pruned_ir_blocks: list of IR basic block objects that have gone through a lowering step. Returns: list of MatchStep namedtuples, each of which contains all basic blocks that correspond to a single MATCH step.
[ "Split", "a", "list", "of", "IR", "blocks", "into", "per", "-", "location", "MATCH", "steps", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L88-L119
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
_split_match_steps_into_match_traversals
def _split_match_steps_into_match_traversals(match_steps): """Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.""" output = [] current_list = None for step in match_steps: if isinstance(step.root_block, QueryRoot): if current_list is not None: ...
python
def _split_match_steps_into_match_traversals(match_steps): """Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.""" output = [] current_list = None for step in match_steps: if isinstance(step.root_block, QueryRoot): if current_list is not None: ...
[ "def", "_split_match_steps_into_match_traversals", "(", "match_steps", ")", ":", "output", "=", "[", "]", "current_list", "=", "None", "for", "step", "in", "match_steps", ":", "if", "isinstance", "(", "step", ".", "root_block", ",", "QueryRoot", ")", ":", "if"...
Split a list of MatchSteps into multiple lists, each denoting a single MATCH traversal.
[ "Split", "a", "list", "of", "MatchSteps", "into", "multiple", "lists", "each", "denoting", "a", "single", "MATCH", "traversal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L122-L138
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/match_query.py
convert_to_match_query
def convert_to_match_query(ir_blocks): """Convert the list of IR blocks into a MatchQuery object, for easier manipulation.""" output_block = ir_blocks[-1] if not isinstance(output_block, ConstructResult): raise AssertionError(u'Expected last IR block to be ConstructResult, found: ' ...
python
def convert_to_match_query(ir_blocks): """Convert the list of IR blocks into a MatchQuery object, for easier manipulation.""" output_block = ir_blocks[-1] if not isinstance(output_block, ConstructResult): raise AssertionError(u'Expected last IR block to be ConstructResult, found: ' ...
[ "def", "convert_to_match_query", "(", "ir_blocks", ")", ":", "output_block", "=", "ir_blocks", "[", "-", "1", "]", "if", "not", "isinstance", "(", "output_block", ",", "ConstructResult", ")", ":", "raise", "AssertionError", "(", "u'Expected last IR block to be Const...
Convert the list of IR blocks into a MatchQuery object, for easier manipulation.
[ "Convert", "the", "list", "of", "IR", "blocks", "into", "a", "MatchQuery", "object", "for", "easier", "manipulation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/match_query.py#L178-L211
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/sql_formatting.py
insert_arguments_into_sql_query
def insert_arguments_into_sql_query(compilation_result, arguments): """Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for ev...
python
def insert_arguments_into_sql_query(compilation_result, arguments): """Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for ev...
[ "def", "insert_arguments_into_sql_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "SQL_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", "compila...
Insert the arguments into the compiled SQL query to form a complete query. Args: compilation_result: CompilationResult, compilation result from the GraphQL compiler. arguments: Dict[str, Any], parameter name -> value, for every parameter the query expects. Returns: SQLAlchemy Selectabl...
[ "Insert", "the", "arguments", "into", "the", "compiled", "SQL", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/sql_formatting.py#L10-L23
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
convert_coerce_type_to_instanceof_filter
def convert_coerce_type_to_instanceof_filter(coerce_type_block): """Create an "INSTANCEOF" Filter block from a CoerceType block.""" coerce_type_target = get_only_element_from_collection(coerce_type_block.target_class) # INSTANCEOF requires the target class to be passed in as a string, # so we make the ...
python
def convert_coerce_type_to_instanceof_filter(coerce_type_block): """Create an "INSTANCEOF" Filter block from a CoerceType block.""" coerce_type_target = get_only_element_from_collection(coerce_type_block.target_class) # INSTANCEOF requires the target class to be passed in as a string, # so we make the ...
[ "def", "convert_coerce_type_to_instanceof_filter", "(", "coerce_type_block", ")", ":", "coerce_type_target", "=", "get_only_element_from_collection", "(", "coerce_type_block", ".", "target_class", ")", "new_predicate", "=", "BinaryComposition", "(", "u'INSTANCEOF'", ",", "Loc...
Create an "INSTANCEOF" Filter block from a CoerceType block.
[ "Create", "an", "INSTANCEOF", "Filter", "block", "from", "a", "CoerceType", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L15-L24
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
convert_coerce_type_and_add_to_where_block
def convert_coerce_type_and_add_to_where_block(coerce_type_block, where_block): """Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.""" instanceof_filter = convert_coerce_type_to_instanceof_filter(coerce_type_block) if where_block: # There was already a Filter bl...
python
def convert_coerce_type_and_add_to_where_block(coerce_type_block, where_block): """Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.""" instanceof_filter = convert_coerce_type_to_instanceof_filter(coerce_type_block) if where_block: # There was already a Filter bl...
[ "def", "convert_coerce_type_and_add_to_where_block", "(", "coerce_type_block", ",", "where_block", ")", ":", "instanceof_filter", "=", "convert_coerce_type_to_instanceof_filter", "(", "coerce_type_block", ")", "if", "where_block", ":", "return", "Filter", "(", "BinaryComposit...
Create an "INSTANCEOF" Filter from a CoerceType, adding to an existing Filter if any.
[ "Create", "an", "INSTANCEOF", "Filter", "from", "a", "CoerceType", "adding", "to", "an", "existing", "Filter", "if", "any", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L27-L35
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
expression_list_to_conjunction
def expression_list_to_conjunction(expression_list): """Convert a list of expressions to an Expression that is the conjunction of all of them.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected `list`, Received {}.'.format(expression_list)) if len(expression_list) == 0: ...
python
def expression_list_to_conjunction(expression_list): """Convert a list of expressions to an Expression that is the conjunction of all of them.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected `list`, Received {}.'.format(expression_list)) if len(expression_list) == 0: ...
[ "def", "expression_list_to_conjunction", "(", "expression_list", ")", ":", "if", "not", "isinstance", "(", "expression_list", ",", "list", ")", ":", "raise", "AssertionError", "(", "u'Expected `list`, Received {}.'", ".", "format", "(", "expression_list", ")", ")", ...
Convert a list of expressions to an Expression that is the conjunction of all of them.
[ "Convert", "a", "list", "of", "expressions", "to", "an", "Expression", "that", "is", "the", "conjunction", "of", "all", "of", "them", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L38-L54
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
construct_where_filter_predicate
def construct_where_filter_predicate(query_metadata_table, simple_optional_root_info): """Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_l...
python
def construct_where_filter_predicate(query_metadata_table, simple_optional_root_info): """Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_l...
[ "def", "construct_where_filter_predicate", "(", "query_metadata_table", ",", "simple_optional_root_info", ")", ":", "inner_location_name_to_where_filter", "=", "{", "}", "for", "root_location", ",", "root_info_dict", "in", "six", ".", "iteritems", "(", "simple_optional_root...
Return an Expression that is True if and only if each simple optional filter is True. Construct filters for each simple optional, that are True if and only if `edge_field` does not exist in the `simple_optional_root_location` OR the `inner_location` is not defined. Return an Expression that evaluates to Tr...
[ "Return", "an", "Expression", "that", "is", "True", "if", "and", "only", "if", "each", "simple", "optional", "filter", "is", "True", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L192-L233
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
construct_optional_traversal_tree
def construct_optional_traversal_tree(complex_optional_roots, location_to_optional_roots): """Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand v...
python
def construct_optional_traversal_tree(complex_optional_roots, location_to_optional_roots): """Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand v...
[ "def", "construct_optional_traversal_tree", "(", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "tree", "=", "OptionalTraversalTree", "(", "complex_optional_roots", ")", "for", "optional_root_locations_stack", "in", "six", ".", "itervalues", "(", "lo...
Return a tree of complex optional root locations. Args: complex_optional_roots: list of @optional locations (location immmediately preceding an @optional Traverse) that expand vertex fields location_to_optional_roots: dict mapping from location -> optional_roots wher...
[ "Return", "a", "tree", "of", "complex", "optional", "root", "locations", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L337-L355
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
BetweenClause.validate
def validate(self): """Validate that the Between Expression is correctly representable.""" if not isinstance(self.field, LocalField): raise TypeError(u'Expected LocalField field, got: {} {}'.format( type(self.field).__name__, self.field)) if not isinstance(self.lower...
python
def validate(self): """Validate that the Between Expression is correctly representable.""" if not isinstance(self.field, LocalField): raise TypeError(u'Expected LocalField field, got: {} {}'.format( type(self.field).__name__, self.field)) if not isinstance(self.lower...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "field", ",", "LocalField", ")", ":", "raise", "TypeError", "(", "u'Expected LocalField field, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "field", ")", ...
Validate that the Between Expression is correctly representable.
[ "Validate", "that", "the", "Between", "Expression", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L77-L89
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
BetweenClause.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this BetweenClause.""" template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})' return template.format( field_name=self.field.to_match(), lower_bound=self.lower_bound.to_match(), ...
python
def to_match(self): """Return a unicode object with the MATCH representation of this BetweenClause.""" template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})' return template.format( field_name=self.field.to_match(), lower_bound=self.lower_bound.to_match(), ...
[ "def", "to_match", "(", "self", ")", ":", "template", "=", "u'({field_name} BETWEEN {lower_bound} AND {upper_bound})'", "return", "template", ".", "format", "(", "field_name", "=", "self", ".", "field", ".", "to_match", "(", ")", ",", "lower_bound", "=", "self", ...
Return a unicode object with the MATCH representation of this BetweenClause.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "BetweenClause", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L101-L107
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/utils.py
OptionalTraversalTree.insert
def insert(self, optional_root_locations_path): """Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of option...
python
def insert(self, optional_root_locations_path): """Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of option...
[ "def", "insert", "(", "self", ",", "optional_root_locations_path", ")", ":", "encountered_simple_optional", "=", "False", "parent_location", "=", "self", ".", "_root_location", "for", "optional_root_location", "in", "optional_root_locations_path", ":", "if", "encountered_...
Insert a path of optional Locations into the tree. Each OptionalTraversalTree object contains child Location objects as keys mapping to other OptionalTraversalTree objects. Args: optional_root_locations_path: list of optional root Locations all except the last ...
[ "Insert", "a", "path", "of", "optional", "Locations", "into", "the", "tree", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/utils.py#L261-L285
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
emit_code_from_ir
def emit_code_from_ir(sql_query_tree, compiler_metadata): """Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query ...
python
def emit_code_from_ir(sql_query_tree, compiler_metadata): """Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query ...
[ "def", "emit_code_from_ir", "(", "sql_query_tree", ",", "compiler_metadata", ")", ":", "context", "=", "CompilationContext", "(", "query_path_to_selectable", "=", "dict", "(", ")", ",", "query_path_to_location_info", "=", "sql_query_tree", ".", "query_path_to_location_inf...
Return a SQLAlchemy Query from a passed SqlQueryTree. Args: sql_query_tree: SqlQueryTree, tree representation of the query to emit. compiler_metadata: SqlMetadata, SQLAlchemy specific metadata. Returns: SQLAlchemy Query
[ "Return", "a", "SQLAlchemy", "Query", "from", "a", "passed", "SqlQueryTree", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L39-L58
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_create_table_and_update_context
def _create_table_and_update_context(node, context): """Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly a...
python
def _create_table_and_update_context(node, context): """Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly a...
[ "def", "_create_table_and_update_context", "(", "node", ",", "context", ")", ":", "schema_type_name", "=", "sql_context_helpers", ".", "get_schema_type_name", "(", "node", ",", "context", ")", "table", "=", "context", ".", "compiler_metadata", ".", "get_table", "(",...
Create an aliased table for a SqlNode. Updates the relevant Selectable global context. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Table, the newly aliased SQLAlchemy table.
[ "Create", "an", "aliased", "table", "for", "a", "SqlNode", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L75-L90
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_create_query
def _create_query(node, context): """Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query. """ visited_nodes = [node] output_colum...
python
def _create_query(node, context): """Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query. """ visited_nodes = [node] output_colum...
[ "def", "_create_query", "(", "node", ",", "context", ")", ":", "visited_nodes", "=", "[", "node", "]", "output_columns", "=", "_get_output_columns", "(", "visited_nodes", ",", "context", ")", "filters", "=", "_get_filters", "(", "visited_nodes", ",", "context", ...
Create a query from a SqlNode. Args: node: SqlNode, the current node. context: CompilationContext, global compilation state and metadata. Returns: Selectable, selectable of the generated query.
[ "Create", "a", "query", "from", "a", "SqlNode", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L93-L108
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_get_output_columns
def _get_output_columns(nodes, context): """Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to outp...
python
def _get_output_columns(nodes, context): """Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to outp...
[ "def", "_get_output_columns", "(", "nodes", ",", "context", ")", ":", "columns", "=", "[", "]", "for", "node", "in", "nodes", ":", "for", "sql_output", "in", "sql_context_helpers", ".", "get_outputs", "(", "node", ",", "context", ")", ":", "field_name", "=...
Get the output columns for a list of SqlNodes. Args: nodes: List[SqlNode], the nodes to get output columns from. context: CompilationContext, global compilation state and metadata. Returns: List[Column], list of SqlAlchemy Columns to output for this query.
[ "Get", "the", "output", "columns", "for", "a", "list", "of", "SqlNodes", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L111-L128
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_get_filters
def _get_filters(nodes, context): """Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions. """ f...
python
def _get_filters(nodes, context): """Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions. """ f...
[ "def", "_get_filters", "(", "nodes", ",", "context", ")", ":", "filters", "=", "[", "]", "for", "node", "in", "nodes", ":", "for", "filter_block", "in", "sql_context_helpers", ".", "get_filters", "(", "node", ",", "context", ")", ":", "filter_sql_expression"...
Get filters to apply to a list of SqlNodes. Args: nodes: List[SqlNode], the SqlNodes to get filters for. context: CompilationContext, global compilation state and metadata. Returns: List[Expression], list of SQLAlchemy expressions.
[ "Get", "filters", "to", "apply", "to", "a", "list", "of", "SqlNodes", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L131-L146
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_filter_to_sql
def _transform_filter_to_sql(filter_block, node, context): """Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation ...
python
def _transform_filter_to_sql(filter_block, node, context): """Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation ...
[ "def", "_transform_filter_to_sql", "(", "filter_block", ",", "node", ",", "context", ")", ":", "expression", "=", "filter_block", ".", "predicate", "return", "_expression_to_sql", "(", "expression", ",", "node", ",", "context", ")" ]
Transform a Filter block to its corresponding SQLAlchemy expression. Args: filter_block: Filter, the Filter block to transform. node: SqlNode, the node Filter block applies to. context: CompilationContext, global compilation state and metadata. Returns: Expression, SQLAlchemy e...
[ "Transform", "a", "Filter", "block", "to", "its", "corresponding", "SQLAlchemy", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L149-L161
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_expression_to_sql
def _expression_to_sql(expression, node, context): """Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: Compilatio...
python
def _expression_to_sql(expression, node, context): """Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: Compilatio...
[ "def", "_expression_to_sql", "(", "expression", ",", "node", ",", "context", ")", ":", "_expression_transformers", "=", "{", "expressions", ".", "LocalField", ":", "_transform_local_field_to_expression", ",", "expressions", ".", "Variable", ":", "_transform_variable_to_...
Recursively transform a Filter block predicate to its SQLAlchemy expression representation. Args: expression: expression, the compiler expression to transform. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Retu...
[ "Recursively", "transform", "a", "Filter", "block", "predicate", "to", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L164-L186
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_binary_composition_to_expression
def _transform_binary_composition_to_expression(expression, node, context): """Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compile...
python
def _transform_binary_composition_to_expression(expression, node, context): """Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compile...
[ "def", "_transform_binary_composition_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "if", "expression", ".", "operator", "not", "in", "constants", ".", "SUPPORTED_OPERATORS", ":", "raise", "NotImplementedError", "(", "u'Filter operation \"{}\...
Transform a BinaryComposition compiler expression into a SQLAlchemy expression. Recursively calls _expression_to_sql to convert its left and right sub-expressions. Args: expression: expression, BinaryComposition compiler expression. node: SqlNode, the SqlNode the expression applies to. ...
[ "Transform", "a", "BinaryComposition", "compiler", "expression", "into", "a", "SQLAlchemy", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L189-L223
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_variable_to_expression
def _transform_variable_to_expression(expression, node, context): """Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: Compila...
python
def _transform_variable_to_expression(expression, node, context): """Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: Compila...
[ "def", "_transform_variable_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "variable_name", "=", "expression", ".", "variable_name", "if", "not", "variable_name", ".", "startswith", "(", "u'$'", ")", ":", "raise", "AssertionError", "(", ...
Transform a Variable compiler expression into its SQLAlchemy expression representation. Args: expression: expression, Variable compiler expression. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Returns: ...
[ "Transform", "a", "Variable", "compiler", "expression", "into", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L255-L270
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_sql.py
_transform_local_field_to_expression
def _transform_local_field_to_expression(expression, node, context): """Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: ...
python
def _transform_local_field_to_expression(expression, node, context): """Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: ...
[ "def", "_transform_local_field_to_expression", "(", "expression", ",", "node", ",", "context", ")", ":", "column_name", "=", "expression", ".", "field_name", "column", "=", "sql_context_helpers", ".", "get_column", "(", "column_name", ",", "node", ",", "context", ...
Transform a LocalField compiler expression into its SQLAlchemy expression representation. Args: expression: expression, LocalField compiler expression. node: SqlNode, the SqlNode the expression applies to. context: CompilationContext, global compilation state and metadata. Returns: ...
[ "Transform", "a", "LocalField", "compiler", "expression", "into", "its", "SQLAlchemy", "expression", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_sql.py#L273-L286
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
lower_context_field_existence
def lower_context_field_existence(ir_blocks, query_metadata_table): """Lower ContextFieldExistence expressions into lower-level expressions.""" def regular_visitor_fn(expression): """Expression visitor function that rewrites ContextFieldExistence expressions.""" if not isinstance(expression, Con...
python
def lower_context_field_existence(ir_blocks, query_metadata_table): """Lower ContextFieldExistence expressions into lower-level expressions.""" def regular_visitor_fn(expression): """Expression visitor function that rewrites ContextFieldExistence expressions.""" if not isinstance(expression, Con...
[ "def", "lower_context_field_existence", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "def", "regular_visitor_fn", "(", "expression", ")", ":", "if", "not", "isinstance", "(", "expression", ",", "ContextFieldExistence", ")", ":", "return", "expression", "...
Lower ContextFieldExistence expressions into lower-level expressions.
[ "Lower", "ContextFieldExistence", "expressions", "into", "lower", "-", "level", "expressions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L56-L95
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
optimize_boolean_expression_comparisons
def optimize_boolean_expression_comparisons(ir_blocks): """Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is re...
python
def optimize_boolean_expression_comparisons(ir_blocks): """Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is re...
[ "def", "optimize_boolean_expression_comparisons", "(", "ir_blocks", ")", ":", "operator_inverses", "=", "{", "u'='", ":", "u'!='", ",", "u'!='", ":", "u'='", ",", "}", "def", "visitor_fn", "(", "expression", ")", ":", "if", "not", "isinstance", "(", "expressio...
Optimize comparisons of a boolean binary comparison expression against a boolean literal. Rewriting example: BinaryComposition( '=', BinaryComposition('!=', something, NullLiteral) False) The above is rewritten into: BinaryComposition('=', something, NullLit...
[ "Optimize", "comparisons", "of", "a", "boolean", "binary", "comparison", "expression", "against", "a", "boolean", "literal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L98-L171
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
extract_simple_optional_location_info
def extract_simple_optional_location_info( ir_blocks, complex_optional_roots, location_to_optional_roots): """Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_root...
python
def extract_simple_optional_location_info( ir_blocks, complex_optional_roots, location_to_optional_roots): """Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_root...
[ "def", "extract_simple_optional_location_info", "(", "ir_blocks", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "location_to_preceding_optional_root_iteritems", "=", "six", ".", "iteritems", "(", "{", "location", ":", "optional_root_locations_stack...
Construct a map from simple optional locations to their inner location and traversed edge. Args: ir_blocks: list of IR blocks to extract optional data from complex_optional_roots: list of @optional locations (location immmediately preceding an @optional traverse) tha...
[ "Construct", "a", "map", "from", "simple", "optional", "locations", "to", "their", "inner", "location", "and", "traversed", "edge", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L283-L337
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
remove_end_optionals
def remove_end_optionals(ir_blocks): """Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.""" new_ir_blocks = [] for block in ir_blocks: if not isinstance(block, EndOptional): new_ir_blocks.append(block) return new_ir_blocks
python
def remove_end_optionals(ir_blocks): """Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.""" new_ir_blocks = [] for block in ir_blocks: if not isinstance(block, EndOptional): new_ir_blocks.append(block) return new_ir_blocks
[ "def", "remove_end_optionals", "(", "ir_blocks", ")", ":", "new_ir_blocks", "=", "[", "]", "for", "block", "in", "ir_blocks", ":", "if", "not", "isinstance", "(", "block", ",", "EndOptional", ")", ":", "new_ir_blocks", ".", "append", "(", "block", ")", "re...
Return a list of IR blocks as a copy of the original, with EndOptional blocks removed.
[ "Return", "a", "list", "of", "IR", "blocks", "as", "a", "copy", "of", "the", "original", "with", "EndOptional", "blocks", "removed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L340-L346
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_common.py
OutputContextVertex.validate
def validate(self): """Validate that the OutputContextVertex is correctly representable.""" super(OutputContextVertex, self).validate() if self.location.field is not None: raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location))
python
def validate(self): """Validate that the OutputContextVertex is correctly representable.""" super(OutputContextVertex, self).validate() if self.location.field is not None: raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location))
[ "def", "validate", "(", "self", ")", ":", "super", "(", "OutputContextVertex", ",", "self", ")", ".", "validate", "(", ")", "if", "self", ".", "location", ".", "field", "is", "not", "None", ":", "raise", "ValueError", "(", "u'Expected location at a vertex, b...
Validate that the OutputContextVertex is correctly representable.
[ "Validate", "that", "the", "OutputContextVertex", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_common.py#L35-L40
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
lower_has_substring_binary_compositions
def lower_has_substring_binary_compositions(ir_blocks): """Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.""" def visitor_fn(expression): """Rewrite BinaryComposition expressions with "has_substring" into representable form.""" # The implementation of "h...
python
def lower_has_substring_binary_compositions(ir_blocks): """Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.""" def visitor_fn(expression): """Rewrite BinaryComposition expressions with "has_substring" into representable form.""" # The implementation of "h...
[ "def", "lower_has_substring_binary_compositions", "(", "ir_blocks", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "if", "not", "isinstance", "(", "expression", ",", "BinaryComposition", ")", "or", "expression", ".", "operator", "!=", "u'has_substring'"...
Lower Filter blocks that use the "has_substring" operation into MATCH-representable form.
[ "Lower", "Filter", "blocks", "that", "use", "the", "has_substring", "operation", "into", "MATCH", "-", "representable", "form", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L96-L140
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
truncate_repeated_single_step_traversals
def truncate_repeated_single_step_traversals(match_query): """Truncate one-step traversals that overlap a previous traversal location.""" # Such traversals frequently happen as side-effects of the lowering process # of Backtrack blocks, and needlessly complicate the executed queries. new_match_traversal...
python
def truncate_repeated_single_step_traversals(match_query): """Truncate one-step traversals that overlap a previous traversal location.""" # Such traversals frequently happen as side-effects of the lowering process # of Backtrack blocks, and needlessly complicate the executed queries. new_match_traversal...
[ "def", "truncate_repeated_single_step_traversals", "(", "match_query", ")", ":", "new_match_traversals", "=", "[", "]", "visited_locations", "=", "set", "(", ")", "for", "current_match_traversal", "in", "match_query", ".", "match_traversals", ":", "ignore_traversal", "=...
Truncate one-step traversals that overlap a previous traversal location.
[ "Truncate", "one", "-", "step", "traversals", "that", "overlap", "a", "previous", "traversal", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L143-L171
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
_flatten_location_translations
def _flatten_location_translations(location_translations): """If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency ...
python
def _flatten_location_translations(location_translations): """If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency ...
[ "def", "_flatten_location_translations", "(", "location_translations", ")", ":", "sources_to_process", "=", "set", "(", "six", ".", "iterkeys", "(", "location_translations", ")", ")", "def", "_update_translation", "(", "source", ")", ":", "destination", "=", "locati...
If location A translates to B, and B to C, then make A translate directly to C. Args: location_translations: dict of Location -> Location, where the key translates to the value. Mutated in place for efficiency and simplicity of implementation.
[ "If", "location", "A", "translates", "to", "B", "and", "B", "to", "C", "then", "make", "A", "translate", "directly", "to", "C", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L224-L248
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
_translate_equivalent_locations
def _translate_equivalent_locations(match_query, location_translations): """Translate Location objects into their equivalent locations, based on the given dict.""" new_match_traversals = [] def visitor_fn(expression): """Expression visitor function used to rewrite expressions with updated Location ...
python
def _translate_equivalent_locations(match_query, location_translations): """Translate Location objects into their equivalent locations, based on the given dict.""" new_match_traversals = [] def visitor_fn(expression): """Expression visitor function used to rewrite expressions with updated Location ...
[ "def", "_translate_equivalent_locations", "(", "match_query", ",", "location_translations", ")", ":", "new_match_traversals", "=", "[", "]", "def", "visitor_fn", "(", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "(", "ContextField", ",", "Gl...
Translate Location objects into their equivalent locations, based on the given dict.
[ "Translate", "Location", "objects", "into", "their", "equivalent", "locations", "based", "on", "the", "given", "dict", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L251-L338
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
lower_folded_coerce_types_into_filter_blocks
def lower_folded_coerce_types_into_filter_blocks(folded_ir_blocks): """Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if isinstance(block, CoerceType): new_block = convert_coerce_type_to_...
python
def lower_folded_coerce_types_into_filter_blocks(folded_ir_blocks): """Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if isinstance(block, CoerceType): new_block = convert_coerce_type_to_...
[ "def", "lower_folded_coerce_types_into_filter_blocks", "(", "folded_ir_blocks", ")", ":", "new_folded_ir_blocks", "=", "[", "]", "for", "block", "in", "folded_ir_blocks", ":", "if", "isinstance", "(", "block", ",", "CoerceType", ")", ":", "new_block", "=", "convert_...
Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks.
[ "Lower", "CoerceType", "blocks", "into", "INSTANCEOF", "Filter", "blocks", ".", "Indended", "for", "folded", "IR", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L341-L352
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
remove_backtrack_blocks_from_fold
def remove_backtrack_blocks_from_fold(folded_ir_blocks): """Return a list of IR blocks with all Backtrack blocks removed.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if not isinstance(block, Backtrack): new_folded_ir_blocks.append(block) return new_folded_ir_blocks
python
def remove_backtrack_blocks_from_fold(folded_ir_blocks): """Return a list of IR blocks with all Backtrack blocks removed.""" new_folded_ir_blocks = [] for block in folded_ir_blocks: if not isinstance(block, Backtrack): new_folded_ir_blocks.append(block) return new_folded_ir_blocks
[ "def", "remove_backtrack_blocks_from_fold", "(", "folded_ir_blocks", ")", ":", "new_folded_ir_blocks", "=", "[", "]", "for", "block", "in", "folded_ir_blocks", ":", "if", "not", "isinstance", "(", "block", ",", "Backtrack", ")", ":", "new_folded_ir_blocks", ".", "...
Return a list of IR blocks with all Backtrack blocks removed.
[ "Return", "a", "list", "of", "IR", "blocks", "with", "all", "Backtrack", "blocks", "removed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L355-L361
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/ir_lowering.py
truncate_repeated_single_step_traversals_in_sub_queries
def truncate_repeated_single_step_traversals_in_sub_queries(compound_match_query): """For each sub-query, remove one-step traversals that overlap a previous traversal location.""" lowered_match_queries = [] for match_query in compound_match_query.match_queries: new_match_query = truncate_repeated_si...
python
def truncate_repeated_single_step_traversals_in_sub_queries(compound_match_query): """For each sub-query, remove one-step traversals that overlap a previous traversal location.""" lowered_match_queries = [] for match_query in compound_match_query.match_queries: new_match_query = truncate_repeated_si...
[ "def", "truncate_repeated_single_step_traversals_in_sub_queries", "(", "compound_match_query", ")", ":", "lowered_match_queries", "=", "[", "]", "for", "match_query", "in", "compound_match_query", ".", "match_queries", ":", "new_match_query", "=", "truncate_repeated_single_step...
For each sub-query, remove one-step traversals that overlap a previous traversal location.
[ "For", "each", "sub", "-", "query", "remove", "one", "-", "step", "traversals", "that", "overlap", "a", "previous", "traversal", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/ir_lowering.py#L364-L371
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_prune_traverse_using_omitted_locations
def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations, complex_optional_roots, location_to_optional_roots): """Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of comple...
python
def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations, complex_optional_roots, location_to_optional_roots): """Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of comple...
[ "def", "_prune_traverse_using_omitted_locations", "(", "match_traversal", ",", "omitted_locations", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "new_match_traversal", "=", "[", "]", "for", "step", "in", "match_traversal", ":", "new_step", "...
Return a prefix of the given traverse, excluding any blocks after an omitted optional. Given a subset (omitted_locations) of complex_optional_roots, return a new match traversal removing all MatchStep objects that are within any omitted location. Args: match_traversal: list of MatchStep objects to...
[ "Return", "a", "prefix", "of", "the", "given", "traverse", "excluding", "any", "blocks", "after", "an", "omitted", "optional", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L18-L82
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
convert_optional_traversals_to_compound_match_query
def convert_optional_traversals_to_compound_match_query( match_query, complex_optional_roots, location_to_optional_roots): """Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different Mat...
python
def convert_optional_traversals_to_compound_match_query( match_query, complex_optional_roots, location_to_optional_roots): """Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different Mat...
[ "def", "convert_optional_traversals_to_compound_match_query", "(", "match_query", ",", "complex_optional_roots", ",", "location_to_optional_roots", ")", ":", "tree", "=", "construct_optional_traversal_tree", "(", "complex_optional_roots", ",", "location_to_optional_roots", ")", "...
Return 2^n distinct MatchQuery objects in a CompoundMatchQuery. Given a MatchQuery containing `n` optional traverses that expand vertex fields, construct `2^n` different MatchQuery objects: one for each possible subset of optional edges that can be followed. For each edge `e` in a subset of optional ed...
[ "Return", "2^n", "distinct", "MatchQuery", "objects", "in", "a", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L85-L151
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_get_present_locations
def _get_present_locations(match_traversals): """Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be i...
python
def _get_present_locations(match_traversals): """Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be i...
[ "def", "_get_present_locations", "(", "match_traversals", ")", ":", "present_locations", "=", "set", "(", ")", "present_non_optional_locations", "=", "set", "(", ")", "for", "match_traversal", "in", "match_traversals", ":", "for", "step", "in", "match_traversal", ":...
Return the set of locations and non-optional locations present in the given match traversals. When enumerating the possibilities for optional traversals, the resulting match traversals may have sections of the query omitted. These locations will not be included in the returned `present_locations`. All ...
[ "Return", "the", "set", "of", "locations", "and", "non", "-", "optional", "locations", "present", "in", "the", "given", "match", "traversals", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L154-L190
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
prune_non_existent_outputs
def prune_non_existent_outputs(compound_match_query): """Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned...
python
def prune_non_existent_outputs(compound_match_query): """Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned...
[ "def", "prune_non_existent_outputs", "(", "compound_match_query", ")", ":", "if", "len", "(", "compound_match_query", ".", "match_queries", ")", "==", "1", ":", "return", "compound_match_query", "elif", "len", "(", "compound_match_query", ".", "match_queries", ")", ...
Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery. Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks, For each of these, remove the outputs (that have been implicitly pruned away) from each corresponding ConstructResult block. ...
[ "Remove", "non", "-", "existent", "outputs", "from", "each", "MatchQuery", "in", "the", "given", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L193-L266
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_construct_location_to_filter_list
def _construct_location_to_filter_list(match_query): """Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of ...
python
def _construct_location_to_filter_list(match_query): """Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of ...
[ "def", "_construct_location_to_filter_list", "(", "match_query", ")", ":", "location_to_filters", "=", "{", "}", "for", "match_traversal", "in", "match_query", ".", "match_traversals", ":", "for", "match_step", "in", "match_traversal", ":", "current_filter", "=", "mat...
Return a dict mapping location -> list of filters applied at that location. Args: match_query: MatchQuery object from which to extract location -> filters dict Returns: dict mapping each location in match_query to a list of Filter objects applied at that location
[ "Return", "a", "dict", "mapping", "location", "-", ">", "list", "of", "filters", "applied", "at", "that", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L269-L291
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_filter_list_to_conjunction_expression
def _filter_list_to_conjunction_expression(filter_list): """Convert a list of filters to an Expression that is the conjunction of all of them.""" if not isinstance(filter_list, list): raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list)) if any((not isinstance(filter_block, Fil...
python
def _filter_list_to_conjunction_expression(filter_list): """Convert a list of filters to an Expression that is the conjunction of all of them.""" if not isinstance(filter_list, list): raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list)) if any((not isinstance(filter_block, Fil...
[ "def", "_filter_list_to_conjunction_expression", "(", "filter_list", ")", ":", "if", "not", "isinstance", "(", "filter_list", ",", "list", ")", ":", "raise", "AssertionError", "(", "u'Expected `list`, Received: {}.'", ".", "format", "(", "filter_list", ")", ")", "if...
Convert a list of filters to an Expression that is the conjunction of all of them.
[ "Convert", "a", "list", "of", "filters", "to", "an", "Expression", "that", "is", "the", "conjunction", "of", "all", "of", "them", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L294-L302
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_apply_filters_to_first_location_occurrence
def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters, already_filtered_locations): """Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, con...
python
def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters, already_filtered_locations): """Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, con...
[ "def", "_apply_filters_to_first_location_occurrence", "(", "match_traversal", ",", "location_to_filters", ",", "already_filtered_locations", ")", ":", "new_match_traversal", "=", "[", "]", "newly_filtered_locations", "=", "set", "(", ")", "for", "match_step", "in", "match...
Apply all filters for a specific location into its first occurrence in a given traversal. For each location in the given match traversal, construct a conjunction of all filters applied to that location, and apply the resulting Filter to the first instance of the location. Args: match_traversal...
[ "Apply", "all", "filters", "for", "a", "specific", "location", "into", "its", "first", "occurrence", "in", "a", "given", "traversal", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L305-L355
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
collect_filters_to_first_location_occurrence
def collect_filters_to_first_location_occurrence(compound_match_query): """Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their ...
python
def collect_filters_to_first_location_occurrence(compound_match_query): """Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their ...
[ "def", "collect_filters_to_first_location_occurrence", "(", "compound_match_query", ")", ":", "new_match_queries", "=", "[", "]", "for", "match_query", "in", "compound_match_query", ".", "match_queries", ":", "location_to_filters", "=", "_construct_location_to_filter_list", "...
Collect all filters for a particular location to the first instance of the location. Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may result in filters being applied to locations after their first occurence. OrientDB does not resolve this behavior correctly. Therefo...
[ "Collect", "all", "filters", "for", "a", "particular", "location", "to", "the", "first", "instance", "of", "the", "location", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L358-L402
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_update_context_field_binary_composition
def _update_context_field_binary_composition(present_locations, expression): """Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least on...
python
def _update_context_field_binary_composition(present_locations, expression): """Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least on...
[ "def", "_update_context_field_binary_composition", "(", "present_locations", ",", "expression", ")", ":", "if", "not", "any", "(", "(", "isinstance", "(", "expression", ".", "left", ",", "ContextField", ")", ",", "isinstance", "(", "expression", ".", "right", ",...
Lower BinaryCompositions involving non-existent ContextFields to True. Args: present_locations: set of all locations in the current MatchQuery that have not been pruned expression: BinaryComposition with at least one ContextField operand Returns: TrueLiteral iff either ContextField ope...
[ "Lower", "BinaryCompositions", "involving", "non", "-", "existent", "ContextFields", "to", "True", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L405-L433
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_simplify_non_context_field_binary_composition
def _simplify_non_context_field_binary_composition(expression): """Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conju...
python
def _simplify_non_context_field_binary_composition(expression): """Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conju...
[ "def", "_simplify_non_context_field_binary_composition", "(", "expression", ")", ":", "if", "any", "(", "(", "isinstance", "(", "expression", ".", "left", ",", "ContextField", ")", ",", "isinstance", "(", "expression", ".", "right", ",", "ContextField", ")", ")"...
Return a simplified BinaryComposition if either operand is a TrueLiteral. Args: expression: BinaryComposition without any ContextField operand(s) Returns: simplified expression if the given expression is a disjunction/conjunction and one of it's operands is a TrueLiteral, and t...
[ "Return", "a", "simplified", "BinaryComposition", "if", "either", "operand", "is", "a", "TrueLiteral", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L436-L465
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_update_context_field_expression
def _update_context_field_expression(present_locations, expression): """Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.""" no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable) if isinstance(expression, BinaryComposition): if isi...
python
def _update_context_field_expression(present_locations, expression): """Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.""" no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable) if isinstance(expression, BinaryComposition): if isi...
[ "def", "_update_context_field_expression", "(", "present_locations", ",", "expression", ")", ":", "no_op_blocks", "=", "(", "ContextField", ",", "Literal", ",", "LocalField", ",", "UnaryTransformation", ",", "Variable", ")", "if", "isinstance", "(", "expression", ",...
Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result.
[ "Lower", "Expressions", "involving", "non", "-", "existent", "ContextFields", "to", "TrueLiteral", "and", "simplify", "result", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L484-L508
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
_lower_non_existent_context_field_filters
def _lower_non_existent_context_field_filters(match_traversals, visitor_fn): """Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a Tr...
python
def _lower_non_existent_context_field_filters(match_traversals, visitor_fn): """Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a Tr...
[ "def", "_lower_non_existent_context_field_filters", "(", "match_traversals", ",", "visitor_fn", ")", ":", "new_match_traversals", "=", "[", "]", "for", "match_traversal", "in", "match_traversals", ":", "new_match_traversal", "=", "[", "]", "for", "step", "in", "match_...
Return new match traversals, lowering filters involving non-existent ContextFields. Expressions involving non-existent ContextFields are evaluated to TrueLiteral. BinaryCompositions, where one of the operands is lowered to a TrueLiteral, are lowered appropriately based on the present operator (u'||' and u'...
[ "Return", "new", "match", "traversals", "lowering", "filters", "involving", "non", "-", "existent", "ContextFields", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L511-L544
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/optional_traversal.py
lower_context_field_expressions
def lower_context_field_expressions(compound_match_query): """Lower Expressons involving non-existent ContextFields.""" if len(compound_match_query.match_queries) == 0: raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.' .format(compound_match_...
python
def lower_context_field_expressions(compound_match_query): """Lower Expressons involving non-existent ContextFields.""" if len(compound_match_query.match_queries) == 0: raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.' .format(compound_match_...
[ "def", "lower_context_field_expressions", "(", "compound_match_query", ")", ":", "if", "len", "(", "compound_match_query", ".", "match_queries", ")", "==", "0", ":", "raise", "AssertionError", "(", "u'Received CompoundMatchQuery {} with no MatchQuery objects.'", ".", "forma...
Lower Expressons involving non-existent ContextFields.
[ "Lower", "Expressons", "involving", "non", "-", "existent", "ContextFields", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/optional_traversal.py#L547-L574
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_edges_do_not_have_extra_links
def _validate_edges_do_not_have_extra_links(class_name, properties): """Validate that edges do not have properties of Link type that aren't the edge endpoints.""" for property_name, property_descriptor in six.iteritems(properties): if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT...
python
def _validate_edges_do_not_have_extra_links(class_name, properties): """Validate that edges do not have properties of Link type that aren't the edge endpoints.""" for property_name, property_descriptor in six.iteritems(properties): if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT...
[ "def", "_validate_edges_do_not_have_extra_links", "(", "class_name", ",", "properties", ")", ":", "for", "property_name", ",", "property_descriptor", "in", "six", ".", "iteritems", "(", "properties", ")", ":", "if", "property_name", "in", "{", "EDGE_SOURCE_PROPERTY_NA...
Validate that edges do not have properties of Link type that aren't the edge endpoints.
[ "Validate", "that", "edges", "do", "not", "have", "properties", "of", "Link", "type", "that", "aren", "t", "the", "edge", "endpoints", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L44-L53
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_property_names
def _validate_property_names(class_name, properties): """Validate that properties do not have names that may cause problems in the GraphQL schema.""" for property_name in properties: if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES): raise IllegalSchemaStateErr...
python
def _validate_property_names(class_name, properties): """Validate that properties do not have names that may cause problems in the GraphQL schema.""" for property_name in properties: if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES): raise IllegalSchemaStateErr...
[ "def", "_validate_property_names", "(", "class_name", ",", "properties", ")", ":", "for", "property_name", "in", "properties", ":", "if", "not", "property_name", "or", "property_name", ".", "startswith", "(", "ILLEGAL_PROPERTY_NAME_PREFIXES", ")", ":", "raise", "Ill...
Validate that properties do not have names that may cause problems in the GraphQL schema.
[ "Validate", "that", "properties", "do", "not", "have", "names", "that", "may", "cause", "problems", "in", "the", "GraphQL", "schema", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L56-L61
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
_validate_collections_have_default_values
def _validate_collections_have_default_values(class_name, property_name, property_descriptor): """Validate that if the property is of collection type, it has a specified default value.""" # We don't want properties of collection type having "null" values, since that may cause # unexpected errors during Grap...
python
def _validate_collections_have_default_values(class_name, property_name, property_descriptor): """Validate that if the property is of collection type, it has a specified default value.""" # We don't want properties of collection type having "null" values, since that may cause # unexpected errors during Grap...
[ "def", "_validate_collections_have_default_values", "(", "class_name", ",", "property_name", ",", "property_descriptor", ")", ":", "if", "property_descriptor", ".", "type_id", "in", "COLLECTION_PROPERTY_TYPES", ":", "if", "property_descriptor", ".", "default", "is", "None...
Validate that if the property is of collection type, it has a specified default value.
[ "Validate", "that", "if", "the", "property", "is", "of", "collection", "type", "it", "has", "a", "specified", "default", "value", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L64-L71
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
get_superclasses_from_class_definition
def get_superclasses_from_class_definition(class_definition): """Extract a list of all superclass names from a class definition dict.""" # New-style superclasses definition, supporting multiple-inheritance. superclasses = class_definition.get('superClasses', None) if superclasses: return list(s...
python
def get_superclasses_from_class_definition(class_definition): """Extract a list of all superclass names from a class definition dict.""" # New-style superclasses definition, supporting multiple-inheritance. superclasses = class_definition.get('superClasses', None) if superclasses: return list(s...
[ "def", "get_superclasses_from_class_definition", "(", "class_definition", ")", ":", "superclasses", "=", "class_definition", ".", "get", "(", "'superClasses'", ",", "None", ")", "if", "superclasses", ":", "return", "list", "(", "superclasses", ")", "superclass", "="...
Extract a list of all superclass names from a class definition dict.
[ "Extract", "a", "list", "of", "all", "superclass", "names", "from", "a", "class", "definition", "dict", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L74-L88
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaElement.freeze
def freeze(self): """Make the SchemaElement's connections immutable.""" self.in_connections = frozenset(self.in_connections) self.out_connections = frozenset(self.out_connections)
python
def freeze(self): """Make the SchemaElement's connections immutable.""" self.in_connections = frozenset(self.in_connections) self.out_connections = frozenset(self.out_connections)
[ "def", "freeze", "(", "self", ")", ":", "self", ".", "in_connections", "=", "frozenset", "(", "self", ".", "in_connections", ")", "self", ".", "out_connections", "=", "frozenset", "(", "self", ".", "out_connections", ")" ]
Make the SchemaElement's connections immutable.
[ "Make", "the", "SchemaElement", "s", "connections", "immutable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L180-L183
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.get_default_property_values
def get_default_property_values(self, classname): """Return a dict with default values for all properties declared on this class.""" schema_element = self.get_element_by_class_name(classname) result = { property_name: property_descriptor.default for property_name, proper...
python
def get_default_property_values(self, classname): """Return a dict with default values for all properties declared on this class.""" schema_element = self.get_element_by_class_name(classname) result = { property_name: property_descriptor.default for property_name, proper...
[ "def", "get_default_property_values", "(", "self", ",", "classname", ")", ":", "schema_element", "=", "self", ".", "get_element_by_class_name", "(", "classname", ")", "result", "=", "{", "property_name", ":", "property_descriptor", ".", "default", "for", "property_n...
Return a dict with default values for all properties declared on this class.
[ "Return", "a", "dict", "with", "default", "values", "for", "all", "properties", "declared", "on", "this", "class", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L297-L311
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph._get_property_values_with_defaults
def _get_property_values_with_defaults(self, classname, property_values): """Return the property values for the class, with default values applied where needed.""" # To uphold OrientDB semantics, make a new dict with all property values set # to their default values, which are None if no default...
python
def _get_property_values_with_defaults(self, classname, property_values): """Return the property values for the class, with default values applied where needed.""" # To uphold OrientDB semantics, make a new dict with all property values set # to their default values, which are None if no default...
[ "def", "_get_property_values_with_defaults", "(", "self", ",", "classname", ",", "property_values", ")", ":", "final_values", "=", "self", ".", "get_default_property_values", "(", "classname", ")", "final_values", ".", "update", "(", "property_values", ")", "return", ...
Return the property values for the class, with default values applied where needed.
[ "Return", "the", "property", "values", "for", "the", "class", "with", "default", "values", "applied", "where", "needed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L313-L320
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.get_element_by_class_name_or_raise
def get_element_by_class_name_or_raise(self, class_name): """Return the SchemaElement for the specified class name, asserting that it exists.""" if class_name not in self._elements: raise InvalidClassError(u'Class does not exist: {}'.format(class_name)) return self._elements[class_n...
python
def get_element_by_class_name_or_raise(self, class_name): """Return the SchemaElement for the specified class name, asserting that it exists.""" if class_name not in self._elements: raise InvalidClassError(u'Class does not exist: {}'.format(class_name)) return self._elements[class_n...
[ "def", "get_element_by_class_name_or_raise", "(", "self", ",", "class_name", ")", ":", "if", "class_name", "not", "in", "self", ".", "_elements", ":", "raise", "InvalidClassError", "(", "u'Class does not exist: {}'", ".", "format", "(", "class_name", ")", ")", "re...
Return the SchemaElement for the specified class name, asserting that it exists.
[ "Return", "the", "SchemaElement", "for", "the", "specified", "class", "name", "asserting", "that", "it", "exists", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L322-L327
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.get_vertex_schema_element_or_raise
def get_vertex_schema_element_or_raise(self, vertex_classname): """Return the schema element with the given name, asserting that it's of vertex type.""" schema_element = self.get_element_by_class_name_or_raise(vertex_classname) if not schema_element.is_vertex: raise InvalidClassErro...
python
def get_vertex_schema_element_or_raise(self, vertex_classname): """Return the schema element with the given name, asserting that it's of vertex type.""" schema_element = self.get_element_by_class_name_or_raise(vertex_classname) if not schema_element.is_vertex: raise InvalidClassErro...
[ "def", "get_vertex_schema_element_or_raise", "(", "self", ",", "vertex_classname", ")", ":", "schema_element", "=", "self", ".", "get_element_by_class_name_or_raise", "(", "vertex_classname", ")", "if", "not", "schema_element", ".", "is_vertex", ":", "raise", "InvalidCl...
Return the schema element with the given name, asserting that it's of vertex type.
[ "Return", "the", "schema", "element", "with", "the", "given", "name", "asserting", "that", "it", "s", "of", "vertex", "type", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L329-L336
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.get_edge_schema_element_or_raise
def get_edge_schema_element_or_raise(self, edge_classname): """Return the schema element with the given name, asserting that it's of edge type.""" schema_element = self.get_element_by_class_name_or_raise(edge_classname) if not schema_element.is_edge: raise InvalidClassError(u'Non-ed...
python
def get_edge_schema_element_or_raise(self, edge_classname): """Return the schema element with the given name, asserting that it's of edge type.""" schema_element = self.get_element_by_class_name_or_raise(edge_classname) if not schema_element.is_edge: raise InvalidClassError(u'Non-ed...
[ "def", "get_edge_schema_element_or_raise", "(", "self", ",", "edge_classname", ")", ":", "schema_element", "=", "self", ".", "get_element_by_class_name_or_raise", "(", "edge_classname", ")", "if", "not", "schema_element", ".", "is_edge", ":", "raise", "InvalidClassError...
Return the schema element with the given name, asserting that it's of edge type.
[ "Return", "the", "schema", "element", "with", "the", "given", "name", "asserting", "that", "it", "s", "of", "edge", "type", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L338-L345
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.validate_is_non_abstract_vertex_type
def validate_is_non_abstract_vertex_type(self, vertex_classname): """Validate that a vertex classname corresponds to a non-abstract vertex class.""" element = self.get_vertex_schema_element_or_raise(vertex_classname) if element.abstract: raise InvalidClassError(u'Expected a non-abst...
python
def validate_is_non_abstract_vertex_type(self, vertex_classname): """Validate that a vertex classname corresponds to a non-abstract vertex class.""" element = self.get_vertex_schema_element_or_raise(vertex_classname) if element.abstract: raise InvalidClassError(u'Expected a non-abst...
[ "def", "validate_is_non_abstract_vertex_type", "(", "self", ",", "vertex_classname", ")", ":", "element", "=", "self", ".", "get_vertex_schema_element_or_raise", "(", "vertex_classname", ")", "if", "element", ".", "abstract", ":", "raise", "InvalidClassError", "(", "u...
Validate that a vertex classname corresponds to a non-abstract vertex class.
[ "Validate", "that", "a", "vertex", "classname", "corresponds", "to", "a", "non", "-", "abstract", "vertex", "class", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L355-L361
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.validate_is_non_abstract_edge_type
def validate_is_non_abstract_edge_type(self, edge_classname): """Validate that a edge classname corresponds to a non-abstract edge class.""" element = self.get_edge_schema_element_or_raise(edge_classname) if element.abstract: raise InvalidClassError(u'Expected a non-abstract vertex ...
python
def validate_is_non_abstract_edge_type(self, edge_classname): """Validate that a edge classname corresponds to a non-abstract edge class.""" element = self.get_edge_schema_element_or_raise(edge_classname) if element.abstract: raise InvalidClassError(u'Expected a non-abstract vertex ...
[ "def", "validate_is_non_abstract_edge_type", "(", "self", ",", "edge_classname", ")", ":", "element", "=", "self", ".", "get_edge_schema_element_or_raise", "(", "edge_classname", ")", "if", "element", ".", "abstract", ":", "raise", "InvalidClassError", "(", "u'Expecte...
Validate that a edge classname corresponds to a non-abstract edge class.
[ "Validate", "that", "a", "edge", "classname", "corresponds", "to", "a", "non", "-", "abstract", "edge", "class", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L363-L369
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph.validate_properties_exist
def validate_properties_exist(self, classname, property_names): """Validate that the specified property names are indeed defined on the given class.""" schema_element = self.get_element_by_class_name(classname) requested_properties = set(property_names) available_properties = set(schema...
python
def validate_properties_exist(self, classname, property_names): """Validate that the specified property names are indeed defined on the given class.""" schema_element = self.get_element_by_class_name(classname) requested_properties = set(property_names) available_properties = set(schema...
[ "def", "validate_properties_exist", "(", "self", ",", "classname", ",", "property_names", ")", ":", "schema_element", "=", "self", ".", "get_element_by_class_name", "(", "classname", ")", "requested_properties", "=", "set", "(", "property_names", ")", "available_prope...
Validate that the specified property names are indeed defined on the given class.
[ "Validate", "that", "the", "specified", "property", "names", "are", "indeed", "defined", "on", "the", "given", "class", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L371-L381
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph._split_classes_by_kind
def _split_classes_by_kind(self, class_name_to_definition): """Assign each class to the vertex, edge or non-graph type sets based on its kind.""" for class_name in class_name_to_definition: inheritance_set = self._inheritance_sets[class_name] is_vertex = ORIENTDB_BASE_VERTEX_CLA...
python
def _split_classes_by_kind(self, class_name_to_definition): """Assign each class to the vertex, edge or non-graph type sets based on its kind.""" for class_name in class_name_to_definition: inheritance_set = self._inheritance_sets[class_name] is_vertex = ORIENTDB_BASE_VERTEX_CLA...
[ "def", "_split_classes_by_kind", "(", "self", ",", "class_name_to_definition", ")", ":", "for", "class_name", "in", "class_name_to_definition", ":", "inheritance_set", "=", "self", ".", "_inheritance_sets", "[", "class_name", "]", "is_vertex", "=", "ORIENTDB_BASE_VERTEX...
Assign each class to the vertex, edge or non-graph type sets based on its kind.
[ "Assign", "each", "class", "to", "the", "vertex", "edge", "or", "non", "-", "graph", "type", "sets", "based", "on", "its", "kind", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L440-L461
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph._create_descriptor_from_property_definition
def _create_descriptor_from_property_definition(self, class_name, property_definition, class_name_to_definition): """Return a PropertyDescriptor corresponding to the given OrientDB property definition.""" name = property_definition['name'] type...
python
def _create_descriptor_from_property_definition(self, class_name, property_definition, class_name_to_definition): """Return a PropertyDescriptor corresponding to the given OrientDB property definition.""" name = property_definition['name'] type...
[ "def", "_create_descriptor_from_property_definition", "(", "self", ",", "class_name", ",", "property_definition", ",", "class_name_to_definition", ")", ":", "name", "=", "property_definition", "[", "'name'", "]", "type_id", "=", "property_definition", "[", "'type'", "]"...
Return a PropertyDescriptor corresponding to the given OrientDB property definition.
[ "Return", "a", "PropertyDescriptor", "corresponding", "to", "the", "given", "OrientDB", "property", "definition", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L548-L616
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_graph.py
SchemaGraph._link_vertex_and_edge_types
def _link_vertex_and_edge_types(self): """For each edge, link it to the vertex types it connects to each other.""" for edge_class_name in self._edge_class_names: edge_element = self._elements[edge_class_name] if (EDGE_SOURCE_PROPERTY_NAME not in edge_element.properties or ...
python
def _link_vertex_and_edge_types(self): """For each edge, link it to the vertex types it connects to each other.""" for edge_class_name in self._edge_class_names: edge_element = self._elements[edge_class_name] if (EDGE_SOURCE_PROPERTY_NAME not in edge_element.properties or ...
[ "def", "_link_vertex_and_edge_types", "(", "self", ")", ":", "for", "edge_class_name", "in", "self", ".", "_edge_class_names", ":", "edge_element", "=", "self", ".", "_elements", "[", "edge_class_name", "]", "if", "(", "EDGE_SOURCE_PROPERTY_NAME", "not", "in", "ed...
For each edge, link it to the vertex types it connects to each other.
[ "For", "each", "edge", "link", "it", "to", "the", "vertex", "types", "it", "connects", "to", "each", "other", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_graph.py#L618-L646
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
_is_local_filter
def _is_local_filter(filter_block): """Return True if the Filter block references no non-local fields, and False otherwise.""" # We need the "result" value of this function to be mutated within the "visitor_fn". # Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here: # h...
python
def _is_local_filter(filter_block): """Return True if the Filter block references no non-local fields, and False otherwise.""" # We need the "result" value of this function to be mutated within the "visitor_fn". # Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here: # h...
[ "def", "_is_local_filter", "(", "filter_block", ")", ":", "result", "=", "{", "'is_local_filter'", ":", "True", "}", "filter_predicate", "=", "filter_block", ".", "predicate", "def", "visitor_fn", "(", "expression", ")", ":", "non_local_expression_types", "=", "("...
Return True if the Filter block references no non-local fields, and False otherwise.
[ "Return", "True", "if", "the", "Filter", "block", "references", "no", "non", "-", "local", "fields", "and", "False", "otherwise", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L53-L78
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
_calculate_type_bound_at_step
def _calculate_type_bound_at_step(match_step): """Return the GraphQL type bound at the given step, or None if no bound is given.""" current_type_bounds = [] if isinstance(match_step.root_block, QueryRoot): # The QueryRoot start class is a type bound. current_type_bounds.extend(match_step.ro...
python
def _calculate_type_bound_at_step(match_step): """Return the GraphQL type bound at the given step, or None if no bound is given.""" current_type_bounds = [] if isinstance(match_step.root_block, QueryRoot): # The QueryRoot start class is a type bound. current_type_bounds.extend(match_step.ro...
[ "def", "_calculate_type_bound_at_step", "(", "match_step", ")", ":", "current_type_bounds", "=", "[", "]", "if", "isinstance", "(", "match_step", ".", "root_block", ",", "QueryRoot", ")", ":", "current_type_bounds", ".", "extend", "(", "match_step", ".", "root_blo...
Return the GraphQL type bound at the given step, or None if no bound is given.
[ "Return", "the", "GraphQL", "type", "bound", "at", "the", "given", "step", "or", "None", "if", "no", "bound", "is", "given", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L188-L205
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
_assert_type_bounds_are_not_conflicting
def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound, location, match_query): """Ensure that the two bounds either are an exact match, or one of them is None.""" if all((current_type_bound is not None, previous_type_bound is ...
python
def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound, location, match_query): """Ensure that the two bounds either are an exact match, or one of them is None.""" if all((current_type_bound is not None, previous_type_bound is ...
[ "def", "_assert_type_bounds_are_not_conflicting", "(", "current_type_bound", ",", "previous_type_bound", ",", "location", ",", "match_query", ")", ":", "if", "all", "(", "(", "current_type_bound", "is", "not", "None", ",", "previous_type_bound", "is", "not", "None", ...
Ensure that the two bounds either are an exact match, or one of them is None.
[ "Ensure", "that", "the", "two", "bounds", "either", "are", "an", "exact", "match", "or", "one", "of", "them", "is", "None", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L208-L216
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
_expose_only_preferred_locations
def _expose_only_preferred_locations(match_query, location_types, coerced_locations, preferred_locations, eligible_locations): """Return a MATCH query where only preferred locations are valid as query start locations.""" preferred_location_types = dict() eligible_locatio...
python
def _expose_only_preferred_locations(match_query, location_types, coerced_locations, preferred_locations, eligible_locations): """Return a MATCH query where only preferred locations are valid as query start locations.""" preferred_location_types = dict() eligible_locatio...
[ "def", "_expose_only_preferred_locations", "(", "match_query", ",", "location_types", ",", "coerced_locations", ",", "preferred_locations", ",", "eligible_locations", ")", ":", "preferred_location_types", "=", "dict", "(", ")", "eligible_location_types", "=", "dict", "(",...
Return a MATCH query where only preferred locations are valid as query start locations.
[ "Return", "a", "MATCH", "query", "where", "only", "preferred", "locations", "are", "valid", "as", "query", "start", "locations", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L219-L308
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
_expose_all_eligible_locations
def _expose_all_eligible_locations(match_query, location_types, eligible_locations): """Return a MATCH query where all eligible locations are valid as query start locations.""" eligible_location_types = dict() new_match_traversals = [] for current_traversal in match_query.match_traversals: new_...
python
def _expose_all_eligible_locations(match_query, location_types, eligible_locations): """Return a MATCH query where all eligible locations are valid as query start locations.""" eligible_location_types = dict() new_match_traversals = [] for current_traversal in match_query.match_traversals: new_...
[ "def", "_expose_all_eligible_locations", "(", "match_query", ",", "location_types", ",", "eligible_locations", ")", ":", "eligible_location_types", "=", "dict", "(", ")", "new_match_traversals", "=", "[", "]", "for", "current_traversal", "in", "match_query", ".", "mat...
Return a MATCH query where all eligible locations are valid as query start locations.
[ "Return", "a", "MATCH", "query", "where", "all", "eligible", "locations", "are", "valid", "as", "query", "start", "locations", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L311-L350
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/workarounds/orientdb_query_execution.py
expose_ideal_query_execution_start_points
def expose_ideal_query_execution_start_points(compound_match_query, location_types, coerced_locations): """Ensure that OrientDB only considers desirable query start points in query planning.""" new_queries = [] for match_query in compound_match_query.match_quer...
python
def expose_ideal_query_execution_start_points(compound_match_query, location_types, coerced_locations): """Ensure that OrientDB only considers desirable query start points in query planning.""" new_queries = [] for match_query in compound_match_query.match_quer...
[ "def", "expose_ideal_query_execution_start_points", "(", "compound_match_query", ",", "location_types", ",", "coerced_locations", ")", ":", "new_queries", "=", "[", "]", "for", "match_query", "in", "compound_match_query", ".", "match_queries", ":", "location_classification"...
Ensure that OrientDB only considers desirable query start points in query planning.
[ "Ensure", "that", "OrientDB", "only", "considers", "desirable", "query", "start", "points", "in", "query", "planning", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_query_execution.py#L353-L384
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/between_lowering.py
_expression_list_to_conjunction
def _expression_list_to_conjunction(expression_list): """Return an Expression that is the `&&` of all the expressions in the given list.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected list. Received {}: ' u'{}'.format(type(expression_list).__nam...
python
def _expression_list_to_conjunction(expression_list): """Return an Expression that is the `&&` of all the expressions in the given list.""" if not isinstance(expression_list, list): raise AssertionError(u'Expected list. Received {}: ' u'{}'.format(type(expression_list).__nam...
[ "def", "_expression_list_to_conjunction", "(", "expression_list", ")", ":", "if", "not", "isinstance", "(", "expression_list", ",", "list", ")", ":", "raise", "AssertionError", "(", "u'Expected list. Received {}: '", "u'{}'", ".", "format", "(", "type", "(", "expres...
Return an Expression that is the `&&` of all the expressions in the given list.
[ "Return", "an", "Expression", "that", "is", "the", "&&", "of", "all", "the", "expressions", "in", "the", "given", "list", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L9-L22
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/between_lowering.py
_extract_conjuction_elements_from_expression
def _extract_conjuction_elements_from_expression(expression): """Return a generator for expressions that are connected by `&&`s in the given expression.""" if isinstance(expression, BinaryComposition) and expression.operator == u'&&': for element in _extract_conjuction_elements_from_expression(expressio...
python
def _extract_conjuction_elements_from_expression(expression): """Return a generator for expressions that are connected by `&&`s in the given expression.""" if isinstance(expression, BinaryComposition) and expression.operator == u'&&': for element in _extract_conjuction_elements_from_expression(expressio...
[ "def", "_extract_conjuction_elements_from_expression", "(", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "BinaryComposition", ")", "and", "expression", ".", "operator", "==", "u'&&'", ":", "for", "element", "in", "_extract_conjuction_elements_from...
Return a generator for expressions that are connected by `&&`s in the given expression.
[ "Return", "a", "generator", "for", "expressions", "that", "are", "connected", "by", "&&", "s", "in", "the", "given", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L25-L33
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/between_lowering.py
_construct_field_operator_expression_dict
def _construct_field_operator_expression_dict(expression_list): """Construct a mapping from local fields to specified operators, and corresponding expressions. Args: expression_list: list of expressions to analyze Returns: local_field_to_expressions: dict mapping local field na...
python
def _construct_field_operator_expression_dict(expression_list): """Construct a mapping from local fields to specified operators, and corresponding expressions. Args: expression_list: list of expressions to analyze Returns: local_field_to_expressions: dict mapping local field na...
[ "def", "_construct_field_operator_expression_dict", "(", "expression_list", ")", ":", "between_operators", "=", "(", "u'<='", ",", "u'>='", ")", "inverse_operator", "=", "{", "u'>='", ":", "u'<='", ",", "u'<='", ":", "u'>='", "}", "local_field_to_expressions", "=", ...
Construct a mapping from local fields to specified operators, and corresponding expressions. Args: expression_list: list of expressions to analyze Returns: local_field_to_expressions: dict mapping local field names to "operator -> list of BinaryComposition" dictionaries, ...
[ "Construct", "a", "mapping", "from", "local", "fields", "to", "specified", "operators", "and", "corresponding", "expressions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L36-L70
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/between_lowering.py
_lower_expressions_to_between
def _lower_expressions_to_between(base_expression): """Return a new expression, with any eligible comparisons lowered to `between` clauses.""" expression_list = list(_extract_conjuction_elements_from_expression(base_expression)) if len(expression_list) == 0: raise AssertionError(u'Received empty exp...
python
def _lower_expressions_to_between(base_expression): """Return a new expression, with any eligible comparisons lowered to `between` clauses.""" expression_list = list(_extract_conjuction_elements_from_expression(base_expression)) if len(expression_list) == 0: raise AssertionError(u'Received empty exp...
[ "def", "_lower_expressions_to_between", "(", "base_expression", ")", ":", "expression_list", "=", "list", "(", "_extract_conjuction_elements_from_expression", "(", "base_expression", ")", ")", "if", "len", "(", "expression_list", ")", "==", "0", ":", "raise", "Asserti...
Return a new expression, with any eligible comparisons lowered to `between` clauses.
[ "Return", "a", "new", "expression", "with", "any", "eligible", "comparisons", "lowered", "to", "between", "clauses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L73-L103
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/between_lowering.py
lower_comparisons_to_between
def lower_comparisons_to_between(match_query): """Return a new MatchQuery, with all eligible comparison filters lowered to between clauses.""" new_match_traversals = [] for current_match_traversal in match_query.match_traversals: new_traversal = [] for step in current_match_traversal: ...
python
def lower_comparisons_to_between(match_query): """Return a new MatchQuery, with all eligible comparison filters lowered to between clauses.""" new_match_traversals = [] for current_match_traversal in match_query.match_traversals: new_traversal = [] for step in current_match_traversal: ...
[ "def", "lower_comparisons_to_between", "(", "match_query", ")", ":", "new_match_traversals", "=", "[", "]", "for", "current_match_traversal", "in", "match_query", ".", "match_traversals", ":", "new_traversal", "=", "[", "]", "for", "step", "in", "current_match_travers...
Return a new MatchQuery, with all eligible comparison filters lowered to between clauses.
[ "Return", "a", "new", "MatchQuery", "with", "all", "eligible", "comparison", "filters", "lowered", "to", "between", "clauses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/between_lowering.py#L106-L122
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/common.py
_ensure_arguments_are_provided
def _ensure_arguments_are_provided(expected_types, arguments): """Ensure that all arguments expected by the query were actually provided.""" # This function only checks that the arguments were specified, # and does not check types. Type checking is done as part of the actual formatting step. expected_ar...
python
def _ensure_arguments_are_provided(expected_types, arguments): """Ensure that all arguments expected by the query were actually provided.""" # This function only checks that the arguments were specified, # and does not check types. Type checking is done as part of the actual formatting step. expected_ar...
[ "def", "_ensure_arguments_are_provided", "(", "expected_types", ",", "arguments", ")", ":", "expected_arg_names", "=", "set", "(", "six", ".", "iterkeys", "(", "expected_types", ")", ")", "provided_arg_names", "=", "set", "(", "six", ".", "iterkeys", "(", "argum...
Ensure that all arguments expected by the query were actually provided.
[ "Ensure", "that", "all", "arguments", "expected", "by", "the", "query", "were", "actually", "provided", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/common.py#L12-L24
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/common.py
insert_arguments_into_query
def insert_arguments_into_query(compilation_result, arguments): """Insert the arguments into the compiled GraphQL query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for every...
python
def insert_arguments_into_query(compilation_result, arguments): """Insert the arguments into the compiled GraphQL query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for every...
[ "def", "insert_arguments_into_query", "(", "compilation_result", ",", "arguments", ")", ":", "_ensure_arguments_are_provided", "(", "compilation_result", ".", "input_metadata", ",", "arguments", ")", "if", "compilation_result", ".", "language", "==", "MATCH_LANGUAGE", ":"...
Insert the arguments into the compiled GraphQL query to form a complete query. Args: compilation_result: a CompilationResult object derived from the GraphQL compiler arguments: dict, mapping argument name to its value, for every parameter the query expects. Returns: string, a query in ...
[ "Insert", "the", "arguments", "into", "the", "compiled", "GraphQL", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/common.py#L31-L51
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
QueryRoot.validate
def validate(self): """Ensure that the QueryRoot block is valid.""" if not (isinstance(self.start_class, set) and all(isinstance(x, six.string_types) for x in self.start_class)): raise TypeError(u'Expected set of string start_class, got: {} {}'.format( type(se...
python
def validate(self): """Ensure that the QueryRoot block is valid.""" if not (isinstance(self.start_class, set) and all(isinstance(x, six.string_types) for x in self.start_class)): raise TypeError(u'Expected set of string start_class, got: {} {}'.format( type(se...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "(", "isinstance", "(", "self", ".", "start_class", ",", "set", ")", "and", "all", "(", "isinstance", "(", "x", ",", "six", ".", "string_types", ")", "for", "x", "in", "self", ".", "start_class",...
Ensure that the QueryRoot block is valid.
[ "Ensure", "that", "the", "QueryRoot", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L34-L42
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
CoerceType.validate
def validate(self): """Ensure that the CoerceType block is valid.""" if not (isinstance(self.target_class, set) and all(isinstance(x, six.string_types) for x in self.target_class)): raise TypeError(u'Expected set of string target_class, got: {} {}'.format( typ...
python
def validate(self): """Ensure that the CoerceType block is valid.""" if not (isinstance(self.target_class, set) and all(isinstance(x, six.string_types) for x in self.target_class)): raise TypeError(u'Expected set of string target_class, got: {} {}'.format( typ...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "(", "isinstance", "(", "self", ".", "target_class", ",", "set", ")", "and", "all", "(", "isinstance", "(", "x", ",", "six", ".", "string_types", ")", "for", "x", "in", "self", ".", "target_class...
Ensure that the CoerceType block is valid.
[ "Ensure", "that", "the", "CoerceType", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L79-L87
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
ConstructResult.validate
def validate(self): """Ensure that the ConstructResult block is valid.""" if not isinstance(self.fields, dict): raise TypeError(u'Expected dict fields, got: {} {}'.format( type(self.fields).__name__, self.fields)) for key, value in six.iteritems(self.fields): ...
python
def validate(self): """Ensure that the ConstructResult block is valid.""" if not isinstance(self.fields, dict): raise TypeError(u'Expected dict fields, got: {} {}'.format( type(self.fields).__name__, self.fields)) for key, value in six.iteritems(self.fields): ...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fields", ",", "dict", ")", ":", "raise", "TypeError", "(", "u'Expected dict fields, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "fields", ")", ".", "_...
Ensure that the ConstructResult block is valid.
[ "Ensure", "that", "the", "ConstructResult", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L120-L131
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
Filter.validate
def validate(self): """Ensure that the Filter block is valid.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate))
python
def validate(self): """Ensure that the Filter block is valid.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate))
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "predicate", ",", "Expression", ")", ":", "raise", "TypeError", "(", "u'Expected Expression predicate, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "predicate...
Ensure that the Filter block is valid.
[ "Ensure", "that", "the", "Filter", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L174-L178
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
Backtrack.validate
def validate(self): """Ensure that the Backtrack block is valid.""" validate_marked_location(self.location) if not isinstance(self.optional, bool): raise TypeError(u'Expected bool optional, got: {} {}'.format( type(self.optional).__name__, self.optional))
python
def validate(self): """Ensure that the Backtrack block is valid.""" validate_marked_location(self.location) if not isinstance(self.optional, bool): raise TypeError(u'Expected bool optional, got: {} {}'.format( type(self.optional).__name__, self.optional))
[ "def", "validate", "(", "self", ")", ":", "validate_marked_location", "(", "self", ".", "location", ")", "if", "not", "isinstance", "(", "self", ".", "optional", ",", "bool", ")", ":", "raise", "TypeError", "(", "u'Expected bool optional, got: {} {}'", ".", "f...
Ensure that the Backtrack block is valid.
[ "Ensure", "that", "the", "Backtrack", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L395-L400
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
Backtrack.to_gremlin
def to_gremlin(self): """Return a unicode object with the Gremlin representation of this BasicBlock.""" self.validate() if self.optional: operation = u'optional' else: operation = u'back' mark_name, _ = self.location.get_location_name() return u'...
python
def to_gremlin(self): """Return a unicode object with the Gremlin representation of this BasicBlock.""" self.validate() if self.optional: operation = u'optional' else: operation = u'back' mark_name, _ = self.location.get_location_name() return u'...
[ "def", "to_gremlin", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "if", "self", ".", "optional", ":", "operation", "=", "u'optional'", "else", ":", "operation", "=", "u'back'", "mark_name", ",", "_", "=", "self", ".", "location", ".", "get...
Return a unicode object with the Gremlin representation of this BasicBlock.
[ "Return", "a", "unicode", "object", "with", "the", "Gremlin", "representation", "of", "this", "BasicBlock", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L402-L414
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/blocks.py
Fold.validate
def validate(self): """Ensure the Fold block is valid.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected a FoldScopeLocation for fold_scope_location, got: {} ' u'{}'.format(type(self.fold_scope_location), self.fold_scope...
python
def validate(self): """Ensure the Fold block is valid.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected a FoldScopeLocation for fold_scope_location, got: {} ' u'{}'.format(type(self.fold_scope_location), self.fold_scope...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected a FoldScopeLocation for fold_scope_location, got: {} '", "u'{}'", ".", "format", "(...
Ensure the Fold block is valid.
[ "Ensure", "the", "Fold", "block", "is", "valid", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/blocks.py#L446-L450
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
lower_ir
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR blocks into a form that can be represented by a SQL query. Args: ir_blocks: list of IR blocks to lower into SQL-compatible form query_metadata_table: QueryMetadataTable object containing all metadata col...
python
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR blocks into a form that can be represented by a SQL query. Args: ir_blocks: list of IR blocks to lower into SQL-compatible form query_metadata_table: QueryMetadataTable object containing all metadata col...
[ "def", "lower_ir", "(", "ir_blocks", ",", "query_metadata_table", ",", "type_equivalence_hints", "=", "None", ")", ":", "_validate_all_blocks_supported", "(", "ir_blocks", ",", "query_metadata_table", ")", "construct_result", "=", "_get_construct_result", "(", "ir_blocks"...
Lower the IR blocks into a form that can be represented by a SQL query. Args: ir_blocks: list of IR blocks to lower into SQL-compatible form query_metadata_table: QueryMetadataTable object containing all metadata collected during query processing, including location me...
[ "Lower", "the", "IR", "blocks", "into", "a", "form", "that", "can", "be", "represented", "by", "a", "SQL", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L17-L81
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_validate_all_blocks_supported
def _validate_all_blocks_supported(ir_blocks, query_metadata_table): """Validate that all IR blocks and ConstructResult fields passed to the backend are supported. Args: ir_blocks: List[BasicBlock], IR blocks to validate. query_metadata_table: QueryMetadataTable, object containing all metadata ...
python
def _validate_all_blocks_supported(ir_blocks, query_metadata_table): """Validate that all IR blocks and ConstructResult fields passed to the backend are supported. Args: ir_blocks: List[BasicBlock], IR blocks to validate. query_metadata_table: QueryMetadataTable, object containing all metadata ...
[ "def", "_validate_all_blocks_supported", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "if", "len", "(", "ir_blocks", ")", "<", "3", ":", "raise", "AssertionError", "(", "u'Unexpectedly attempting to validate IR blocks with fewer than 3 blocks. A minimal '", "u'que...
Validate that all IR blocks and ConstructResult fields passed to the backend are supported. Args: ir_blocks: List[BasicBlock], IR blocks to validate. query_metadata_table: QueryMetadataTable, object containing all metadata collected during query processing, including l...
[ "Validate", "that", "all", "IR", "blocks", "and", "ConstructResult", "fields", "passed", "to", "the", "backend", "are", "supported", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L84-L121
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_get_construct_result
def _get_construct_result(ir_blocks): """Return the ConstructResult block from a list of IR blocks.""" last_block = ir_blocks[-1] if not isinstance(last_block, blocks.ConstructResult): raise AssertionError( u'The last IR block {} for IR blocks {} was unexpectedly not ' u'a Co...
python
def _get_construct_result(ir_blocks): """Return the ConstructResult block from a list of IR blocks.""" last_block = ir_blocks[-1] if not isinstance(last_block, blocks.ConstructResult): raise AssertionError( u'The last IR block {} for IR blocks {} was unexpectedly not ' u'a Co...
[ "def", "_get_construct_result", "(", "ir_blocks", ")", ":", "last_block", "=", "ir_blocks", "[", "-", "1", "]", "if", "not", "isinstance", "(", "last_block", ",", "blocks", ".", "ConstructResult", ")", ":", "raise", "AssertionError", "(", "u'The last IR block {}...
Return the ConstructResult block from a list of IR blocks.
[ "Return", "the", "ConstructResult", "block", "from", "a", "list", "of", "IR", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L124-L131
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_map_query_path_to_location_info
def _map_query_path_to_location_info(query_metadata_table): """Create a map from each query path to a LocationInfo at that path. Args: query_metadata_table: QueryMetadataTable, object containing all metadata collected during query processing, including location metadata (e...
python
def _map_query_path_to_location_info(query_metadata_table): """Create a map from each query path to a LocationInfo at that path. Args: query_metadata_table: QueryMetadataTable, object containing all metadata collected during query processing, including location metadata (e...
[ "def", "_map_query_path_to_location_info", "(", "query_metadata_table", ")", ":", "query_path_to_location_info", "=", "{", "}", "for", "location", ",", "location_info", "in", "query_metadata_table", ".", "registered_locations", ":", "if", "not", "isinstance", "(", "loca...
Create a map from each query path to a LocationInfo at that path. Args: query_metadata_table: QueryMetadataTable, object containing all metadata collected during query processing, including location metadata (e.g. which locations are folded or opt...
[ "Create", "a", "map", "from", "each", "query", "path", "to", "a", "LocationInfo", "at", "that", "path", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L134-L161
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_location_infos_equal
def _location_infos_equal(left, right): """Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise. LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth, recursive scopes depth, types and parent query paths are equal. Args: ...
python
def _location_infos_equal(left, right): """Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise. LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth, recursive scopes depth, types and parent query paths are equal. Args: ...
[ "def", "_location_infos_equal", "(", "left", ",", "right", ")", ":", "if", "not", "isinstance", "(", "left", ",", "LocationInfo", ")", "or", "not", "isinstance", "(", "right", ",", "LocationInfo", ")", ":", "raise", "AssertionError", "(", "u'Unsupported Locati...
Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise. LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth, recursive scopes depth, types and parent query paths are equal. Args: left: LocationInfo, left location info object ...
[ "Return", "True", "if", "LocationInfo", "objects", "are", "equivalent", "for", "the", "SQL", "backend", "False", "otherwise", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L164-L196
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_map_query_path_to_outputs
def _map_query_path_to_outputs(construct_result, query_path_to_location_info): """Assign the output fields of a ConstructResult block to their respective query_path.""" query_path_to_output_fields = {} for output_name, field in six.iteritems(construct_result.fields): field_name = field.location.fiel...
python
def _map_query_path_to_outputs(construct_result, query_path_to_location_info): """Assign the output fields of a ConstructResult block to their respective query_path.""" query_path_to_output_fields = {} for output_name, field in six.iteritems(construct_result.fields): field_name = field.location.fiel...
[ "def", "_map_query_path_to_outputs", "(", "construct_result", ",", "query_path_to_location_info", ")", ":", "query_path_to_output_fields", "=", "{", "}", "for", "output_name", ",", "field", "in", "six", ".", "iteritems", "(", "construct_result", ".", "fields", ")", ...
Assign the output fields of a ConstructResult block to their respective query_path.
[ "Assign", "the", "output", "fields", "of", "a", "ConstructResult", "block", "to", "their", "respective", "query_path", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L199-L211
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
_map_block_index_to_location
def _map_block_index_to_location(ir_blocks): """Associate each IR block with its corresponding location, by index.""" block_index_to_location = {} # MarkLocation blocks occur after the blocks related to that location. # The core approach here is to buffer blocks until their MarkLocation is encountered ...
python
def _map_block_index_to_location(ir_blocks): """Associate each IR block with its corresponding location, by index.""" block_index_to_location = {} # MarkLocation blocks occur after the blocks related to that location. # The core approach here is to buffer blocks until their MarkLocation is encountered ...
[ "def", "_map_block_index_to_location", "(", "ir_blocks", ")", ":", "block_index_to_location", "=", "{", "}", "current_block_ixs", "=", "[", "]", "for", "num", ",", "ir_block", "in", "enumerate", "(", "ir_blocks", ")", ":", "if", "isinstance", "(", "ir_block", ...
Associate each IR block with its corresponding location, by index.
[ "Associate", "each", "IR", "block", "with", "its", "corresponding", "location", "by", "index", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L214-L234
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
lower_unary_transformations
def lower_unary_transformations(ir_blocks): """Raise exception if any unary transformation block encountered.""" def visitor_fn(expression): """Raise error if current expression is a UnaryTransformation.""" if not isinstance(expression, expressions.UnaryTransformation): return expres...
python
def lower_unary_transformations(ir_blocks): """Raise exception if any unary transformation block encountered.""" def visitor_fn(expression): """Raise error if current expression is a UnaryTransformation.""" if not isinstance(expression, expressions.UnaryTransformation): return expres...
[ "def", "lower_unary_transformations", "(", "ir_blocks", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "if", "not", "isinstance", "(", "expression", ",", "expressions", ".", "UnaryTransformation", ")", ":", "return", "expression", "raise", "NotImpleme...
Raise exception if any unary transformation block encountered.
[ "Raise", "exception", "if", "any", "unary", "transformation", "block", "encountered", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L237-L252
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_sql/__init__.py
lower_unsupported_metafield_expressions
def lower_unsupported_metafield_expressions(ir_blocks): """Raise exception if an unsupported metafield is encountered in any LocalField expression.""" def visitor_fn(expression): """Visitor function raising exception for any unsupported metafield.""" if not isinstance(expression, expressions.Loc...
python
def lower_unsupported_metafield_expressions(ir_blocks): """Raise exception if an unsupported metafield is encountered in any LocalField expression.""" def visitor_fn(expression): """Visitor function raising exception for any unsupported metafield.""" if not isinstance(expression, expressions.Loc...
[ "def", "lower_unsupported_metafield_expressions", "(", "ir_blocks", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "if", "not", "isinstance", "(", "expression", ",", "expressions", ".", "LocalField", ")", ":", "return", "expression", "if", "expression...
Raise exception if an unsupported metafield is encountered in any LocalField expression.
[ "Raise", "exception", "if", "an", "unsupported", "metafield", "is", "encountered", "in", "any", "LocalField", "expression", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_sql/__init__.py#L255-L272
train
kensho-technologies/graphql-compiler
graphql_compiler/__init__.py
get_graphql_schema_from_orientdb_schema_data
def get_graphql_schema_from_orientdb_schema_data(schema_data, class_to_field_type_overrides=None, hidden_classes=None): """Construct a GraphQL schema from an OrientDB schema. Args: schema_data: list of dicts describing the classes in the OrientDB schema....
python
def get_graphql_schema_from_orientdb_schema_data(schema_data, class_to_field_type_overrides=None, hidden_classes=None): """Construct a GraphQL schema from an OrientDB schema. Args: schema_data: list of dicts describing the classes in the OrientDB schema....
[ "def", "get_graphql_schema_from_orientdb_schema_data", "(", "schema_data", ",", "class_to_field_type_overrides", "=", "None", ",", "hidden_classes", "=", "None", ")", ":", "if", "class_to_field_type_overrides", "is", "None", ":", "class_to_field_type_overrides", "=", "dict"...
Construct a GraphQL schema from an OrientDB schema. Args: schema_data: list of dicts describing the classes in the OrientDB schema. The following format is the way the data is structured in OrientDB 2. See the README.md file for an example of how to query this data...
[ "Construct", "a", "GraphQL", "schema", "from", "an", "OrientDB", "schema", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/__init__.py#L139-L199
train
slackapi/python-slack-events-api
slackeventsapi/__init__.py
SlackEventAdapter.start
def start(self, host='127.0.0.1', port=None, debug=False, **kwargs): """ Start the built in webserver, bound to the host and port you'd like. Default host is `127.0.0.1` and port 8080. :param host: The host you want to bind the build in webserver to :param port: The port number ...
python
def start(self, host='127.0.0.1', port=None, debug=False, **kwargs): """ Start the built in webserver, bound to the host and port you'd like. Default host is `127.0.0.1` and port 8080. :param host: The host you want to bind the build in webserver to :param port: The port number ...
[ "def", "start", "(", "self", ",", "host", "=", "'127.0.0.1'", ",", "port", "=", "None", ",", "debug", "=", "False", ",", "**", "kwargs", ")", ":", "self", ".", "server", ".", "run", "(", "host", "=", "host", ",", "port", "=", "port", ",", "debug"...
Start the built in webserver, bound to the host and port you'd like. Default host is `127.0.0.1` and port 8080. :param host: The host you want to bind the build in webserver to :param port: The port number you want the webserver to run on :param debug: Set to `True` to enable debug leve...
[ "Start", "the", "built", "in", "webserver", "bound", "to", "the", "host", "and", "port", "you", "d", "like", ".", "Default", "host", "is", "127", ".", "0", ".", "0", ".", "1", "and", "port", "8080", "." ]
1254d83181eb939f124a0e4746dafea7e14047c1
https://github.com/slackapi/python-slack-events-api/blob/1254d83181eb939f124a0e4746dafea7e14047c1/slackeventsapi/__init__.py#L13-L23
train
apragacz/django-rest-registration
rest_registration/api/views/login.py
login
def login(request): ''' Logs in the user via given login and password. ''' serializer_class = registration_settings.LOGIN_SERIALIZER_CLASS serializer = serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.get_authenticated_user() if not user: ...
python
def login(request): ''' Logs in the user via given login and password. ''' serializer_class = registration_settings.LOGIN_SERIALIZER_CLASS serializer = serializer_class(data=request.data) serializer.is_valid(raise_exception=True) user = serializer.get_authenticated_user() if not user: ...
[ "def", "login", "(", "request", ")", ":", "serializer_class", "=", "registration_settings", ".", "LOGIN_SERIALIZER_CLASS", "serializer", "=", "serializer_class", "(", "data", "=", "request", ".", "data", ")", "serializer", ".", "is_valid", "(", "raise_exception", ...
Logs in the user via given login and password.
[ "Logs", "in", "the", "user", "via", "given", "login", "and", "password", "." ]
7373571264dd567c2a73a97ff4c45b64f113605b
https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/login.py#L25-L39
train
apragacz/django-rest-registration
rest_registration/api/views/login.py
logout
def logout(request): ''' Logs out the user. returns an error if the user is not authenticated. ''' user = request.user serializer = LogoutSerializer(data=request.data) serializer.is_valid(raise_exception=True) data = serializer.validated_data if should_authenticate_session(): ...
python
def logout(request): ''' Logs out the user. returns an error if the user is not authenticated. ''' user = request.user serializer = LogoutSerializer(data=request.data) serializer.is_valid(raise_exception=True) data = serializer.validated_data if should_authenticate_session(): ...
[ "def", "logout", "(", "request", ")", ":", "user", "=", "request", ".", "user", "serializer", "=", "LogoutSerializer", "(", "data", "=", "request", ".", "data", ")", "serializer", ".", "is_valid", "(", "raise_exception", "=", "True", ")", "data", "=", "s...
Logs out the user. returns an error if the user is not authenticated.
[ "Logs", "out", "the", "user", ".", "returns", "an", "error", "if", "the", "user", "is", "not", "authenticated", "." ]
7373571264dd567c2a73a97ff4c45b64f113605b
https://github.com/apragacz/django-rest-registration/blob/7373571264dd567c2a73a97ff4c45b64f113605b/rest_registration/api/views/login.py#L49-L67
train