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/gremlin_formatting.py
insert_arguments_into_gremlin_query
def insert_arguments_into_gremlin_query(compilation_result, arguments): """Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $...
python
def insert_arguments_into_gremlin_query(compilation_result, arguments): """Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $...
[ "def", "insert_arguments_into_gremlin_query", "(", "compilation_result", ",", "arguments", ")", ":", "if", "compilation_result", ".", "language", "!=", "GREMLIN_LANGUAGE", ":", "raise", "AssertionError", "(", "u'Unexpected query output language: {}'", ".", "format", "(", ...
Insert the arguments into the compiled Gremlin query to form a complete query. The GraphQL compiler attempts to use single-quoted string literals ('abc') in Gremlin output. Double-quoted strings allow inline interpolation with the $ symbol, see here for details: http://www.groovy-lang.org/syntax.html#all-s...
[ "Insert", "the", "arguments", "into", "the", "compiled", "Gremlin", "query", "to", "form", "a", "complete", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L138-L167
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_get_vertex_location_name
def _get_vertex_location_name(location): """Get the location name from a location that is expected to point to a vertex.""" mark_name, field_name = location.get_location_name() if field_name is not None: raise AssertionError(u'Location unexpectedly pointed to a field: {}'.format(location)) retu...
python
def _get_vertex_location_name(location): """Get the location name from a location that is expected to point to a vertex.""" mark_name, field_name = location.get_location_name() if field_name is not None: raise AssertionError(u'Location unexpectedly pointed to a field: {}'.format(location)) retu...
[ "def", "_get_vertex_location_name", "(", "location", ")", ":", "mark_name", ",", "field_name", "=", "location", ".", "get_location_name", "(", ")", "if", "field_name", "is", "not", "None", ":", "raise", "AssertionError", "(", "u'Location unexpectedly pointed to a fiel...
Get the location name from a location that is expected to point to a vertex.
[ "Get", "the", "location", "name", "from", "a", "location", "that", "is", "expected", "to", "point", "to", "a", "vertex", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L12-L18
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_first_step_to_match
def _first_step_to_match(match_step): """Transform the very first MATCH step into a MATCH query string.""" parts = [] if match_step.root_block is not None: if not isinstance(match_step.root_block, QueryRoot): raise AssertionError(u'Expected None or QueryRoot root block, received: ' ...
python
def _first_step_to_match(match_step): """Transform the very first MATCH step into a MATCH query string.""" parts = [] if match_step.root_block is not None: if not isinstance(match_step.root_block, QueryRoot): raise AssertionError(u'Expected None or QueryRoot root block, received: ' ...
[ "def", "_first_step_to_match", "(", "match_step", ")", ":", "parts", "=", "[", "]", "if", "match_step", ".", "root_block", "is", "not", "None", ":", "if", "not", "isinstance", "(", "match_step", ".", "root_block", ",", "QueryRoot", ")", ":", "raise", "Asse...
Transform the very first MATCH step into a MATCH query string.
[ "Transform", "the", "very", "first", "MATCH", "step", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L21-L50
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_represent_match_traversal
def _represent_match_traversal(match_traversal): """Emit MATCH query code for an entire MATCH traversal sequence.""" output = [] output.append(_first_step_to_match(match_traversal[0])) for step in match_traversal[1:]: output.append(_subsequent_step_to_match(step)) return u''.join(output)
python
def _represent_match_traversal(match_traversal): """Emit MATCH query code for an entire MATCH traversal sequence.""" output = [] output.append(_first_step_to_match(match_traversal[0])) for step in match_traversal[1:]: output.append(_subsequent_step_to_match(step)) return u''.join(output)
[ "def", "_represent_match_traversal", "(", "match_traversal", ")", ":", "output", "=", "[", "]", "output", ".", "append", "(", "_first_step_to_match", "(", "match_traversal", "[", "0", "]", ")", ")", "for", "step", "in", "match_traversal", "[", "1", ":", "]",...
Emit MATCH query code for an entire MATCH traversal sequence.
[ "Emit", "MATCH", "query", "code", "for", "an", "entire", "MATCH", "traversal", "sequence", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L94-L102
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_represent_fold
def _represent_fold(fold_location, fold_ir_blocks): """Emit a LET clause corresponding to the IR blocks for a @fold scope.""" start_let_template = u'$%(mark_name)s = %(base_location)s' traverse_edge_template = u'.%(direction)s("%(edge_name)s")' base_template = start_let_template + traverse_edge_template...
python
def _represent_fold(fold_location, fold_ir_blocks): """Emit a LET clause corresponding to the IR blocks for a @fold scope.""" start_let_template = u'$%(mark_name)s = %(base_location)s' traverse_edge_template = u'.%(direction)s("%(edge_name)s")' base_template = start_let_template + traverse_edge_template...
[ "def", "_represent_fold", "(", "fold_location", ",", "fold_ir_blocks", ")", ":", "start_let_template", "=", "u'$%(mark_name)s = %(base_location)s'", "traverse_edge_template", "=", "u'.%(direction)s(\"%(edge_name)s\")'", "base_template", "=", "start_let_template", "+", "traverse_e...
Emit a LET clause corresponding to the IR blocks for a @fold scope.
[ "Emit", "a", "LET", "clause", "corresponding", "to", "the", "IR", "blocks", "for", "a" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L105-L147
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_construct_output_to_match
def _construct_output_to_match(output_block): """Transform a ConstructResult block into a MATCH query string.""" output_block.validate() selections = ( u'%s AS `%s`' % (output_block.fields[key].to_match(), key) for key in sorted(output_block.fields.keys()) # Sort keys for deterministic out...
python
def _construct_output_to_match(output_block): """Transform a ConstructResult block into a MATCH query string.""" output_block.validate() selections = ( u'%s AS `%s`' % (output_block.fields[key].to_match(), key) for key in sorted(output_block.fields.keys()) # Sort keys for deterministic out...
[ "def", "_construct_output_to_match", "(", "output_block", ")", ":", "output_block", ".", "validate", "(", ")", "selections", "=", "(", "u'%s AS `%s`'", "%", "(", "output_block", ".", "fields", "[", "key", "]", ".", "to_match", "(", ")", ",", "key", ")", "f...
Transform a ConstructResult block into a MATCH query string.
[ "Transform", "a", "ConstructResult", "block", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L150-L159
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
_construct_where_to_match
def _construct_where_to_match(where_block): """Transform a Filter block into a MATCH query string.""" if where_block.predicate == TrueLiteral: raise AssertionError(u'Received WHERE block with TrueLiteral predicate: {}' .format(where_block)) return u'WHERE ' + where_block...
python
def _construct_where_to_match(where_block): """Transform a Filter block into a MATCH query string.""" if where_block.predicate == TrueLiteral: raise AssertionError(u'Received WHERE block with TrueLiteral predicate: {}' .format(where_block)) return u'WHERE ' + where_block...
[ "def", "_construct_where_to_match", "(", "where_block", ")", ":", "if", "where_block", ".", "predicate", "==", "TrueLiteral", ":", "raise", "AssertionError", "(", "u'Received WHERE block with TrueLiteral predicate: {}'", ".", "format", "(", "where_block", ")", ")", "ret...
Transform a Filter block into a MATCH query string.
[ "Transform", "a", "Filter", "block", "into", "a", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L162-L167
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
emit_code_from_multiple_match_queries
def emit_code_from_multiple_match_queries(match_queries): """Return a MATCH query string from a list of MatchQuery namedtuples.""" optional_variable_base_name = '$optional__' union_variable_name = '$result' query_data = deque([u'SELECT EXPAND(', union_variable_name, u')', u' LET ']) optional_variab...
python
def emit_code_from_multiple_match_queries(match_queries): """Return a MATCH query string from a list of MatchQuery namedtuples.""" optional_variable_base_name = '$optional__' union_variable_name = '$result' query_data = deque([u'SELECT EXPAND(', union_variable_name, u')', u' LET ']) optional_variab...
[ "def", "emit_code_from_multiple_match_queries", "(", "match_queries", ")", ":", "optional_variable_base_name", "=", "'$optional__'", "union_variable_name", "=", "'$result'", "query_data", "=", "deque", "(", "[", "u'SELECT EXPAND('", ",", "union_variable_name", ",", "u')'", ...
Return a MATCH query string from a list of MatchQuery namedtuples.
[ "Return", "a", "MATCH", "query", "string", "from", "a", "list", "of", "MatchQuery", "namedtuples", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L218-L241
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/emit_match.py
emit_code_from_ir
def emit_code_from_ir(compound_match_query, compiler_metadata): """Return a MATCH query string from a CompoundMatchQuery.""" # If the compound match query contains only one match query, # just call `emit_code_from_single_match_query` # If there are multiple match queries, construct the query string for ...
python
def emit_code_from_ir(compound_match_query, compiler_metadata): """Return a MATCH query string from a CompoundMatchQuery.""" # If the compound match query contains only one match query, # just call `emit_code_from_single_match_query` # If there are multiple match queries, construct the query string for ...
[ "def", "emit_code_from_ir", "(", "compound_match_query", ",", "compiler_metadata", ")", ":", "match_queries", "=", "compound_match_query", ".", "match_queries", "if", "len", "(", "match_queries", ")", "==", "1", ":", "query_string", "=", "emit_code_from_single_match_que...
Return a MATCH query string from a CompoundMatchQuery.
[ "Return", "a", "MATCH", "query", "string", "from", "a", "CompoundMatchQuery", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/emit_match.py#L244-L276
train
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_serialize_date
def _serialize_date(value): """Serialize a Date object to its proper ISO-8601 representation.""" if not isinstance(value, date): raise ValueError(u'The received object was not a date: ' u'{} {}'.format(type(value), value)) return value.isoformat()
python
def _serialize_date(value): """Serialize a Date object to its proper ISO-8601 representation.""" if not isinstance(value, date): raise ValueError(u'The received object was not a date: ' u'{} {}'.format(type(value), value)) return value.isoformat()
[ "def", "_serialize_date", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "date", ")", ":", "raise", "ValueError", "(", "u'The received object was not a date: '", "u'{} {}'", ".", "format", "(", "type", "(", "value", ")", ",", "value", ...
Serialize a Date object to its proper ISO-8601 representation.
[ "Serialize", "a", "Date", "object", "to", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L201-L206
train
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_serialize_datetime
def _serialize_datetime(value): """Serialize a DateTime object to its proper ISO-8601 representation.""" if not isinstance(value, (datetime, arrow.Arrow)): raise ValueError(u'The received object was not a datetime: ' u'{} {}'.format(type(value), value)) return value.isoforma...
python
def _serialize_datetime(value): """Serialize a DateTime object to its proper ISO-8601 representation.""" if not isinstance(value, (datetime, arrow.Arrow)): raise ValueError(u'The received object was not a datetime: ' u'{} {}'.format(type(value), value)) return value.isoforma...
[ "def", "_serialize_datetime", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "datetime", ",", "arrow", ".", "Arrow", ")", ")", ":", "raise", "ValueError", "(", "u'The received object was not a datetime: '", "u'{} {}'", ".", "format", ...
Serialize a DateTime object to its proper ISO-8601 representation.
[ "Serialize", "a", "DateTime", "object", "to", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L214-L219
train
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
_parse_datetime_value
def _parse_datetime_value(value): """Deserialize a DateTime object from its proper ISO-8601 representation.""" if value.endswith('Z'): # Arrow doesn't support the "Z" literal to denote UTC time. # Strip the "Z" and add an explicit time zone instead. value = value[:-1] + '+00:00' ret...
python
def _parse_datetime_value(value): """Deserialize a DateTime object from its proper ISO-8601 representation.""" if value.endswith('Z'): # Arrow doesn't support the "Z" literal to denote UTC time. # Strip the "Z" and add an explicit time zone instead. value = value[:-1] + '+00:00' ret...
[ "def", "_parse_datetime_value", "(", "value", ")", ":", "if", "value", ".", "endswith", "(", "'Z'", ")", ":", "value", "=", "value", "[", ":", "-", "1", "]", "+", "'+00:00'", "return", "arrow", ".", "get", "(", "value", ",", "'YYYY-MM-DDTHH:mm:ssZ'", "...
Deserialize a DateTime object from its proper ISO-8601 representation.
[ "Deserialize", "a", "DateTime", "object", "from", "its", "proper", "ISO", "-", "8601", "representation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L222-L229
train
kensho-technologies/graphql-compiler
graphql_compiler/schema.py
insert_meta_fields_into_existing_schema
def insert_meta_fields_into_existing_schema(graphql_schema): """Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the s...
python
def insert_meta_fields_into_existing_schema(graphql_schema): """Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the s...
[ "def", "insert_meta_fields_into_existing_schema", "(", "graphql_schema", ")", ":", "root_type_name", "=", "graphql_schema", ".", "get_query_type", "(", ")", ".", "name", "for", "type_name", ",", "type_obj", "in", "six", ".", "iteritems", "(", "graphql_schema", ".", ...
Add compiler-specific meta-fields into all interfaces and types of the specified schema. It is preferable to use the EXTENDED_META_FIELD_DEFINITIONS constant above to directly inject the meta-fields during the initial process of building the schema, as that approach is more robust. This function does its b...
[ "Add", "compiler", "-", "specific", "meta", "-", "fields", "into", "all", "interfaces", "and", "types", "of", "the", "specified", "schema", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema.py#L302-L338
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/context_helpers.py
validate_context_for_visiting_vertex_field
def validate_context_for_visiting_vertex_field(parent_location, vertex_field_name, context): """Ensure that the current context allows for visiting a vertex field.""" if is_in_fold_innermost_scope(context): raise GraphQLCompilationError( u'Traversing inside a @fold block after filtering on {...
python
def validate_context_for_visiting_vertex_field(parent_location, vertex_field_name, context): """Ensure that the current context allows for visiting a vertex field.""" if is_in_fold_innermost_scope(context): raise GraphQLCompilationError( u'Traversing inside a @fold block after filtering on {...
[ "def", "validate_context_for_visiting_vertex_field", "(", "parent_location", ",", "vertex_field_name", ",", "context", ")", ":", "if", "is_in_fold_innermost_scope", "(", "context", ")", ":", "raise", "GraphQLCompilationError", "(", "u'Traversing inside a @fold block after filte...
Ensure that the current context allows for visiting a vertex field.
[ "Ensure", "that", "the", "current", "context", "allows", "for", "visiting", "a", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/context_helpers.py#L95-L101
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
pretty_print_graphql
def pretty_print_graphql(query, use_four_spaces=True): """Take a GraphQL query, pretty print it, and return it.""" # Use our custom visitor, which fixes directive argument order # to get the canonical representation output = visit(parse(query), CustomPrintingVisitor()) # Using four spaces for inden...
python
def pretty_print_graphql(query, use_four_spaces=True): """Take a GraphQL query, pretty print it, and return it.""" # Use our custom visitor, which fixes directive argument order # to get the canonical representation output = visit(parse(query), CustomPrintingVisitor()) # Using four spaces for inden...
[ "def", "pretty_print_graphql", "(", "query", ",", "use_four_spaces", "=", "True", ")", ":", "output", "=", "visit", "(", "parse", "(", "query", ")", ",", "CustomPrintingVisitor", "(", ")", ")", "if", "use_four_spaces", ":", "return", "fix_indentation_depth", "...
Take a GraphQL query, pretty print it, and return it.
[ "Take", "a", "GraphQL", "query", "pretty", "print", "it", "and", "return", "it", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L10-L20
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
fix_indentation_depth
def fix_indentation_depth(query): """Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.""" lines = query.split('\n') final_lines = [] for line in lines: consecutive_spaces = 0 for char in line: if char == ' ': consecutive_spaces +=...
python
def fix_indentation_depth(query): """Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.""" lines = query.split('\n') final_lines = [] for line in lines: consecutive_spaces = 0 for char in line: if char == ' ': consecutive_spaces +=...
[ "def", "fix_indentation_depth", "(", "query", ")", ":", "lines", "=", "query", ".", "split", "(", "'\\n'", ")", "final_lines", "=", "[", "]", "for", "line", "in", "lines", ":", "consecutive_spaces", "=", "0", "for", "char", "in", "line", ":", "if", "ch...
Make indentation use 4 spaces, rather than the 2 spaces GraphQL normally uses.
[ "Make", "indentation", "use", "4", "spaces", "rather", "than", "the", "2", "spaces", "GraphQL", "normally", "uses", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L67-L86
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/graphql_formatting.py
CustomPrintingVisitor.leave_Directive
def leave_Directive(self, node, *args): """Call when exiting a directive node in the ast.""" name_to_arg_value = { # Taking [0] is ok here because the GraphQL parser checks for the # existence of ':' in directive arguments. arg.split(':', 1)[0]: arg for ar...
python
def leave_Directive(self, node, *args): """Call when exiting a directive node in the ast.""" name_to_arg_value = { # Taking [0] is ok here because the GraphQL parser checks for the # existence of ':' in directive arguments. arg.split(':', 1)[0]: arg for ar...
[ "def", "leave_Directive", "(", "self", ",", "node", ",", "*", "args", ")", ":", "name_to_arg_value", "=", "{", "arg", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]", ":", "arg", "for", "arg", "in", "node", ".", "arguments", "}", "ordered_ar...
Call when exiting a directive node in the ast.
[ "Call", "when", "exiting", "a", "directive", "node", "in", "the", "ast", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L32-L64
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_lowering_match/__init__.py
lower_ir
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata co...
python
def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None): """Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata co...
[ "def", "lower_ir", "(", "ir_blocks", ",", "query_metadata_table", ",", "type_equivalence_hints", "=", "None", ")", ":", "sanity_check_ir_blocks_from_frontend", "(", "ir_blocks", ",", "query_metadata_table", ")", "location_types", "=", "{", "location", ":", "location_inf...
Lower the IR into an IR form that can be represented in MATCH queries. Args: ir_blocks: list of IR blocks to lower into MATCH-compatible form query_metadata_table: QueryMetadataTable object containing all metadata collected during query processing, including location m...
[ "Lower", "the", "IR", "into", "an", "IR", "form", "that", "can", "be", "represented", "in", "MATCH", "queries", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_match/__init__.py#L31-L128
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/utils.py
toposort_classes
def toposort_classes(classes): """Sort class metadatas so that a superclass is always before the subclass""" def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): """Return a topologically sorted list of this class's dependencies and class itself Args: ...
python
def toposort_classes(classes): """Sort class metadatas so that a superclass is always before the subclass""" def get_class_topolist(class_name, name_to_class, processed_classes, current_trace): """Return a topologically sorted list of this class's dependencies and class itself Args: ...
[ "def", "toposort_classes", "(", "classes", ")", ":", "def", "get_class_topolist", "(", "class_name", ",", "name_to_class", ",", "processed_classes", ",", "current_trace", ")", ":", "if", "class_name", "in", "processed_classes", ":", "return", "[", "]", "if", "cl...
Sort class metadatas so that a superclass is always before the subclass
[ "Sort", "class", "metadatas", "so", "that", "a", "superclass", "is", "always", "before", "the", "subclass" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/utils.py#L11-L63
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/utils.py
_list_superclasses
def _list_superclasses(class_def): """Return a list of the superclasses of the given class""" superclasses = class_def.get('superClasses', []) if superclasses: # Make sure to duplicate the list return list(superclasses) sup = class_def.get('superClass', None) if sup: return ...
python
def _list_superclasses(class_def): """Return a list of the superclasses of the given class""" superclasses = class_def.get('superClasses', []) if superclasses: # Make sure to duplicate the list return list(superclasses) sup = class_def.get('superClass', None) if sup: return ...
[ "def", "_list_superclasses", "(", "class_def", ")", ":", "superclasses", "=", "class_def", ".", "get", "(", "'superClasses'", ",", "[", "]", ")", "if", "superclasses", ":", "return", "list", "(", "superclasses", ")", "sup", "=", "class_def", ".", "get", "(...
Return a list of the superclasses of the given class
[ "Return", "a", "list", "of", "the", "superclasses", "of", "the", "given", "class" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/utils.py#L66-L77
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_construct_location_stack_entry
def _construct_location_stack_entry(location, num_traverses): """Return a LocationStackEntry namedtuple with the specified parameters.""" if not isinstance(num_traverses, int) or num_traverses < 0: raise AssertionError(u'Attempted to create a LocationStackEntry namedtuple with an invalid ' ...
python
def _construct_location_stack_entry(location, num_traverses): """Return a LocationStackEntry namedtuple with the specified parameters.""" if not isinstance(num_traverses, int) or num_traverses < 0: raise AssertionError(u'Attempted to create a LocationStackEntry namedtuple with an invalid ' ...
[ "def", "_construct_location_stack_entry", "(", "location", ",", "num_traverses", ")", ":", "if", "not", "isinstance", "(", "num_traverses", ",", "int", ")", "or", "num_traverses", "<", "0", ":", "raise", "AssertionError", "(", "u'Attempted to create a LocationStackEnt...
Return a LocationStackEntry namedtuple with the specified parameters.
[ "Return", "a", "LocationStackEntry", "namedtuple", "with", "the", "specified", "parameters", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L103-L113
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_fields
def _get_fields(ast): """Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtaine...
python
def _get_fields(ast): """Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtaine...
[ "def", "_get_fields", "(", "ast", ")", ":", "if", "not", "ast", ".", "selection_set", ":", "return", "[", "]", ",", "[", "]", "property_fields", "=", "[", "]", "vertex_fields", "=", "[", "]", "seen_field_names", "=", "set", "(", ")", "switched_to_vertice...
Return a list of vertex fields, and a list of property fields, for the given AST node. Also verifies that all property fields for the AST node appear before all vertex fields, raising GraphQLCompilationError if that is not the case. Args: ast: GraphQL AST node, obtained from the graphql library ...
[ "Return", "a", "list", "of", "vertex", "fields", "and", "a", "list", "of", "property", "fields", "for", "the", "given", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L142-L187
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_inline_fragment
def _get_inline_fragment(ast): """Return the inline fragment at the current AST node, or None if no fragment exists.""" if not ast.selection_set: # There is nothing selected here, so no fragment. return None fragments = [ ast_node for ast_node in ast.selection_set.selections...
python
def _get_inline_fragment(ast): """Return the inline fragment at the current AST node, or None if no fragment exists.""" if not ast.selection_set: # There is nothing selected here, so no fragment. return None fragments = [ ast_node for ast_node in ast.selection_set.selections...
[ "def", "_get_inline_fragment", "(", "ast", ")", ":", "if", "not", "ast", ".", "selection_set", ":", "return", "None", "fragments", "=", "[", "ast_node", "for", "ast_node", "in", "ast", ".", "selection_set", ".", "selections", "if", "isinstance", "(", "ast_no...
Return the inline fragment at the current AST node, or None if no fragment exists.
[ "Return", "the", "inline", "fragment", "at", "the", "current", "AST", "node", "or", "None", "if", "no", "fragment", "exists", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L190-L209
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_process_output_source_directive
def _process_output_source_directive(schema, current_schema_type, ast, location, context, local_unique_directives): """Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library ...
python
def _process_output_source_directive(schema, current_schema_type, ast, location, context, local_unique_directives): """Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library ...
[ "def", "_process_output_source_directive", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ",", "local_unique_directives", ")", ":", "output_source_directive", "=", "local_unique_directives", ".", "get", "(", "'output_source'", ",...
Process the output_source directive, modifying the context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library locati...
[ "Process", "the", "output_source", "directive", "modifying", "the", "context", "as", "appropriate", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L217-L244
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_property_ast
def _compile_property_ast(schema, current_schema_type, ast, location, context, unique_local_directives): """Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library c...
python
def _compile_property_ast(schema, current_schema_type, ast, location, context, unique_local_directives): """Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library c...
[ "def", "_compile_property_ast", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ",", "unique_local_directives", ")", ":", "validate_property_directives", "(", "unique_local_directives", ")", "if", "location", ".", "field", "==",...
Process property directives at this AST node, updating the query context as appropriate. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library....
[ "Process", "property", "directives", "at", "this", "AST", "node", "updating", "the", "query", "context", "as", "appropriate", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L247-L320
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_get_recurse_directive_depth
def _get_recurse_directive_depth(field_name, field_directives): """Validate and return the depth parameter of the recurse directive.""" recurse_directive = field_directives['recurse'] optional_directive = field_directives.get('optional', None) if optional_directive: raise GraphQLCompilationErro...
python
def _get_recurse_directive_depth(field_name, field_directives): """Validate and return the depth parameter of the recurse directive.""" recurse_directive = field_directives['recurse'] optional_directive = field_directives.get('optional', None) if optional_directive: raise GraphQLCompilationErro...
[ "def", "_get_recurse_directive_depth", "(", "field_name", ",", "field_directives", ")", ":", "recurse_directive", "=", "field_directives", "[", "'recurse'", "]", "optional_directive", "=", "field_directives", ".", "get", "(", "'optional'", ",", "None", ")", "if", "o...
Validate and return the depth parameter of the recurse directive.
[ "Validate", "and", "return", "the", "depth", "parameter", "of", "the", "recurse", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L323-L338
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_recurse_directive_types
def _validate_recurse_directive_types(current_schema_type, field_schema_type, context): """Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the...
python
def _validate_recurse_directive_types(current_schema_type, field_schema_type, context): """Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the...
[ "def", "_validate_recurse_directive_types", "(", "current_schema_type", ",", "field_schema_type", ",", "context", ")", ":", "type_hints", "=", "context", "[", "'type_equivalence_hints'", "]", ".", "get", "(", "field_schema_type", ")", "type_hints_inverse", "=", "context...
Perform type checks on the enclosing type and the recursed type for a recurse directive. Args: current_schema_type: GraphQLType, the schema type at the current location field_schema_type: GraphQLType, the schema type at the inner scope context: dict, various per-compilation data (e.g. decla...
[ "Perform", "type", "checks", "on", "the", "enclosing", "type", "and", "the", "recursed", "type", "for", "a", "recurse", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L341-L376
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_fragment_ast
def _compile_fragment_ast(schema, current_schema_type, ast, location, context): """Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the...
python
def _compile_fragment_ast(schema, current_schema_type, ast, location, context): """Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the...
[ "def", "_compile_fragment_ast", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ")", ":", "query_metadata_table", "=", "context", "[", "'metadata'", "]", "coerces_to_type_name", "=", "ast", ".", "type_condition", ".", "name"...
Return a list of basic blocks corresponding to the inline fragment at this AST node. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: GraphQL AST node, obtained from the graphql library. ...
[ "Return", "a", "list", "of", "basic", "blocks", "corresponding", "to", "the", "inline", "fragment", "at", "this", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L583-L626
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_ast_node_to_ir
def _compile_ast_node_to_ir(schema, current_schema_type, ast, location, context): """Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ...
python
def _compile_ast_node_to_ir(schema, current_schema_type, ast, location, context): """Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ...
[ "def", "_compile_ast_node_to_ir", "(", "schema", ",", "current_schema_type", ",", "ast", ",", "location", ",", "context", ")", ":", "basic_blocks", "=", "[", "]", "local_unique_directives", "=", "get_unique_directives", "(", "ast", ")", "fields", "=", "_get_fields...
Compile the given GraphQL AST node into a list of basic blocks. Args: schema: GraphQL schema object, obtained from the graphql library current_schema_type: GraphQLType, the schema type at the current location ast: the current GraphQL AST node, obtained from the graphql library locat...
[ "Compile", "the", "given", "GraphQL", "AST", "node", "into", "a", "list", "of", "basic", "blocks", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L629-L720
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_all_tags_are_used
def _validate_all_tags_are_used(metadata): """Ensure all tags are used in some filter.""" tag_names = set([tag_name for tag_name, _ in metadata.tags]) filter_arg_names = set() for location, _ in metadata.registered_locations: for filter_info in metadata.get_filter_infos(location): fo...
python
def _validate_all_tags_are_used(metadata): """Ensure all tags are used in some filter.""" tag_names = set([tag_name for tag_name, _ in metadata.tags]) filter_arg_names = set() for location, _ in metadata.registered_locations: for filter_info in metadata.get_filter_infos(location): fo...
[ "def", "_validate_all_tags_are_used", "(", "metadata", ")", ":", "tag_names", "=", "set", "(", "[", "tag_name", "for", "tag_name", ",", "_", "in", "metadata", ".", "tags", "]", ")", "filter_arg_names", "=", "set", "(", ")", "for", "location", ",", "_", "...
Ensure all tags are used in some filter.
[ "Ensure", "all", "tags", "are", "used", "in", "some", "filter", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L723-L738
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_compile_output_step
def _compile_output_step(outputs): """Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and th...
python
def _compile_output_step(outputs): """Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and th...
[ "def", "_compile_output_step", "(", "outputs", ")", ":", "if", "not", "outputs", ":", "raise", "GraphQLCompilationError", "(", "u'No fields were selected for output! Please mark at least '", "u'one field with the @output directive.'", ")", "output_fields", "=", "{", "}", "for...
Construct the final ConstructResult basic block that defines the output format of the query. Args: outputs: dict, output name (string) -> output data dict, specifying the location from where to get the data, and whether the data is optional (and therefore may be missing); ...
[ "Construct", "the", "final", "ConstructResult", "basic", "block", "that", "defines", "the", "output", "format", "of", "the", "query", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L866-L912
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
_validate_schema_and_ast
def _validate_schema_and_ast(schema, ast): """Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive...
python
def _validate_schema_and_ast(schema, ast): """Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive...
[ "def", "_validate_schema_and_ast", "(", "schema", ",", "ast", ")", ":", "core_graphql_errors", "=", "validate", "(", "schema", ",", "ast", ")", "unsupported_default_directives", "=", "frozenset", "(", "[", "frozenset", "(", "[", "'include'", ",", "frozenset", "(...
Validate the supplied graphql schema and ast. This method wraps around graphql-core's validation to enforce a stricter requirement of the schema -- all directives supported by the compiler must be declared by the schema, regardless of whether each directive is used in the query or not. Args: s...
[ "Validate", "the", "supplied", "graphql", "schema", "and", "ast", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L922-L996
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/compiler_frontend.py
graphql_to_ir
def graphql_to_ir(schema, graphql_string, type_equivalence_hints=None): """Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compile...
python
def graphql_to_ir(schema, graphql_string, type_equivalence_hints=None): """Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compile...
[ "def", "graphql_to_ir", "(", "schema", ",", "graphql_string", ",", "type_equivalence_hints", "=", "None", ")", ":", "graphql_string", "=", "_preprocess_graphql_string", "(", "graphql_string", ")", "try", ":", "ast", "=", "parse", "(", "graphql_string", ")", "excep...
Convert the given GraphQL string into compiler IR, using the given schema object. Args: schema: GraphQL schema object, created using the GraphQL library graphql_string: string containing the GraphQL to compile to compiler IR type_equivalence_hints: optional dict of GraphQL interface or type...
[ "Convert", "the", "given", "GraphQL", "string", "into", "compiler", "IR", "using", "the", "given", "schema", "object", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L1003-L1059
train
kensho-technologies/graphql-compiler
graphql_compiler/debugging_utils.py
pretty_print_gremlin
def pretty_print_gremlin(gremlin): """Return a human-readable representation of a gremlin command string.""" gremlin = remove_custom_formatting(gremlin) too_many_parts = re.split(r'([)}]|scatter)[ ]?\.', gremlin) # Put the ) and } back on. parts = [ too_many_parts[i] + too_many_parts[i + 1]...
python
def pretty_print_gremlin(gremlin): """Return a human-readable representation of a gremlin command string.""" gremlin = remove_custom_formatting(gremlin) too_many_parts = re.split(r'([)}]|scatter)[ ]?\.', gremlin) # Put the ) and } back on. parts = [ too_many_parts[i] + too_many_parts[i + 1]...
[ "def", "pretty_print_gremlin", "(", "gremlin", ")", ":", "gremlin", "=", "remove_custom_formatting", "(", "gremlin", ")", "too_many_parts", "=", "re", ".", "split", "(", "r'([)}]|scatter)[ ]?\\.'", ",", "gremlin", ")", "parts", "=", "[", "too_many_parts", "[", "...
Return a human-readable representation of a gremlin command string.
[ "Return", "a", "human", "-", "readable", "representation", "of", "a", "gremlin", "command", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/debugging_utils.py#L13-L44
train
kensho-technologies/graphql-compiler
graphql_compiler/debugging_utils.py
pretty_print_match
def pretty_print_match(match, parameterized=True): """Return a human-readable representation of a parameterized MATCH query string.""" left_curly = '{{' if parameterized else '{' right_curly = '}}' if parameterized else '}' match = remove_custom_formatting(match) parts = re.split('({}|{})'.format(le...
python
def pretty_print_match(match, parameterized=True): """Return a human-readable representation of a parameterized MATCH query string.""" left_curly = '{{' if parameterized else '{' right_curly = '}}' if parameterized else '}' match = remove_custom_formatting(match) parts = re.split('({}|{})'.format(le...
[ "def", "pretty_print_match", "(", "match", ",", "parameterized", "=", "True", ")", ":", "left_curly", "=", "'{{'", "if", "parameterized", "else", "'{'", "right_curly", "=", "'}}'", "if", "parameterized", "else", "'}'", "match", "=", "remove_custom_formatting", "...
Return a human-readable representation of a parameterized MATCH query string.
[ "Return", "a", "human", "-", "readable", "representation", "of", "a", "parameterized", "MATCH", "query", "string", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/debugging_utils.py#L47-L96
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/representations.py
represent_float_as_str
def represent_float_as_str(value): """Represent a float as a string without losing precision.""" # In Python 2, calling str() on a float object loses precision: # # In [1]: 1.23456789012345678 # Out[1]: 1.2345678901234567 # # In [2]: 1.2345678901234567 # Out[2]: 1.2345678901234567 # ...
python
def represent_float_as_str(value): """Represent a float as a string without losing precision.""" # In Python 2, calling str() on a float object loses precision: # # In [1]: 1.23456789012345678 # Out[1]: 1.2345678901234567 # # In [2]: 1.2345678901234567 # Out[2]: 1.2345678901234567 # ...
[ "def", "represent_float_as_str", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "float", ")", ":", "raise", "GraphQLInvalidArgumentError", "(", "u'Attempting to represent a non-float as a float: '", "u'{}'", ".", "format", "(", "value", ")", "...
Represent a float as a string without losing precision.
[ "Represent", "a", "float", "as", "a", "string", "without", "losing", "precision", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/representations.py#L8-L29
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/representations.py
coerce_to_decimal
def coerce_to_decimal(value): """Attempt to coerce the value to a Decimal, or raise an error if unable to do so.""" if isinstance(value, decimal.Decimal): return value else: try: return decimal.Decimal(value) except decimal.InvalidOperation as e: raise GraphQL...
python
def coerce_to_decimal(value): """Attempt to coerce the value to a Decimal, or raise an error if unable to do so.""" if isinstance(value, decimal.Decimal): return value else: try: return decimal.Decimal(value) except decimal.InvalidOperation as e: raise GraphQL...
[ "def", "coerce_to_decimal", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "decimal", ".", "Decimal", ")", ":", "return", "value", "else", ":", "try", ":", "return", "decimal", ".", "Decimal", "(", "value", ")", "except", "decimal", ".", ...
Attempt to coerce the value to a Decimal, or raise an error if unable to do so.
[ "Attempt", "to", "coerce", "the", "value", "to", "a", "Decimal", "or", "raise", "an", "error", "if", "unable", "to", "do", "so", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/representations.py#L41-L49
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
make_replacement_visitor
def make_replacement_visitor(find_expression, replace_expression): """Return a visitor function that replaces every instance of one expression with another one.""" def visitor_fn(expression): """Return the replacement if this expression matches the expression we're looking for.""" if expression ...
python
def make_replacement_visitor(find_expression, replace_expression): """Return a visitor function that replaces every instance of one expression with another one.""" def visitor_fn(expression): """Return the replacement if this expression matches the expression we're looking for.""" if expression ...
[ "def", "make_replacement_visitor", "(", "find_expression", ",", "replace_expression", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "if", "expression", "==", "find_expression", ":", "return", "replace_expression", "else", ":", "return", "expression", "...
Return a visitor function that replaces every instance of one expression with another one.
[ "Return", "a", "visitor", "function", "that", "replaces", "every", "instance", "of", "one", "expression", "with", "another", "one", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L29-L38
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
make_type_replacement_visitor
def make_type_replacement_visitor(find_types, replacement_func): """Return a visitor function that replaces expressions of a given type with new expressions.""" def visitor_fn(expression): """Return a replacement expression if the original expression is of the correct type.""" if isinstance(expr...
python
def make_type_replacement_visitor(find_types, replacement_func): """Return a visitor function that replaces expressions of a given type with new expressions.""" def visitor_fn(expression): """Return a replacement expression if the original expression is of the correct type.""" if isinstance(expr...
[ "def", "make_type_replacement_visitor", "(", "find_types", ",", "replacement_func", ")", ":", "def", "visitor_fn", "(", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "find_types", ")", ":", "return", "replacement_func", "(", "expression", ")"...
Return a visitor function that replaces expressions of a given type with new expressions.
[ "Return", "a", "visitor", "function", "that", "replaces", "expressions", "of", "a", "given", "type", "with", "new", "expressions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L41-L50
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
_validate_operator_name
def _validate_operator_name(operator, supported_operators): """Ensure the named operator is valid and supported.""" if not isinstance(operator, six.text_type): raise TypeError(u'Expected operator as unicode string, got: {} {}'.format( type(operator).__name__, operator)) if operator not ...
python
def _validate_operator_name(operator, supported_operators): """Ensure the named operator is valid and supported.""" if not isinstance(operator, six.text_type): raise TypeError(u'Expected operator as unicode string, got: {} {}'.format( type(operator).__name__, operator)) if operator not ...
[ "def", "_validate_operator_name", "(", "operator", ",", "supported_operators", ")", ":", "if", "not", "isinstance", "(", "operator", ",", "six", ".", "text_type", ")", ":", "raise", "TypeError", "(", "u'Expected operator as unicode string, got: {} {}'", ".", "format",...
Ensure the named operator is valid and supported.
[ "Ensure", "the", "named", "operator", "is", "valid", "and", "supported", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L665-L672
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Literal.validate
def validate(self): """Validate that the Literal is correctly representable.""" # Literals representing boolean values or None are correctly representable and supported. if self.value is None or self.value is True or self.value is False: return # Literal safe strings are cor...
python
def validate(self): """Validate that the Literal is correctly representable.""" # Literals representing boolean values or None are correctly representable and supported. if self.value is None or self.value is True or self.value is False: return # Literal safe strings are cor...
[ "def", "validate", "(", "self", ")", ":", "if", "self", ".", "value", "is", "None", "or", "self", ".", "value", "is", "True", "or", "self", ".", "value", "is", "False", ":", "return", "if", "isinstance", "(", "self", ".", "value", ",", "six", ".", ...
Validate that the Literal is correctly representable.
[ "Validate", "that", "the", "Literal", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L72-L95
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Variable.validate
def validate(self): """Validate that the Variable is correctly representable.""" # Get the first letter, or empty string if it doesn't exist. if not self.variable_name.startswith(u'$'): raise GraphQLCompilationError(u'Expected variable name to start with $, but was: ' ...
python
def validate(self): """Validate that the Variable is correctly representable.""" # Get the first letter, or empty string if it doesn't exist. if not self.variable_name.startswith(u'$'): raise GraphQLCompilationError(u'Expected variable name to start with $, but was: ' ...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "self", ".", "variable_name", ".", "startswith", "(", "u'$'", ")", ":", "raise", "GraphQLCompilationError", "(", "u'Expected variable name to start with $, but was: '", "u'{}'", ".", "format", "(", "self", "."...
Validate that the Variable is correctly representable.
[ "Validate", "that", "the", "Variable", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L154-L183
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
Variable.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this Variable.""" self.validate() # We don't want the dollar sign as part of the variable name. variable_with_no_dollar_sign = self.variable_name[1:] match_variable_name = '{%s}' % (six.text_type(va...
python
def to_match(self): """Return a unicode object with the MATCH representation of this Variable.""" self.validate() # We don't want the dollar sign as part of the variable name. variable_with_no_dollar_sign = self.variable_name[1:] match_variable_name = '{%s}' % (six.text_type(va...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "variable_with_no_dollar_sign", "=", "self", ".", "variable_name", "[", "1", ":", "]", "match_variable_name", "=", "'{%s}'", "%", "(", "six", ".", "text_type", "(", "variable_with_n...
Return a unicode object with the MATCH representation of this Variable.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "Variable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L185-L204
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
GlobalContextField.validate
def validate(self): """Validate that the GlobalContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}' .format(type(self.location).__name__, self.location)) if self....
python
def validate(self): """Validate that the GlobalContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}' .format(type(self.location).__name__, self.location)) if self....
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the GlobalContextField is correctly representable.
[ "Validate", "that", "the", "GlobalContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L289-L300
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
GlobalContextField.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this GlobalContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) validate_safe_string(field_name) return u'%s.%s' % (mark...
python
def to_match(self): """Return a unicode object with the MATCH representation of this GlobalContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) validate_safe_string(field_name) return u'%s.%s' % (mark...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "mark_name", ",", "field_name", "=", "self", ".", "location", ".", "get_location_name", "(", ")", "validate_safe_string", "(", "mark_name", ")", "validate_safe_string", "(", "field_na...
Return a unicode object with the MATCH representation of this GlobalContextField.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "GlobalContextField", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L302-L310
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
ContextField.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this ContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) if field_name is None: return u'$matched.%s' % (mark_name,...
python
def to_match(self): """Return a unicode object with the MATCH representation of this ContextField.""" self.validate() mark_name, field_name = self.location.get_location_name() validate_safe_string(mark_name) if field_name is None: return u'$matched.%s' % (mark_name,...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "mark_name", ",", "field_name", "=", "self", ".", "location", ".", "get_location_name", "(", ")", "validate_safe_string", "(", "mark_name", ")", "if", "field_name", "is", "None", ...
Return a unicode object with the MATCH representation of this ContextField.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "ContextField", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L350-L361
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
OutputContextField.validate
def validate(self): """Validate that the OutputContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if not self.location...
python
def validate(self): """Validate that the OutputContextField is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if not self.location...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the OutputContextField is correctly representable.
[ "Validate", "that", "the", "OutputContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L404-L427
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
FoldedContextField.validate
def validate(self): """Validate that the FoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), sel...
python
def validate(self): """Validate that the FoldedContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), sel...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected FoldScopeLocation fold_scope_location, got: {} {}'", ".", "format", "(", "type", ...
Validate that the FoldedContextField is correctly representable.
[ "Validate", "that", "the", "FoldedContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L505-L530
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
FoldCountContextField.validate
def validate(self): """Validate that the FoldCountContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), ...
python
def validate(self): """Validate that the FoldCountContextField is correctly representable.""" if not isinstance(self.fold_scope_location, FoldScopeLocation): raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format( type(self.fold_scope_location), ...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "fold_scope_location", ",", "FoldScopeLocation", ")", ":", "raise", "TypeError", "(", "u'Expected FoldScopeLocation fold_scope_location, got: {} {}'", ".", "format", "(", "type", ...
Validate that the FoldCountContextField is correctly representable.
[ "Validate", "that", "the", "FoldCountContextField", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L596-L605
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
ContextFieldExistence.validate
def validate(self): """Validate that the ContextFieldExistence is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if self.location....
python
def validate(self): """Validate that the ContextFieldExistence is correctly representable.""" if not isinstance(self.location, Location): raise TypeError(u'Expected Location location, got: {} {}'.format( type(self.location).__name__, self.location)) if self.location....
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "location", ",", "Location", ")", ":", "raise", "TypeError", "(", "u'Expected Location location, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "location", ")...
Validate that the ContextFieldExistence is correctly representable.
[ "Validate", "that", "the", "ContextFieldExistence", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L646-L654
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
UnaryTransformation.validate
def validate(self): """Validate that the UnaryTransformation is correctly representable.""" _validate_operator_name(self.operator, UnaryTransformation.SUPPORTED_OPERATORS) if not isinstance(self.inner_expression, Expression): raise TypeError(u'Expected Expression inner_expression, g...
python
def validate(self): """Validate that the UnaryTransformation is correctly representable.""" _validate_operator_name(self.operator, UnaryTransformation.SUPPORTED_OPERATORS) if not isinstance(self.inner_expression, Expression): raise TypeError(u'Expected Expression inner_expression, g...
[ "def", "validate", "(", "self", ")", ":", "_validate_operator_name", "(", "self", ".", "operator", ",", "UnaryTransformation", ".", "SUPPORTED_OPERATORS", ")", "if", "not", "isinstance", "(", "self", ".", "inner_expression", ",", "Expression", ")", ":", "raise",...
Validate that the UnaryTransformation is correctly representable.
[ "Validate", "that", "the", "UnaryTransformation", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L688-L694
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
UnaryTransformation.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this UnaryTransformation.""" self.validate() translation_table = { u'size': u'size()', } match_operator = translation_table.get(self.operator) if not match_operator: r...
python
def to_match(self): """Return a unicode object with the MATCH representation of this UnaryTransformation.""" self.validate() translation_table = { u'size': u'size()', } match_operator = translation_table.get(self.operator) if not match_operator: r...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "translation_table", "=", "{", "u'size'", ":", "u'size()'", ",", "}", "match_operator", "=", "translation_table", ".", "get", "(", "self", ".", "operator", ")", "if", "not", "ma...
Return a unicode object with the MATCH representation of this UnaryTransformation.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "UnaryTransformation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L705-L722
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
BinaryComposition.validate
def validate(self): """Validate that the BinaryComposition is correctly representable.""" _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( ...
python
def validate(self): """Validate that the BinaryComposition is correctly representable.""" _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( ...
[ "def", "validate", "(", "self", ")", ":", "_validate_operator_name", "(", "self", ".", "operator", ",", "BinaryComposition", ".", "SUPPORTED_OPERATORS", ")", "if", "not", "isinstance", "(", "self", ".", "left", ",", "Expression", ")", ":", "raise", "TypeError"...
Validate that the BinaryComposition is correctly representable.
[ "Validate", "that", "the", "BinaryComposition", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L769-L779
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
BinaryComposition.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this BinaryComposition.""" self.validate() # The MATCH versions of some operators require an inverted order of arguments. # pylint: disable=unused-variable regular_operator_format = '(%(left)s %(oper...
python
def to_match(self): """Return a unicode object with the MATCH representation of this BinaryComposition.""" self.validate() # The MATCH versions of some operators require an inverted order of arguments. # pylint: disable=unused-variable regular_operator_format = '(%(left)s %(oper...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "regular_operator_format", "=", "'(%(left)s %(operator)s %(right)s)'", "inverted_operator_format", "=", "'(%(right)s %(operator)s %(left)s)'", "intersects_operator_format", "=", "'(%(operator)s(%(left)...
Return a unicode object with the MATCH representation of this BinaryComposition.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "BinaryComposition", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L791-L836
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
TernaryConditional.validate
def validate(self): """Validate that the TernaryConditional is correctly representable.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate)) if not isinst...
python
def validate(self): """Validate that the TernaryConditional is correctly representable.""" if not isinstance(self.predicate, Expression): raise TypeError(u'Expected Expression predicate, got: {} {}'.format( type(self.predicate).__name__, self.predicate)) if not isinst...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "predicate", ",", "Expression", ")", ":", "raise", "TypeError", "(", "u'Expected Expression predicate, got: {} {}'", ".", "format", "(", "type", "(", "self", ".", "predicate...
Validate that the TernaryConditional is correctly representable.
[ "Validate", "that", "the", "TernaryConditional", "is", "correctly", "representable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L893-L903
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
TernaryConditional.to_match
def to_match(self): """Return a unicode object with the MATCH representation of this TernaryConditional.""" self.validate() # For MATCH, an additional validation step is needed -- we currently do not support # emitting MATCH code for TernaryConditional that contains another TernaryCondi...
python
def to_match(self): """Return a unicode object with the MATCH representation of this TernaryConditional.""" self.validate() # For MATCH, an additional validation step is needed -- we currently do not support # emitting MATCH code for TernaryConditional that contains another TernaryCondi...
[ "def", "to_match", "(", "self", ")", ":", "self", ".", "validate", "(", ")", "def", "visitor_fn", "(", "expression", ")", ":", "if", "isinstance", "(", "expression", ",", "TernaryConditional", ")", ":", "raise", "ValueError", "(", "u'Cannot emit MATCH code for...
Return a unicode object with the MATCH representation of this TernaryConditional.
[ "Return", "a", "unicode", "object", "with", "the", "MATCH", "representation", "of", "this", "TernaryConditional", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L918-L945
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
sanity_check_ir_blocks_from_frontend
def sanity_check_ir_blocks_from_frontend(ir_blocks, query_metadata_table): """Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected str...
python
def sanity_check_ir_blocks_from_frontend(ir_blocks, query_metadata_table): """Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected str...
[ "def", "sanity_check_ir_blocks_from_frontend", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "if", "not", "ir_blocks", ":", "raise", "AssertionError", "(", "u'Received no ir_blocks: {}'", ".", "format", "(", "ir_blocks", ")", ")", "_sanity_check_fold_scope_loca...
Assert that IR blocks originating from the frontend do not have nonsensical structure. Args: ir_blocks: list of BasicBlocks representing the IR to sanity-check Raises: AssertionError, if the IR has unexpected structure. If the IR produced by the front-end cannot be successfully and cor...
[ "Assert", "that", "IR", "blocks", "originating", "from", "the", "frontend", "do", "not", "have", "nonsensical", "structure", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L13-L36
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_registered_locations_parent_locations
def _sanity_check_registered_locations_parent_locations(query_metadata_table): """Assert that all registered locations' parent locations are also registered.""" for location, location_info in query_metadata_table.registered_locations: if (location != query_metadata_table.root_location and ...
python
def _sanity_check_registered_locations_parent_locations(query_metadata_table): """Assert that all registered locations' parent locations are also registered.""" for location, location_info in query_metadata_table.registered_locations: if (location != query_metadata_table.root_location and ...
[ "def", "_sanity_check_registered_locations_parent_locations", "(", "query_metadata_table", ")", ":", "for", "location", ",", "location_info", "in", "query_metadata_table", ".", "registered_locations", ":", "if", "(", "location", "!=", "query_metadata_table", ".", "root_loca...
Assert that all registered locations' parent locations are also registered.
[ "Assert", "that", "all", "registered", "locations", "parent", "locations", "are", "also", "registered", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L39-L54
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_all_marked_locations_are_registered
def _sanity_check_all_marked_locations_are_registered(ir_blocks, query_metadata_table): """Assert that all locations in MarkLocation blocks have registered and valid metadata.""" # Grab all the registered locations, then make sure that: # - Any location that appears in a MarkLocation block is also registere...
python
def _sanity_check_all_marked_locations_are_registered(ir_blocks, query_metadata_table): """Assert that all locations in MarkLocation blocks have registered and valid metadata.""" # Grab all the registered locations, then make sure that: # - Any location that appears in a MarkLocation block is also registere...
[ "def", "_sanity_check_all_marked_locations_are_registered", "(", "ir_blocks", ",", "query_metadata_table", ")", ":", "registered_locations", "=", "{", "location", "for", "location", ",", "_", "in", "query_metadata_table", ".", "registered_locations", "}", "ir_encountered_lo...
Assert that all locations in MarkLocation blocks have registered and valid metadata.
[ "Assert", "that", "all", "locations", "in", "MarkLocation", "blocks", "have", "registered", "and", "valid", "metadata", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L57-L80
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_fold_scope_locations_are_unique
def _sanity_check_fold_scope_locations_are_unique(ir_blocks): """Assert that every FoldScopeLocation that exists on a Fold block is unique.""" observed_locations = dict() for block in ir_blocks: if isinstance(block, Fold): alternate = observed_locations.get(block.fold_scope_location, Non...
python
def _sanity_check_fold_scope_locations_are_unique(ir_blocks): """Assert that every FoldScopeLocation that exists on a Fold block is unique.""" observed_locations = dict() for block in ir_blocks: if isinstance(block, Fold): alternate = observed_locations.get(block.fold_scope_location, Non...
[ "def", "_sanity_check_fold_scope_locations_are_unique", "(", "ir_blocks", ")", ":", "observed_locations", "=", "dict", "(", ")", "for", "block", "in", "ir_blocks", ":", "if", "isinstance", "(", "block", ",", "Fold", ")", ":", "alternate", "=", "observed_locations"...
Assert that every FoldScopeLocation that exists on a Fold block is unique.
[ "Assert", "that", "every", "FoldScopeLocation", "that", "exists", "on", "a", "Fold", "block", "is", "unique", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L83-L92
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_no_nested_folds
def _sanity_check_no_nested_folds(ir_blocks): """Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.""" fold_seen = False for block in ir_blocks: if isinstance(block, Fold): if fold_seen: raise AssertionError(u'Found a nested Fold con...
python
def _sanity_check_no_nested_folds(ir_blocks): """Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.""" fold_seen = False for block in ir_blocks: if isinstance(block, Fold): if fold_seen: raise AssertionError(u'Found a nested Fold con...
[ "def", "_sanity_check_no_nested_folds", "(", "ir_blocks", ")", ":", "fold_seen", "=", "False", "for", "block", "in", "ir_blocks", ":", "if", "isinstance", "(", "block", ",", "Fold", ")", ":", "if", "fold_seen", ":", "raise", "AssertionError", "(", "u'Found a n...
Assert that there are no nested Fold contexts, and that every Fold has a matching Unfold.
[ "Assert", "that", "there", "are", "no", "nested", "Fold", "contexts", "and", "that", "every", "Fold", "has", "a", "matching", "Unfold", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L95-L109
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_query_root_block
def _sanity_check_query_root_block(ir_blocks): """Assert that QueryRoot is always the first block, and only the first block.""" if not isinstance(ir_blocks[0], QueryRoot): raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks)) for block in ir_blocks[1:]: if isinstan...
python
def _sanity_check_query_root_block(ir_blocks): """Assert that QueryRoot is always the first block, and only the first block.""" if not isinstance(ir_blocks[0], QueryRoot): raise AssertionError(u'The first block was not QueryRoot: {}'.format(ir_blocks)) for block in ir_blocks[1:]: if isinstan...
[ "def", "_sanity_check_query_root_block", "(", "ir_blocks", ")", ":", "if", "not", "isinstance", "(", "ir_blocks", "[", "0", "]", ",", "QueryRoot", ")", ":", "raise", "AssertionError", "(", "u'The first block was not QueryRoot: {}'", ".", "format", "(", "ir_blocks", ...
Assert that QueryRoot is always the first block, and only the first block.
[ "Assert", "that", "QueryRoot", "is", "always", "the", "first", "block", "and", "only", "the", "first", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L112-L118
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_construct_result_block
def _sanity_check_construct_result_block(ir_blocks): """Assert that ConstructResult is always the last block, and only the last block.""" if not isinstance(ir_blocks[-1], ConstructResult): raise AssertionError(u'The last block was not ConstructResult: {}'.format(ir_blocks)) for block in ir_blocks[:-...
python
def _sanity_check_construct_result_block(ir_blocks): """Assert that ConstructResult is always the last block, and only the last block.""" if not isinstance(ir_blocks[-1], ConstructResult): raise AssertionError(u'The last block was not ConstructResult: {}'.format(ir_blocks)) for block in ir_blocks[:-...
[ "def", "_sanity_check_construct_result_block", "(", "ir_blocks", ")", ":", "if", "not", "isinstance", "(", "ir_blocks", "[", "-", "1", "]", ",", "ConstructResult", ")", ":", "raise", "AssertionError", "(", "u'The last block was not ConstructResult: {}'", ".", "format"...
Assert that ConstructResult is always the last block, and only the last block.
[ "Assert", "that", "ConstructResult", "is", "always", "the", "last", "block", "and", "only", "the", "last", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L121-L128
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_block_pairwise_constraints
def _sanity_check_block_pairwise_constraints(ir_blocks): """Assert that adjacent blocks obey all invariants.""" for first_block, second_block in pairwise(ir_blocks): # Always Filter before MarkLocation, never after. if isinstance(first_block, MarkLocation) and isinstance(second_block, Filter): ...
python
def _sanity_check_block_pairwise_constraints(ir_blocks): """Assert that adjacent blocks obey all invariants.""" for first_block, second_block in pairwise(ir_blocks): # Always Filter before MarkLocation, never after. if isinstance(first_block, MarkLocation) and isinstance(second_block, Filter): ...
[ "def", "_sanity_check_block_pairwise_constraints", "(", "ir_blocks", ")", ":", "for", "first_block", ",", "second_block", "in", "pairwise", "(", "ir_blocks", ")", ":", "if", "isinstance", "(", "first_block", ",", "MarkLocation", ")", "and", "isinstance", "(", "sec...
Assert that adjacent blocks obey all invariants.
[ "Assert", "that", "adjacent", "blocks", "obey", "all", "invariants", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L144-L172
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_mark_location_preceding_optional_traverse
def _sanity_check_mark_location_preceding_optional_traverse(ir_blocks): """Assert that optional Traverse blocks are preceded by a MarkLocation.""" # Once all fold blocks are removed, each optional Traverse must have # a MarkLocation block immediately before it. _, new_ir_blocks = extract_folds_from_ir_b...
python
def _sanity_check_mark_location_preceding_optional_traverse(ir_blocks): """Assert that optional Traverse blocks are preceded by a MarkLocation.""" # Once all fold blocks are removed, each optional Traverse must have # a MarkLocation block immediately before it. _, new_ir_blocks = extract_folds_from_ir_b...
[ "def", "_sanity_check_mark_location_preceding_optional_traverse", "(", "ir_blocks", ")", ":", "_", ",", "new_ir_blocks", "=", "extract_folds_from_ir_blocks", "(", "ir_blocks", ")", "for", "first_block", ",", "second_block", "in", "pairwise", "(", "new_ir_blocks", ")", "...
Assert that optional Traverse blocks are preceded by a MarkLocation.
[ "Assert", "that", "optional", "Traverse", "blocks", "are", "preceded", "by", "a", "MarkLocation", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L175-L185
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_every_location_is_marked
def _sanity_check_every_location_is_marked(ir_blocks): """Ensure that every new location is marked with a MarkLocation block.""" # Exactly one MarkLocation block is found between any block that starts an interval of blocks # that all affect the same query position, and the first subsequent block that affect...
python
def _sanity_check_every_location_is_marked(ir_blocks): """Ensure that every new location is marked with a MarkLocation block.""" # Exactly one MarkLocation block is found between any block that starts an interval of blocks # that all affect the same query position, and the first subsequent block that affect...
[ "def", "_sanity_check_every_location_is_marked", "(", "ir_blocks", ")", ":", "found_start_block", "=", "False", "mark_location_blocks_count", "=", "0", "start_interval_types", "=", "(", "QueryRoot", ",", "Traverse", ",", "Recurse", ",", "Fold", ")", "end_interval_types"...
Ensure that every new location is marked with a MarkLocation block.
[ "Ensure", "that", "every", "new", "location", "is", "marked", "with", "a", "MarkLocation", "block", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L188-L216
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/ir_sanity_checks.py
_sanity_check_coerce_type_outside_of_fold
def _sanity_check_coerce_type_outside_of_fold(ir_blocks): """Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.""" is_in_fold = False for first_block, second_block in pairwise(ir_blocks): if isinstance(first_block, Fold): is_in_fold = True if n...
python
def _sanity_check_coerce_type_outside_of_fold(ir_blocks): """Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.""" is_in_fold = False for first_block, second_block in pairwise(ir_blocks): if isinstance(first_block, Fold): is_in_fold = True if n...
[ "def", "_sanity_check_coerce_type_outside_of_fold", "(", "ir_blocks", ")", ":", "is_in_fold", "=", "False", "for", "first_block", ",", "second_block", "in", "pairwise", "(", "ir_blocks", ")", ":", "if", "isinstance", "(", "first_block", ",", "Fold", ")", ":", "i...
Ensure that CoerceType not in a @fold are followed by a MarkLocation or Filter block.
[ "Ensure", "that", "CoerceType", "not", "in", "a" ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_sanity_checks.py#L219-L232
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
validate_supported_property_type_id
def validate_supported_property_type_id(property_name, property_type_id): """Ensure that the given property type_id is supported by the graph.""" if property_type_id not in PROPERTY_TYPE_ID_TO_NAME: raise AssertionError(u'Property "{}" has unsupported property type id: ' u'{...
python
def validate_supported_property_type_id(property_name, property_type_id): """Ensure that the given property type_id is supported by the graph.""" if property_type_id not in PROPERTY_TYPE_ID_TO_NAME: raise AssertionError(u'Property "{}" has unsupported property type id: ' u'{...
[ "def", "validate_supported_property_type_id", "(", "property_name", ",", "property_type_id", ")", ":", "if", "property_type_id", "not", "in", "PROPERTY_TYPE_ID_TO_NAME", ":", "raise", "AssertionError", "(", "u'Property \"{}\" has unsupported property type id: '", "u'{}'", ".", ...
Ensure that the given property type_id is supported by the graph.
[ "Ensure", "that", "the", "given", "property", "type_id", "is", "supported", "by", "the", "graph", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L96-L100
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_bool_default_value
def _parse_bool_default_value(property_name, default_value_string): """Parse and return the default value for a boolean property.""" lowercased_value_string = default_value_string.lower() if lowercased_value_string in {'0', 'false'}: return False elif lowercased_value_string in {'1', 'true'}: ...
python
def _parse_bool_default_value(property_name, default_value_string): """Parse and return the default value for a boolean property.""" lowercased_value_string = default_value_string.lower() if lowercased_value_string in {'0', 'false'}: return False elif lowercased_value_string in {'1', 'true'}: ...
[ "def", "_parse_bool_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "lowercased_value_string", "=", "default_value_string", ".", "lower", "(", ")", "if", "lowercased_value_string", "in", "{", "'0'", ",", "'false'", "}", ":", "return", "F...
Parse and return the default value for a boolean property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "boolean", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L103-L112
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_datetime_default_value
def _parse_datetime_default_value(property_name, default_value_string): """Parse and return the default value for a datetime property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception ...
python
def _parse_datetime_default_value(property_name, default_value_string): """Parse and return the default value for a datetime property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception ...
[ "def", "_parse_datetime_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "parsed_value", "=", "time", ".", "strptime", "(", "default_value_string", ",", "ORIENTDB_DATETIME_FORMAT", ")", "return", "datetime", ".", "datetime", "(", "parsed_valu...
Parse and return the default value for a datetime property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "datetime", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L115-L123
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
_parse_date_default_value
def _parse_date_default_value(property_name, default_value_string): """Parse and return the default value for a date property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception # if the...
python
def _parse_date_default_value(property_name, default_value_string): """Parse and return the default value for a date property.""" # OrientDB doesn't use ISO-8601 datetime format, so we have to parse it manually # and then turn it into a python datetime object. strptime() will raise an exception # if the...
[ "def", "_parse_date_default_value", "(", "property_name", ",", "default_value_string", ")", ":", "parsed_value", "=", "time", ".", "strptime", "(", "default_value_string", ",", "ORIENTDB_DATE_FORMAT", ")", "return", "datetime", ".", "date", "(", "parsed_value", ".", ...
Parse and return the default value for a date property.
[ "Parse", "and", "return", "the", "default", "value", "for", "a", "date", "property", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L126-L132
train
kensho-technologies/graphql-compiler
graphql_compiler/schema_generation/schema_properties.py
parse_default_property_value
def parse_default_property_value(property_name, property_type_id, default_value_string): """Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to...
python
def parse_default_property_value(property_name, property_type_id, default_value_string): """Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to...
[ "def", "parse_default_property_value", "(", "property_name", ",", "property_type_id", ",", "default_value_string", ")", ":", "if", "property_type_id", "==", "PROPERTY_TYPE_EMBEDDED_SET_ID", "and", "default_value_string", "==", "'{}'", ":", "return", "set", "(", ")", "el...
Parse the default value string into its proper form given the property type ID. Args: property_name: string, the name of the property whose default value is being parsed. Used primarily to construct meaningful error messages, should the default value prove inva...
[ "Parse", "the", "default", "value", "string", "into", "its", "proper", "form", "given", "the", "property", "type", "ID", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/schema_properties.py#L135-L171
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/common.py
_compile_graphql_generic
def _compile_graphql_generic(language, lowering_func, query_emitter_func, schema, graphql_string, type_equivalence_hints, compiler_metadata): """Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the targe...
python
def _compile_graphql_generic(language, lowering_func, query_emitter_func, schema, graphql_string, type_equivalence_hints, compiler_metadata): """Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the targe...
[ "def", "_compile_graphql_generic", "(", "language", ",", "lowering_func", ",", "query_emitter_func", ",", "schema", ",", "graphql_string", ",", "type_equivalence_hints", ",", "compiler_metadata", ")", ":", "ir_and_metadata", "=", "graphql_to_ir", "(", "schema", ",", "...
Compile the GraphQL input, lowering and emitting the query using the given functions. Args: language: string indicating the target language to compile to. lowering_func: Function to lower the compiler IR into a compatible form for the target language backend. query_em...
[ "Compile", "the", "GraphQL", "input", "lowering", "and", "emitting", "the", "query", "using", "the", "given", "functions", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/common.py#L122-L152
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
scalar_leaf_only
def scalar_leaf_only(operator): """Ensure the filter function is only applied to scalar leaf types.""" def decorator(f): """Decorate the supplied function with the "scalar_leaf_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
python
def scalar_leaf_only(operator): """Ensure the filter function is only applied to scalar leaf types.""" def decorator(f): """Decorate the supplied function with the "scalar_leaf_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
[ "def", "scalar_leaf_only", "(", "operator", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "context", ",", "parameters", ",", "*", "args", ",", "**", "kwargs", ")", ":...
Ensure the filter function is only applied to scalar leaf types.
[ "Ensure", "the", "filter", "function", "is", "only", "applied", "to", "scalar", "leaf", "types", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L17-L37
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
vertex_field_only
def vertex_field_only(operator): """Ensure the filter function is only applied to vertex field types.""" def decorator(f): """Decorate the supplied function with the "vertex_field_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
python
def vertex_field_only(operator): """Ensure the filter function is only applied to vertex field types.""" def decorator(f): """Decorate the supplied function with the "vertex_field_only" logic.""" @wraps(f) def wrapper(filter_operation_info, context, parameters, *args, **kwargs): ...
[ "def", "vertex_field_only", "(", "operator", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "context", ",", "parameters", ",", "*", "args", ",", "**", "kwargs", ")", "...
Ensure the filter function is only applied to vertex field types.
[ "Ensure", "the", "filter", "function", "is", "only", "applied", "to", "vertex", "field", "types", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L40-L61
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
takes_parameters
def takes_parameters(count): """Ensure the filter function has "count" parameters specified.""" def decorator(f): """Decorate the supplied function with the "takes_parameters" logic.""" @wraps(f) def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs): ...
python
def takes_parameters(count): """Ensure the filter function has "count" parameters specified.""" def decorator(f): """Decorate the supplied function with the "takes_parameters" logic.""" @wraps(f) def wrapper(filter_operation_info, location, context, parameters, *args, **kwargs): ...
[ "def", "takes_parameters", "(", "count", ")", ":", "def", "decorator", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ",", "*", "args", ",", "**", "kw...
Ensure the filter function has "count" parameters specified.
[ "Ensure", "the", "filter", "function", "has", "count", "parameters", "specified", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L64-L79
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_represent_argument
def _represent_argument(directive_location, context, argument, inferred_type): """Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared ...
python
def _represent_argument(directive_location, context, argument, inferred_type): """Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared ...
[ "def", "_represent_argument", "(", "directive_location", ",", "context", ",", "argument", ",", "inferred_type", ")", ":", "argument_name", "=", "argument", "[", "1", ":", "]", "validate_safe_string", "(", "argument_name", ")", "if", "is_variable_argument", "(", "a...
Return a two-element tuple that represents the argument to the directive being processed. Args: directive_location: Location where the directive is used. context: dict, various per-compilation data (e.g. declared tags, whether the current block is optional, etc.). May be mutated in...
[ "Return", "a", "two", "-", "element", "tuple", "that", "represents", "the", "argument", "to", "the", "directive", "being", "processed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L82-L156
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_comparison_filter_directive
def _process_comparison_filter_directive(filter_operation_info, location, context, parameters, operator=None): """Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, ...
python
def _process_comparison_filter_directive(filter_operation_info, location, context, parameters, operator=None): """Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, ...
[ "def", "_process_comparison_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ",", "operator", "=", "None", ")", ":", "comparison_operators", "=", "{", "u'='", ",", "u'!='", ",", "u'>'", ",", "u'<'", ",", "u'>='...
Return a Filter basic block that performs the given comparison against the property field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fi...
[ "Return", "a", "Filter", "basic", "block", "that", "performs", "the", "given", "comparison", "against", "the", "property", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L161-L204
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_has_edge_degree_filter_directive
def _process_has_edge_degree_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_has_edge_degree_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_has_edge_degree_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "if", "isinstance", "(", "filter_operation_info", ".", "field_ast", ",", "InlineFragment", ")", ":", "raise", "AssertionError"...
Return a Filter basic block that checks the degree of the edge to the given vertex field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fil...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "the", "degree", "of", "the", "edge", "to", "the", "given", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L209-L279
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_name_or_alias_filter_directive
def _process_name_or_alias_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_name_or_alias_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_name_or_alias_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "if", "isinstance", "(", "filtered_field_type", ",", "Grap...
Return a Filter basic block that checks for a match against an Entity's name or alias. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "for", "a", "match", "against", "an", "Entity", "s", "name", "or", "alias", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L284-L346
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_between_filter_directive
def _process_between_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_between_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_between_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "field_n...
Return a Filter basic block that checks that a field is between two values, inclusive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "that", "a", "field", "is", "between", "two", "values", "inclusive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L351-L392
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_in_collection_filter_directive
def _process_in_collection_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_in_collection_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_in_collection_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "f...
Return a Filter basic block that checks for a value's existence in a collection. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter is us...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "for", "a", "value", "s", "existence", "in", "a", "collection", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L397-L427
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_has_substring_filter_directive
def _process_has_substring_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_has_substring_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_has_substring_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "f...
Return a Filter basic block that checks if the directive arg is a substring of the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this fil...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "is", "a", "substring", "of", "the", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L432-L466
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_contains_filter_directive
def _process_contains_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_contains_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_contains_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "field_...
Return a Filter basic block that checks if the directive arg is contained in the field. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filte...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "is", "contained", "in", "the", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L470-L505
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
_process_intersects_filter_directive
def _process_intersects_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
python
def _process_intersects_filter_directive(filter_operation_info, location, context, parameters): """Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info ...
[ "def", "_process_intersects_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ",", "parameters", ")", ":", "filtered_field_type", "=", "filter_operation_info", ".", "field_type", "filtered_field_name", "=", "filter_operation_info", ".", "fiel...
Return a Filter basic block that checks if the directive arg and the field intersect. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter ...
[ "Return", "a", "Filter", "basic", "block", "that", "checks", "if", "the", "directive", "arg", "and", "the", "field", "intersect", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L509-L543
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
is_filter_with_outer_scope_vertex_field_operator
def is_filter_with_outer_scope_vertex_field_operator(directive): """Return True if we have a filter directive whose operator applies to the outer scope.""" if directive.name.value != 'filter': return False op_name, _ = _get_filter_op_name_and_values(directive) return op_name in OUTER_SCOPE_VERT...
python
def is_filter_with_outer_scope_vertex_field_operator(directive): """Return True if we have a filter directive whose operator applies to the outer scope.""" if directive.name.value != 'filter': return False op_name, _ = _get_filter_op_name_and_values(directive) return op_name in OUTER_SCOPE_VERT...
[ "def", "is_filter_with_outer_scope_vertex_field_operator", "(", "directive", ")", ":", "if", "directive", ".", "name", ".", "value", "!=", "'filter'", ":", "return", "False", "op_name", ",", "_", "=", "_get_filter_op_name_and_values", "(", "directive", ")", "return"...
Return True if we have a filter directive whose operator applies to the outer scope.
[ "Return", "True", "if", "we", "have", "a", "filter", "directive", "whose", "operator", "applies", "to", "the", "outer", "scope", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L598-L604
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/filters.py
process_filter_directive
def process_filter_directive(filter_operation_info, location, context): """Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field ...
python
def process_filter_directive(filter_operation_info, location, context): """Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field ...
[ "def", "process_filter_directive", "(", "filter_operation_info", ",", "location", ",", "context", ")", ":", "op_name", ",", "operator_params", "=", "_get_filter_op_name_and_values", "(", "filter_operation_info", ".", "directive", ")", "non_comparison_filters", "=", "{", ...
Return a Filter basic block that corresponds to the filter operation in the directive. Args: filter_operation_info: FilterOperationInfo object, containing the directive and field info of the field where the filter is to be applied. location: Location where this filter...
[ "Return", "a", "Filter", "basic", "block", "that", "corresponds", "to", "the", "filter", "operation", "in", "the", "directive", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/filters.py#L607-L663
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_schema_type_name
def get_schema_type_name(node, context): """Return the GraphQL type name of a node.""" query_path = node.query_path if query_path not in context.query_path_to_location_info: raise AssertionError( u'Unable to find type name for query path {} with context {}.'.format( query...
python
def get_schema_type_name(node, context): """Return the GraphQL type name of a node.""" query_path = node.query_path if query_path not in context.query_path_to_location_info: raise AssertionError( u'Unable to find type name for query path {} with context {}.'.format( query...
[ "def", "get_schema_type_name", "(", "node", ",", "context", ")", ":", "query_path", "=", "node", ".", "query_path", "if", "query_path", "not", "in", "context", ".", "query_path_to_location_info", ":", "raise", "AssertionError", "(", "u'Unable to find type name for que...
Return the GraphQL type name of a node.
[ "Return", "the", "GraphQL", "type", "name", "of", "a", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L5-L13
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_node_at_path
def get_node_at_path(query_path, context): """Return the SqlNode associated with the query path.""" if query_path not in context.query_path_to_node: raise AssertionError( u'Unable to find SqlNode for query path {} with context {}.'.format( query_path, context)) node = con...
python
def get_node_at_path(query_path, context): """Return the SqlNode associated with the query path.""" if query_path not in context.query_path_to_node: raise AssertionError( u'Unable to find SqlNode for query path {} with context {}.'.format( query_path, context)) node = con...
[ "def", "get_node_at_path", "(", "query_path", ",", "context", ")", ":", "if", "query_path", "not", "in", "context", ".", "query_path_to_node", ":", "raise", "AssertionError", "(", "u'Unable to find SqlNode for query path {} with context {}.'", ".", "format", "(", "query...
Return the SqlNode associated with the query path.
[ "Return", "the", "SqlNode", "associated", "with", "the", "query", "path", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L27-L34
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
try_get_column
def try_get_column(column_name, node, context): """Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Ret...
python
def try_get_column(column_name, node, context): """Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Ret...
[ "def", "try_get_column", "(", "column_name", ",", "node", ",", "context", ")", ":", "selectable", "=", "get_node_selectable", "(", "node", ",", "context", ")", "if", "not", "hasattr", "(", "selectable", ",", "'c'", ")", ":", "raise", "AssertionError", "(", ...
Attempt to get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: Optional[column], the SQLAlchemy column i...
[ "Attempt", "to", "get", "a", "column", "by", "name", "from", "the", "selectable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L37-L53
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/sql_context_helpers.py
get_column
def get_column(column_name, node, context): """Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: c...
python
def get_column(column_name, node, context): """Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: c...
[ "def", "get_column", "(", "column_name", ",", "node", ",", "context", ")", ":", "column", "=", "try_get_column", "(", "column_name", ",", "node", ",", "context", ")", "if", "column", "is", "None", ":", "selectable", "=", "get_node_selectable", "(", "node", ...
Get a column by name from the selectable. Args: column_name: str, name of the column to retrieve. node: SqlNode, the node the column is being retrieved for. context: CompilationContext, compilation specific metadata. Returns: column, the SQLAlchemy column if found. Raises an As...
[ "Get", "a", "column", "by", "name", "from", "the", "selectable", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/sql_context_helpers.py#L56-L74
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
get_unique_directives
def get_unique_directives(ast): """Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCo...
python
def get_unique_directives(ast): """Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCo...
[ "def", "get_unique_directives", "(", "ast", ")", ":", "if", "not", "ast", ".", "directives", ":", "return", "dict", "(", ")", "result", "=", "dict", "(", ")", "for", "directive_obj", "in", "ast", ".", "directives", ":", "directive_name", "=", "directive_ob...
Return a dict of directive name to directive object for the given AST node. Any directives that are allowed to exist more than once on any AST node are ignored. For any directives that can only exist up to once, we verify that they are not duplicated raising GraphQLCompilationError in case we find them mor...
[ "Return", "a", "dict", "of", "directive", "name", "to", "directive", "object", "for", "the", "given", "AST", "node", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L27-L54
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
get_local_filter_directives
def get_local_filter_directives(ast, current_schema_type, inner_vertex_fields): """Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applie...
python
def get_local_filter_directives(ast, current_schema_type, inner_vertex_fields): """Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applie...
[ "def", "get_local_filter_directives", "(", "ast", ",", "current_schema_type", ",", "inner_vertex_fields", ")", ":", "result", "=", "[", "]", "if", "ast", ".", "directives", ":", "for", "directive_obj", "in", "ast", ".", "directives", ":", "if", "directive_obj", ...
Get all filter directives that apply to the current field. This helper abstracts away the fact that some vertex field filtering operators apply on the inner scope (the scope of the inner vertex field on which they are applied), whereas some apply on the outer scope (the scope that contains the inner vertex...
[ "Get", "all", "filter", "directives", "that", "apply", "to", "the", "current", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L57-L121
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_property_directives
def validate_property_directives(directives): """Validate the directives that appear at a property field.""" for directive_name in six.iterkeys(directives): if directive_name in VERTEX_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found vertex-only directive {} set on pro...
python
def validate_property_directives(directives): """Validate the directives that appear at a property field.""" for directive_name in six.iterkeys(directives): if directive_name in VERTEX_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found vertex-only directive {} set on pro...
[ "def", "validate_property_directives", "(", "directives", ")", ":", "for", "directive_name", "in", "six", ".", "iterkeys", "(", "directives", ")", ":", "if", "directive_name", "in", "VERTEX_ONLY_DIRECTIVES", ":", "raise", "GraphQLCompilationError", "(", "u'Found verte...
Validate the directives that appear at a property field.
[ "Validate", "the", "directives", "that", "appear", "at", "a", "property", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L124-L129
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_directives
def validate_vertex_directives(directives): """Validate the directives that appear at a vertex field.""" for directive_name in six.iterkeys(directives): if directive_name in PROPERTY_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found property-only directive {} set on ver...
python
def validate_vertex_directives(directives): """Validate the directives that appear at a vertex field.""" for directive_name in six.iterkeys(directives): if directive_name in PROPERTY_ONLY_DIRECTIVES: raise GraphQLCompilationError( u'Found property-only directive {} set on ver...
[ "def", "validate_vertex_directives", "(", "directives", ")", ":", "for", "directive_name", "in", "six", ".", "iterkeys", "(", "directives", ")", ":", "if", "directive_name", "in", "PROPERTY_ONLY_DIRECTIVES", ":", "raise", "GraphQLCompilationError", "(", "u'Found prope...
Validate the directives that appear at a vertex field.
[ "Validate", "the", "directives", "that", "appear", "at", "a", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L132-L137
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_root_vertex_directives
def validate_root_vertex_directives(root_ast): """Validate the directives that appear at the root vertex field.""" directives_present_at_root = set() for directive_obj in root_ast.directives: directive_name = directive_obj.name.value if is_filter_with_outer_scope_vertex_field_operator(direc...
python
def validate_root_vertex_directives(root_ast): """Validate the directives that appear at the root vertex field.""" directives_present_at_root = set() for directive_obj in root_ast.directives: directive_name = directive_obj.name.value if is_filter_with_outer_scope_vertex_field_operator(direc...
[ "def", "validate_root_vertex_directives", "(", "root_ast", ")", ":", "directives_present_at_root", "=", "set", "(", ")", "for", "directive_obj", "in", "root_ast", ".", "directives", ":", "directive_name", "=", "directive_obj", ".", "name", ".", "value", "if", "is_...
Validate the directives that appear at the root vertex field.
[ "Validate", "the", "directives", "that", "appear", "at", "the", "root", "vertex", "field", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L140-L155
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_field_directive_interactions
def validate_vertex_field_directive_interactions(parent_location, vertex_field_name, directives): """Ensure that the specified vertex field directives are not mutually disallowed.""" fold_directive = directives.get('fold', None) optional_directive = directives.get('optional', None) output_source_directi...
python
def validate_vertex_field_directive_interactions(parent_location, vertex_field_name, directives): """Ensure that the specified vertex field directives are not mutually disallowed.""" fold_directive = directives.get('fold', None) optional_directive = directives.get('optional', None) output_source_directi...
[ "def", "validate_vertex_field_directive_interactions", "(", "parent_location", ",", "vertex_field_name", ",", "directives", ")", ":", "fold_directive", "=", "directives", ".", "get", "(", "'fold'", ",", "None", ")", "optional_directive", "=", "directives", ".", "get",...
Ensure that the specified vertex field directives are not mutually disallowed.
[ "Ensure", "that", "the", "specified", "vertex", "field", "directives", "are", "not", "mutually", "disallowed", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L158-L188
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/directive_helpers.py
validate_vertex_field_directive_in_context
def validate_vertex_field_directive_in_context(parent_location, vertex_field_name, directives, context): """Ensure that the specified vertex field directives are allowed in the current context.""" fold_directive = directives.get('fold', None) optional_directive...
python
def validate_vertex_field_directive_in_context(parent_location, vertex_field_name, directives, context): """Ensure that the specified vertex field directives are allowed in the current context.""" fold_directive = directives.get('fold', None) optional_directive...
[ "def", "validate_vertex_field_directive_in_context", "(", "parent_location", ",", "vertex_field_name", ",", "directives", ",", "context", ")", ":", "fold_directive", "=", "directives", ".", "get", "(", "'fold'", ",", "None", ")", "optional_directive", "=", "directives...
Ensure that the specified vertex field directives are allowed in the current context.
[ "Ensure", "that", "the", "specified", "vertex", "field", "directives", "are", "allowed", "in", "the", "current", "context", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/directive_helpers.py#L191-L231
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_string
def _safe_match_string(value): """Sanitize and represent a string argument in MATCH.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attempting...
python
def _safe_match_string(value): """Sanitize and represent a string argument in MATCH.""" if not isinstance(value, six.string_types): if isinstance(value, bytes): # should only happen in py3 value = value.decode('utf-8') else: raise GraphQLInvalidArgumentError(u'Attempting...
[ "def", "_safe_match_string", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "value", "=", "value", ".", "decode", "(", "'utf-8'", ")"...
Sanitize and represent a string argument in MATCH.
[ "Sanitize", "and", "represent", "a", "string", "argument", "in", "MATCH", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L17-L29
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/match_formatting.py
_safe_match_date_and_datetime
def _safe_match_date_and_datetime(graphql_type, expected_python_types, value): """Represent date and datetime objects as MATCH strings.""" # Python datetime.datetime is a subclass of datetime.date, # but in this case, the two are not interchangeable. # Rather than using isinstance, we will therefore che...
python
def _safe_match_date_and_datetime(graphql_type, expected_python_types, value): """Represent date and datetime objects as MATCH strings.""" # Python datetime.datetime is a subclass of datetime.date, # but in this case, the two are not interchangeable. # Rather than using isinstance, we will therefore che...
[ "def", "_safe_match_date_and_datetime", "(", "graphql_type", ",", "expected_python_types", ",", "value", ")", ":", "value_type", "=", "type", "(", "value", ")", "if", "not", "any", "(", "value_type", "==", "x", "for", "x", "in", "expected_python_types", ")", "...
Represent date and datetime objects as MATCH strings.
[ "Represent", "date", "and", "datetime", "objects", "as", "MATCH", "strings", "." ]
f6079c6d10f64932f6b3af309b79bcea2123ca8f
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/match_formatting.py#L32-L50
train