Beispiel #1
0
def schema_request(overwrite: bool = False):
    def query_func():
        url = f"{api_url}/status/db"
        payload = {"metric": "schema", "db": "epigraphdb"}
        r = requests.get(url, params=payload, headers=api_request_headers)
        r.raise_for_status()
        res = r.json()[0]["value"]
        return res

    doc_name = "schema_data"
    coll_name = "schema"
    schema_data = cache_func_call(
        coll_name=coll_name,
        doc_name=doc_name,
        func=query_func,
        params=None,
        overwrite=overwrite,
    )

    nodes_data: Dict[str, Any] = {
        key: value
        for key, value in schema_data.items() if value["type"] == "node"
    }

    edges_data: Dict[str, Any] = {
        key: value
        for key, value in schema_data.items()
        if value["type"] == "relationship"
    }
    return nodes_data, edges_data
Beispiel #2
0
def get_metadata_meta_rel_list(
    db: EpigraphdbGraphsExtended = EpigraphdbGraphsExtended.epigraphdb,
    hostname: Optional[str] = None,
    bolt_port: Optional[str] = None,
    user: Optional[str] = None,
    password: Optional[str] = None,
    overwrite: bool = False,
) -> List[str]:
    if db.value in ["epigraphdb", "pqtl"]:
        res = cache_func_call(
            coll_name="meta_rel",
            doc_name=db.value,
            func=get_meta_rel,
            params={"db": db.value},
            overwrite=overwrite,
        )
    else:
        res = get_meta_rel(
            db="custom",
            hostname=hostname,
            bolt_port=bolt_port,
            user=user,
            password=password,
        )
    return res
Beispiel #3
0
def get_metrics(overwrite: bool = False):

    meta_node_res = cache_func_call(
        coll_name="metrics",
        doc_name="meta_node",
        func=query_metric_meta_node,
        params=None,
        overwrite=overwrite,
    )
    meta_rel_res = cache_func_call(
        coll_name="metrics",
        doc_name="meta_rel",
        func=query_metric_meta_rel,
        params=None,
        overwrite=overwrite,
    )

    res = {"meta_node": meta_node_res, "meta_rel": meta_rel_res}
    return res
Beispiel #4
0
def process_query(spec: GalleryGraph, overwrite: bool = False):
    coll_name = "gallery"
    doc_name = spec.name
    if spec.query_type == "cypher":
        results = cache_func_call(
            coll_name=coll_name,
            doc_name=doc_name,
            func=request_cypher,
            params=dict(query=spec.query),
            overwrite=overwrite,
        )

    if len(results) > 0:
        results_df = pd.json_normalize(results)
        graph_data = network_graph(
            df=results_df,
            node_schemas=spec.schema.nodes,
            edge_schemas=spec.schema.edges,
            limit=None,
        )
    else:
        graph_data = None

    return graph_data