[Python] Cognite Data Fusion Python SDK - how to delete edges that lead to a node with a...

Discussão em 'Python' iniciado por Stack, Abril 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the Cognite Data Fusion Python SDK.

    While deleting a node, e.g....

    client.data_modeling.instances.delete(NodeId(space='some-space', external_id=deleted_node_id))


    I want to also delete the edge(s) from the parent in order to avoid leaving orphan edges in the database.

    Problem: how can I look-up such edges?

    I know how to get all edges (and then filter by the end_node attribute), but that would be very inefficient:

    edges = client.data_modeling.instances.list(
    instance_type="edge", limit=-1)


    How could I construct the Filter for the end_node (to match the deleted_node_id) and ideally the type (to equal Child type)? E.g.

    edges = client.data_modeling.instances.list(
    instance_type="edge",
    filter=And(Equal(???), Equal(???)),
    limit=-1)


    Because then I could just delete all those edges with one client.data_modeling.instances.delete(edges) call.

    Continue reading...

Compartilhe esta Página