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

Optimize time of sess.gremlin and sess.close #170

Merged
merged 2 commits into from
Mar 2, 2021

Conversation

lidongze0629
Copy link
Collaborator

What do these changes do?

  • Deleted several unnecessary sleep operations during process of gremlin launching
  • Launch gremlin server's pod implicitly when a property graph created.

Related issue number

Fixes #157

@lidongze0629 lidongze0629 requested a review from sighingnow March 1, 2021 07:26
python/graphscope/framework/graph.py Show resolved Hide resolved
python/graphscope/interactive/__init__.py Outdated Show resolved Hide resolved
python/graphscope/interactive/query.py Show resolved Hide resolved
python/graphscope/client/session.py Show resolved Hide resolved
def _launch_interactive_instance_impl(self):
try:
sess = get_session_by_id(self.session_id)
sess.gremlin(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should add a option to control whether automatically create interactive instance whenever a graph is loaded
Reason: If always create, when user want to get the interactive instance, they call sess.gremlin(graph, params), and the method sess.gremlin() will simply find in the cache and return, the params is silently ignored, which may be confusing. Also since user can never reach the logic of creating instance, it should be in another private method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There may be another circumstance that user can close a previous instance, and create a new one. We allow that. And this procedure of course will takes about ~30s. To prevent user wondering why two gremlin call consumed very different time, I think you should add the silent thread creating technique to somewhere in the doc, and in the session/graph comments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add auto_create_interactive_engine in config.py. Defaults to True.

Copy link
Collaborator

@siyuan0322 siyuan0322 Mar 2, 2021

Choose a reason for hiding this comment

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

To prevent user wondering why two gremlin call consumed very different time, I think you should add the silent thread creating technique to somewhere in the doc, and in the session/graph comments.

Apart from the doc, when user run .gremlin(sess, params) with params, (we know the params are ignored), maybe we should print a warning to remind user that the params is not taken effect. And let them know the backend behavior.
i.e., logger.warning('params is ignored since xxx. see more in /path/to/doc/section/')

We should also tell them how to make params take effect without start the session from the beginning. I could come up with close previous interactive instance, and create a new one with params by call gremlin() manually. Please check the close-and-reopen procedure will behave as expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice advice. I have updated doc of gremlin, which clarify how to create a new instance under the same graph with different engine_params.
I didn't add logger.warning in code, as gremlin may run in a thread and hidden from users.

Copy link
Collaborator Author

@lidongze0629 lidongze0629 Mar 2, 2021

Choose a reason for hiding this comment

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

A new issue opened to trace InteractiveQuery create failed after close.
#172

python/graphscope/client/session.py Outdated Show resolved Hide resolved
python/graphscope/client/session.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@sighingnow sighingnow left a comment

Choose a reason for hiding this comment

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

Now looks good enough to me. Thanks for the effort 👍 .

@codecov-io
Copy link

codecov-io commented Mar 1, 2021

Codecov Report

Merging #170 (7b4b487) into main (10f36b1) will decrease coverage by 12.51%.
The diff coverage is 31.64%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main     #170       +/-   ##
===========================================
- Coverage   78.57%   66.05%   -12.52%     
===========================================
  Files          51       50        -1     
  Lines        4606     4472      -134     
===========================================
- Hits         3619     2954      -665     
- Misses        987     1518      +531     
Impacted Files Coverage Δ
python/graphscope/client/session.py 62.55% <12.00%> (-10.35%) ⬇️
python/graphscope/interactive/query.py 40.54% <33.33%> (-51.92%) ⬇️
python/graphscope/framework/graph.py 78.23% <42.85%> (-10.39%) ⬇️
python/graphscope/config.py 100.00% <100.00%> (ø)
python/graphscope/framework/loader.py 76.43% <100.00%> (-4.46%) ⬇️
python/graphscope/interactive/__init__.py 100.00% <100.00%> (ø)
python/graphscope/deploy/kubernetes/utils.py 12.43% <0.00%> (-61.14%) ⬇️
python/graphscope/deploy/kubernetes/cluster.py 23.80% <0.00%> (-57.94%) ⬇️
...n/graphscope/deploy/kubernetes/resource_builder.py 27.95% <0.00%> (-34.30%) ⬇️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10f36b1...7b4b487. Read the comment docs.


nest_asyncio.apply()
except: # noqa: E722
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why restore this change?

# Otherwise, you should create a GIE instance manually by `sess.gremlin` if
# `initializing_interactive_engine` is False
initializing_interactive_engine = True

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if the GSConfig docs could be rendered in sphinx properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We didn't expose GSConfig in Doc. Instead, graphscope.set_option and graphscope.get_option exposed.

https://graphscope.io/docs/reference/generated/graphscope.set_option.html#graphscope.set_option

def closed(self):
"""Return if the current instance is closed."""
return self._closed
return self._status == InteractiveQueryStatus.Closed
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you have three status type, what will happen if the status is initializing and execute is called?
Will the call be blocked? or error out?
ref:

if self.closed():
raise RuntimeError("Interactive query is closed.")
return self._client.submit(query)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

excute subgraph and traversal_source can only run under running status. Otherwise, raise an exception.

pass waiting for delete to InteravtiveQuery
@lidongze0629 lidongze0629 merged commit b3cf8f6 into alibaba:main Mar 2, 2021
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.

Improve the response time of each step in Python
4 participants