(name_or_id: str)
| 124 | |
| 125 | |
| 126 | def get_graph_id_by_name(name_or_id: str): |
| 127 | graphs = list_graphs() |
| 128 | id_candidate = [] |
| 129 | for g in graphs: |
| 130 | if name_or_id == g.id: |
| 131 | return name_or_id |
| 132 | if name_or_id == g.name: |
| 133 | id_candidate.append(g.id) |
| 134 | if not id_candidate: |
| 135 | raise RuntimeError( |
| 136 | f"Graph '{name_or_id}' not exists, see graph information with `ls` command." |
| 137 | ) |
| 138 | if len(id_candidate) > 1: |
| 139 | raise RuntimeError( |
| 140 | f"Found multiple id candidates {id_candidate} for graph {name_or_id}, please choose one." |
| 141 | ) |
| 142 | return id_candidate[0] |
| 143 | |
| 144 | |
| 145 | def get_graph_name_by_id(graph_identifier: str): |
no test coverage detected