noctis.repository.neo4j.neo4j_queries.CustomQuery

pydantic model noctis.repository.neo4j.neo4j_queries.CustomQuery[source]

Custom query class for executing queries from YAML files

Show JSON schema
{
   "title": "CustomQuery",
   "description": "Custom query class for executing queries from YAML files",
   "type": "object",
   "properties": {
      "query_name": {
         "title": "Query Name",
         "type": "string"
      },
      "query_type": {
         "default": "retrieve_stats",
         "title": "Query Type",
         "type": "string"
      },
      "query": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            }
         ],
         "title": "Query"
      },
      "query_args_required": {
         "items": {
            "type": "string"
         },
         "title": "Query Args Required",
         "type": "array"
      },
      "query_args_optional": {
         "items": {
            "type": "string"
         },
         "title": "Query Args Optional",
         "type": "array"
      },
      "graph_schema": {
         "$ref": "#/$defs/GraphSchema",
         "default": null
      }
   },
   "$defs": {
      "GraphSchema": {
         "additionalProperties": false,
         "description": "Base model representing the schema of a NOCtis graph",
         "properties": {
            "base_nodes": {
               "additionalProperties": {
                  "type": "string"
               },
               "default": {
                  "chemical_equation": "ChemicalEquation",
                  "molecule": "Molecule"
               },
               "minProperties": 2,
               "title": "Base Nodes",
               "type": "object"
            },
            "base_relationships": {
               "additionalProperties": {
                  "additionalProperties": {
                     "type": "string"
                  },
                  "type": "object"
               },
               "default": {
                  "product": {
                     "end_node": "molecule",
                     "start_node": "chemical_equation",
                     "type": "PRODUCT"
                  },
                  "reactant": {
                     "end_node": "chemical_equation",
                     "start_node": "molecule",
                     "type": "REACTANT"
                  }
               },
               "minProperties": 2,
               "title": "Base Relationships",
               "type": "object"
            },
            "extra_nodes": {
               "additionalProperties": {
                  "type": "string"
               },
               "title": "Extra Nodes",
               "type": "object"
            },
            "extra_relationships": {
               "additionalProperties": {
                  "additionalProperties": {
                     "type": "string"
                  },
                  "type": "object"
               },
               "title": "Extra Relationships",
               "type": "object"
            }
         },
         "title": "GraphSchema",
         "type": "object"
      }
   },
   "required": [
      "query_name",
      "query"
   ]
}

Fields:
Validators:
field graph_schema: GraphSchema = None
Validated by:
field query: str | list[str] [Required]
Validated by:
field query_args_optional: list[str] [Optional]
Validated by:
field query_args_required: list[str] [Optional]
Validated by:
field query_name: str [Required]
Validated by:
field query_type: str = 'retrieve_stats'
Validated by:
classmethod build_from_dict(query_dict: dict) CustomQuery[source]

Build a CustomQuery instance from a dictionary

classmethod from_yaml(yaml_file: str, query_name: str) CustomQuery[source]

Load a specific query from a YAML file

get_query() str | list[str][source]
classmethod list_queries(yaml_file: str) list[str][source]

List all query names available in the YAML file

validate_query_kwargs(kwargs: dict[str, any]) None[source]

Validate the query arguments

validator validate_query_structure  »  all fields[source]
parameters_embedded: ClassVar[bool] = False