From 0bd27dea0aa5f2623d1e3a1aed60a29379f8487a Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Thu, 5 Sep 2024 14:06:23 +0800 Subject: [PATCH] feat(interactive): Support customizing service configuration via `gsctl` (#4205) The customized engine configuration can be specified during the deployment of the interactive instance. - [x] Add CI test verify it works --- .github/workflows/flex-interactive.yml | 5 +- docs/flex/interactive/configuration.md | 84 ++++++++----------------- python/graphscope/gsctl/commands/dev.py | 31 ++++++++- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/.github/workflows/flex-interactive.yml b/.github/workflows/flex-interactive.yml index 37ca3a52fd53..24e291eab1a7 100644 --- a/.github/workflows/flex-interactive.yml +++ b/.github/workflows/flex-interactive.yml @@ -54,10 +54,13 @@ jobs: # install gsctl python3 -m pip install ${GITHUB_WORKSPACE}/python/dist/*.whl # launch service: 8080 for coordinator http port; 7687 for cypher port; - docker run -p 8080:8080 -p 7688:7687 graphscope/interactive:latest --enable-coordinator & + gsctl instance deploy --type interactive --image-registry graphscope --image-tag latest --interactive-config ${GITHUB_WORKSPACE}/flex/tests/hqps/interactive_config_test.yaml sleep 20 # test python3 -m pip install --no-cache-dir pytest pytest-xdist python3 -m pytest -d --tx popen//python=python3 \ -s -v \ $(dirname $(python3 -c "import graphscope.gsctl as gsctl; print(gsctl.__file__)"))/tests/test_interactive.py + + # destroy instance + gsctl instance destroy --type interactive -y diff --git a/docs/flex/interactive/configuration.md b/docs/flex/interactive/configuration.md index a75ca8396840..79729dca1e80 100644 --- a/docs/flex/interactive/configuration.md +++ b/docs/flex/interactive/configuration.md @@ -15,12 +15,13 @@ Below is a list of all configurable items: | admin-port | 7777 | The port of the interactive admin service | v0.3 | | storedproc-port | 10000 | The port of the interactive stored procedure service | v0.3 | | cypher-port | 7687 | The port of the cypher service | v0.3 | +| config | None | The customized configuration file for engine interactive service | v0.4 | -### Default Ports +### Ports By default, Interactive will launch the following services on these ports: @@ -43,74 +44,46 @@ The Gremlin service is disabled by default. To enable it, add the `--gremlin-por gsctl instance deploy --type interactive --coordinator-port 8081 --admin-port 7778 --cypher-port 7688 --storedproc-port 10001 --gremlin-port 8183 ``` --> +### Service Configuration - +| compiler.query_timeout | 3000000 | The maximum time for compiler to wait engine's reply, in `ms` | 0.0.3 | + +#### TODOs +We currently only allow service configuration during instance deployment. In the near future, we will support: +- Graph-level configurations +- Modifying service configurations \ No newline at end of file diff --git a/python/graphscope/gsctl/commands/dev.py b/python/graphscope/gsctl/commands/dev.py index 8744b46f1df3..4b1ec9ad91d0 100644 --- a/python/graphscope/gsctl/commands/dev.py +++ b/python/graphscope/gsctl/commands/dev.py @@ -42,6 +42,7 @@ # Interactive docker container config INTERACTIVE_DOCKER_CONTAINER_NAME = "gs-interactive-instance" INTERACTIVE_DOCKER_CONTAINER_LABEL = "flex=interactive" +INTERACTIVE_DOCKER_DEFAULT_CONFIG_PATH = "/opt/flex/share/interactive_config.yaml" scripts_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "scripts") install_deps_script = os.path.join(scripts_dir, "install_deps.sh") @@ -182,6 +183,12 @@ def interactive(app, graphscope_repo): show_default=True, required=False, ) +@click.option( + "--interactive-config", + help="Interactive config file path [docker only]", + required=False, + default=None, +) @click.option( "--gremlin-port", help="Mapping port of gremlin query, -1 means disable mapping [docker only]", @@ -220,6 +227,7 @@ def deploy( storedproc_port, cypher_port, gremlin_port, + interactive_config, ): # noqa: F811 """Deploy a GraphScope Flex instance""" cmd = [] @@ -244,6 +252,17 @@ def deploy( if gremlin_port != -1: cmd.extend(["-p", f"{gremlin_port}:8182"]) image = f"{image_registry}/{type}:{image_tag}" + if interactive_config is not None: + if not os.path.isfile(interactive_config): + click.secho( + f"Interactive config file {interactive_config} does not exist.", + fg="red", + ) + return + interactive_config = os.path.abspath(interactive_config) + cmd.extend( + ["-v", f"{interactive_config}:{INTERACTIVE_DOCKER_DEFAULT_CONFIG_PATH}"] + ) cmd.extend([image, "--enable-coordinator"]) returncode = run_shell_cmd(cmd, os.getcwd()) if returncode == 0: @@ -293,9 +312,17 @@ def deploy( show_default=True, required=False, ) -def destroy(type, container_name): +@click.option( + "-y", + "--yes", + is_flag=True, + default=False, + help="Do not ask for confirmation", + required=False, +) +def destroy(type, container_name, yes): """Destroy Flex Interactive instance""" - if click.confirm(f"Do you want to destroy {container_name} instance?"): + if yes or click.confirm(f"Do you want to destroy {container_name} instance?"): cmd = [] if type == "interactive": cmd = [