Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the error message when passing unexpected arguments to g.project() #2667

Merged
merged 1 commit into from
Apr 28, 2023

Conversation

sighingnow
Copy link
Collaborator

Related issue number

Fixes #2619 (comment)
Fixes #2626 (reply in thread)

After this pull request, the error message looks like

In [4]: g = g.project(vertices={"paper"}, edges={"cites"})
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:1                                                                                    │
│                                                                                                  │
│ /usr/local/lib/python3.11/site-packages/graphscope/framework/graph.py:1136 in project            │
│                                                                                                  │
│   1133 │   ):                                                                                    │
│   1134 │   │   if not self.loaded():                                                             │
│   1135 │   │   │   raise RuntimeError("The graph is not loaded")                                 │
│ ❱ 1136 │   │   return self._session._wrapper(self._graph_node.project(vertices, edges))          │
│   1137 │                                                                                         │
│   1138def _attach_interactive_instance(self, instance):                                     │
│   1139 │   │   """Store the instance when a new interactive instance is started.                 │
│                                                                                                  │
│ /usr/local/lib/python3.11/site-packages/graphscope/framework/graph.py:691 in project             │
│                                                                                                  │
│    688 │   │   """                                                                               │
│    689 │   │   check_argument(self.graph_type == graph_def_pb2.ARROW_PROPERTY)                   │
│    690 │   │   if isinstance(vertices, set) or isinstance(edges, set):                           │
│ ❱  691 │   │   │   raise ValueError("The project vertices or edges cannot be a set, rather, a d  │
│    692 │   │   │   │   │   │   │    "\n"                                                         │
│    693 │   │   │   │   │   │   │    "    g.project(vertices={'person': ['name', 'age']},\n"      │
│    694 │   │   │   │   │   │   │    "              edges={'knows': ['weight']})\n"               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError:
The project vertices or edges cannot be a set, rather, a dict is expected, e.g.,

    g.project(vertices={'person': ['name', 'age']},
              edges={'knows': ['weight']})

The property list for vertices and edges can be empty if not needed, e.g.,

    g.project(vertices={'person': []}, edges={'knows': []})

"\n"
" g.project(vertices={'person': []}, edges={'knows': []})\n"
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add where the key is the label name and the value is a list of properties after the first line is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

…ject()`.

Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
@sighingnow sighingnow merged commit 8168275 into alibaba:main Apr 28, 2023
7 checks passed
@sighingnow sighingnow deleted the ht/build-mac branch April 28, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants