Skip to content

Commit

Permalink
chore: Refine the logic to probe GRAPHSCOPE_HOME (#3082)
Browse files Browse the repository at this point in the history
Committed-by: siyuanzhang.zsy from Dev container

Previously it could not auto detect grape_engine from `/opt/graphscope`,
need to rely on `GRAPHSCOPE_HOME` be set.

Also try to simplify the logic to probe GRAPHSCOPE_HOME, and others. But
its still messy.

And delete the unused `.install_prefix` usage.
  • Loading branch information
siyuan0322 authored Aug 4, 2023
1 parent 7f53b76 commit f744640
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 60 deletions.
8 changes: 0 additions & 8 deletions coordinator/gscoordinator/local_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ def create_interactive_instance(

env = os.environ.copy()
env["GRAPHSCOPE_HOME"] = GRAPHSCOPE_HOME
if ".install_prefix" in INTERACTIVE_ENGINE_SCRIPT:
env["GRAPHSCOPE_HOME"] = os.path.dirname(
os.path.dirname(INTERACTIVE_ENGINE_SCRIPT)
)

if os.environ.get("PARALLEL_INTERACTIVE_EXECUTOR_ON_VINEYARD", "OFF") != "ON":
# only one GIE/GAIA executor will be launched locally, even there are
Expand Down Expand Up @@ -323,10 +319,6 @@ def close_analytical_instance(self):
def close_interactive_instance(self, object_id):
env = os.environ.copy()
env["GRAPHSCOPE_HOME"] = GRAPHSCOPE_HOME
if ".install_prefix" in INTERACTIVE_ENGINE_SCRIPT:
env["GRAPHSCOPE_HOME"] = os.path.dirname(
os.path.dirname(INTERACTIVE_ENGINE_SCRIPT)
)
cmd = [
INTERACTIVE_ENGINE_SCRIPT,
"close_gremlin_instance_on_local",
Expand Down
103 changes: 51 additions & 52 deletions coordinator/gscoordinator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,52 +80,59 @@
except ModuleNotFoundError:
COORDINATOR_HOME = os.path.abspath(os.path.join(__file__, "..", ".."))

# template directory for codegen
TEMPLATE_DIR = os.path.join(COORDINATOR_HOME, "gscoordinator", "template")

# builtin app resource
BUILTIN_APP_RESOURCE_PATH = os.path.join(
COORDINATOR_HOME, "gscoordinator", "builtin/app/builtin_app.gar"
)
# default config file in gar resource
DEFAULT_GS_CONFIG_FILE = ".gs_conf.yaml"
DEFAULT_GRAPHSCOPE_HOME = "/usr/local"

# GRAPHSCOPE_HOME
# 1) get from environment variable `GRAPHSCOPE_HOME`, if not exist,
# 2) infer from COORDINATOR_HOME
GRAPHSCOPE_HOME = os.environ.get("GRAPHSCOPE_HOME", None)

# resolve from pip installed package
if GRAPHSCOPE_HOME is None:
if os.path.isdir(os.path.join(COORDINATOR_HOME, "graphscope.runtime")):
GRAPHSCOPE_HOME = os.path.join(COORDINATOR_HOME, "graphscope.runtime")

# find from DEFAULT_GRAPHSCOPE_HOME
if GRAPHSCOPE_HOME is None:
if os.path.isdir(DEFAULT_GRAPHSCOPE_HOME):
GRAPHSCOPE_HOME = DEFAULT_GRAPHSCOPE_HOME
# Note: The order of locations matters
possible_locations = [
os.path.join(COORDINATOR_HOME, "graphscope.runtime"), # installed by pip
"/opt/graphscope", # installed by gs script
"/usr/local", # a popular location
]

# resolve from develop source tree
# Here the GRAPHSCOPE_HOME has been set to the root of the source tree,
# So the engine location doesn't need to check again,
# just rely on GRAPHSCOPE_HOME.
if GRAPHSCOPE_HOME is None:
for location in possible_locations:
ANALYTICAL_ENGINE_PATH = os.path.join(location, "bin", "grape_engine")
if os.path.isfile(ANALYTICAL_ENGINE_PATH):
GRAPHSCOPE_HOME = location
break

if GRAPHSCOPE_HOME is not None:
ANALYTICAL_ENGINE_HOME = GRAPHSCOPE_HOME
ANALYTICAL_ENGINE_PATH = os.path.join(GRAPHSCOPE_HOME, "bin", "grape_engine")
INTERACTIVE_ENGINE_SCRIPT = os.path.join(GRAPHSCOPE_HOME, "bin", "giectl")
else:
# resolve from develop source tree
# Here the GRAPHSCOPE_HOME has been set to the root of the source tree,
# So the engine location doesn't need to check again,
# just rely on GRAPHSCOPE_HOME.
GRAPHSCOPE_HOME = os.path.join(COORDINATOR_HOME, "..")
ANALYTICAL_ENGINE_HOME = os.path.join(GRAPHSCOPE_HOME, "analytical_engine")
ANALYTICAL_ENGINE_PATH = os.path.join(
ANALYTICAL_ENGINE_HOME, "build", "grape_engine"
)

# ANALYTICAL_ENGINE_HOME
# 1) infer from GRAPHSCOPE_HOME
ANALYTICAL_ENGINE_HOME = GRAPHSCOPE_HOME
ANALYTICAL_ENGINE_PATH = os.path.join(ANALYTICAL_ENGINE_HOME, "bin", "grape_engine")
if not os.path.isfile(ANALYTICAL_ENGINE_PATH):
# try to get analytical engine from build dir
if os.path.isfile(
os.path.join(GRAPHSCOPE_HOME, "analytical_engine", "build", "grape_engine")
):
ANALYTICAL_ENGINE_HOME = os.path.join(GRAPHSCOPE_HOME, "analytical_engine")
ANALYTICAL_ENGINE_PATH = os.path.join(
ANALYTICAL_ENGINE_HOME, "build", "grape_engine"
)
INTERACTIVE_ENGINE_SCRIPT = os.path.join(
GRAPHSCOPE_HOME,
"interactive_engine",
"assembly",
"src",
"bin",
"graphscope",
"giectl",
)

# template directory for code generation
TEMPLATE_DIR = os.path.join(COORDINATOR_HOME, "gscoordinator", "template")

# builtin app resource
BUILTIN_APP_RESOURCE_PATH = os.path.join(
COORDINATOR_HOME, "gscoordinator", "builtin", "app", "builtin_app.gar"
)
# default config file in gar resource
DEFAULT_GS_CONFIG_FILE = ".gs_conf.yaml"

ANALYTICAL_BUILTIN_SPACE = os.path.join(GRAPHSCOPE_HOME, "precompiled", "builtin")

Expand All @@ -152,20 +159,6 @@
)


# INTERACTIVE_ENGINE_SCRIPT
INTERACTIVE_INSTANCE_TIMEOUT_SECONDS = 120 # 2 mins
INTERACTIVE_ENGINE_SCRIPT = os.path.join(GRAPHSCOPE_HOME, "bin", "giectl")
if not os.path.isfile(INTERACTIVE_ENGINE_SCRIPT):
if os.path.isfile(
os.path.join(GRAPHSCOPE_HOME, ".install_prefix", "bin", "giectl")
):
INTERACTIVE_ENGINE_SCRIPT = os.path.join(
GRAPHSCOPE_HOME, ".install_prefix", "bin", "giectl"
)

# default threads per worker configuration for GIE/GAIA
INTERACTIVE_ENGINE_THREADS_PER_WORKER = 2

# JAVA SDK related CONSTANTS
LLVM4JNI_HOME = os.environ.get("LLVM4JNI_HOME", None)
LLVM4JNI_USER_OUT_DIR_BASE = "user-llvm4jni-output"
Expand All @@ -177,9 +170,15 @@

GIRAPH_DRIVER_CLASS = "com.alibaba.graphscope.app.GiraphComputationAdaptor"

# 2 GB
# increase grpc max message size to 2 GB
GS_GRPC_MAX_MESSAGE_LENGTH = 2 * 1024 * 1024 * 1024 - 1

# INTERACTIVE_ENGINE_SCRIPT
INTERACTIVE_INSTANCE_TIMEOUT_SECONDS = 120 # 2 mins

# default threads per worker configuration for GIE/GAIA
INTERACTIVE_ENGINE_THREADS_PER_WORKER = 2


def get_timestamp() -> float:
return datetime.datetime.timestamp(datetime.datetime.now())
Expand Down

0 comments on commit f744640

Please sign in to comment.