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

Add deprecated decorator and apply it on gremlin #3007

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ curl -XPOST $url -d 'crew_graph = session.load_from(
)' >/dev/null

curl -XPOST $url -d 'crew_gremlin = session.gremlin(crew_graph)'>/dev/null
code=$(curl -XPOST $url -d 'crew_gremlin._graph_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
code=$(curl -XPOST $url -d 'crew_gremlin.gremlin_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
res=$(cat ./gremlin.tmp)
if [ -f "gremlin.tmp" ];then
rm gremlin.tmp 1>/dev/null 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ curl -XPOST $url -d 'grateful_graph = session.load_from(
)' >/dev/null

curl -XPOST $url -d 'grateful_gremlin = session.gremlin(grateful_graph)' >/dev/null
code=$(curl -XPOST $url -d 'grateful_gremlin._graph_url' --write-out %{http_code} --silent --output ./grateful.tmp)
code=$(curl -XPOST $url -d 'grateful_gremlin.gremlin_url' --write-out %{http_code} --silent --output ./grateful.tmp)
res=$(cat ./grateful.tmp)
if [ -f "grateful.tmp" ];then
rm grateful.tmp 1>/dev/null 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cur_dir = $(cd "$(dirname "$0")"; pwd)
curl -XPOST $url -d 'modern_graph = load_modern_graph(session, "/testingdata/modern_graph")' >/dev/null

curl -XPOST $url -d 'modern_gremlin = session.gremlin(modern_graph)'>/dev/null
code=$(curl -XPOST $url -d 'modern_gremlin._graph_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
code=$(curl -XPOST $url -d 'modern_gremlin.gremlin_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
res=$(cat ./gremlin.tmp)
if [ -f "gremlin.tmp" ];then
rm gremlin.tmp 1>/dev/null 2>&1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ curl -XPOST $url -d 'sink_graph = session.load_from(
)' >/dev/null

curl -XPOST $url -d 'sink_gremlin = session.gremlin(sink_graph)'>/dev/null
code=$(curl -XPOST $url -d 'sink_gremlin._graph_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
code=$(curl -XPOST $url -d 'sink_gremlin.gremlin_url' --write-out %{http_code} --silent --output ./gremlin.tmp)
res=`cat ./gremlin.tmp`
if [ -f "gremlin.tmp" ];then
rm gremlin.tmp 1>/dev/null 2>&1
Expand Down
4 changes: 2 additions & 2 deletions python/graphscope/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def __init__(self, addr, gremlin_endpoint, username="", password="") -> None:
self._write_service_stub = write_service_pb2_grpc.ClientWriteStub(channel)
self._client_id = None
self._metadata = self._encode_metadata(username, password)
graph_url = "ws://%s/gremlin" % self._gremlin_endpoint
gremlin_url = f"ws://{self._gremlin_endpoint}/gremlin"
self._conn = DriverRemoteConnection(
graph_url, "g", username=username, password=password
gremlin_url, "g", username=username, password=password
)

def _get_channel_options(self):
Expand Down
5 changes: 4 additions & 1 deletion python/graphscope/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import json
import logging
import os
import pickle
import signal
import threading
import time
Expand Down Expand Up @@ -62,6 +61,7 @@
from graphscope.framework.operation import Operation
from graphscope.framework.utils import decode_dataframe
from graphscope.framework.utils import decode_numpy
from graphscope.framework.utils import deprecated
from graphscope.framework.utils import random_string
from graphscope.interactive.query import InteractiveQuery
from graphscope.proto import graph_def_pb2
Expand Down Expand Up @@ -1293,6 +1293,7 @@ def _run_on_local(self):
self._config_params["port"] = None
self._config_params["vineyard_socket"] = ""

@deprecated("Please use `sess.interactive` instead.")
def gremlin(self, graph, params=None):
"""This method is going to be deprecated.
Use :meth:`interactive` to get an interactive engine handler supports
Expand Down Expand Up @@ -1351,6 +1352,7 @@ def interactive(self, graph, params=None):
graph._attach_interactive_instance(interactive_query)
return interactive_query

@deprecated("Please use `graphlearn` instead.")
def learning(self, graph, nodes=None, edges=None, gen_labels=None):
"""Start a graph learning engine.

Expand Down Expand Up @@ -1730,6 +1732,7 @@ def g(
)


@deprecated("Please use `graphscope.interactive` instead.")
def gremlin(graph, params=None):
"""This method is going to be deprecated in the future.
Use :meth:`graphscope.interactive` instead.
Expand Down
12 changes: 12 additions & 0 deletions python/graphscope/framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import tempfile
import threading
import time
import warnings
from queue import Empty
from queue import Queue

Expand Down Expand Up @@ -680,3 +681,14 @@ def _to_numpy_dtype(dtype):
if npdtype is None:
raise NotImplementedError("Do not support type {}".format(dtype))
return npdtype


def deprecated(msg):
def decorator(func):
def wrapper(*args, **kwargs):
warnings.warn(f"Deprecated usage: {msg}", DeprecationWarning, stacklevel=2)
return func(*args, **kwargs)

return wrapper

return decorator
16 changes: 5 additions & 11 deletions python/graphscope/interactive/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
#

import logging
from copy import deepcopy
from enum import Enum

from gremlin_python.driver.client import Client
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.anonymous_traversal import traversal

from graphscope.framework.dag import DAGNode
from graphscope.framework.dag_utils import gremlin_to_subgraph
from graphscope.framework.utils import deprecated

logger = logging.getLogger("graphscope")

Expand Down Expand Up @@ -59,25 +58,20 @@ def __init__(self, graph, frontend_gremlin_endpoint, frontend_cypher_endpoint):
# graph object id stored in vineyard
self._graph = graph
self._session = graph._session
frontend_gremlin_endpoint = frontend_gremlin_endpoint.split(",")
self._gremlin_url = [
f"ws://{endpoint}/gremlin" for endpoint in frontend_gremlin_endpoint
f"ws://{endpoint}/gremlin"
for endpoint in frontend_gremlin_endpoint.split(",")
]
frontend_cypher_endpoint = frontend_cypher_endpoint.split(",")
self._cypher_url = [
f"neo4j://{endpoint}" for endpoint in frontend_cypher_endpoint
f"neo4j://{endpoint}" for endpoint in frontend_cypher_endpoint.split(",")
]
self._conn = None
self._gremlin_client = None
self._cypher_driver = None
self.closed = False

@property
def _graph_url(self):
"""This will be deprecated in the future, use `_gremlin_url` instead."""
return self._gremlin_url

@property
@deprecated("Please use `gremlin_url` instead")
def graph_url(self):
"""This will be deprecated in the future, use `gremlin_url` instead."""
return self._gremlin_url
Expand Down
Loading