Skip to content

Commit

Permalink
Merge pull request #27 from wey-gu/ci_pr_actions
Browse files Browse the repository at this point in the history
Ci pr actions
  • Loading branch information
wey-gu authored Jan 15, 2024
2 parents e41665a + 611a334 commit f61f248
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 13 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: PR Workflow
on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
with:
python-version: '3.x'
cache: true
- name: Install dependencies
run: pdm install

- name: Lint
run: pdm run lint

- name: Build and Install NebulaGraph-Lite
run: pip3 install .

- name: Dry run `nebulagraph start`
run: nebulagraph --debug start --cleanup
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# NebulaGraph Lite

[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://bit.ly/nebula-colab)
[![Jupyter](https://img.shields.io/badge/Jupyter-Supported-brightgreen)](https://github.com/jupyterlab/jupyterlab)
[![for NebulaGraph](https://img.shields.io/badge/Toolchain-NebulaGraph-blue)](https://github.com/vesoft-inc/nebula)
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
[![Jupyter](https://img.shields.io/badge/Jupyter-Supported-brightgreen)](https://github.com/jupyterlab/jupyterlab)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wey-gu/nebulagraph-lite?label=Version)](https://github.com/wey-gu/nebulagraph-lite/releases)


[![GitHub release (latest by date)](https://img.shields.io/github/v/release/wey-gu/nebulagraph-lite?label=release)](https://github.com/wey-gu/nebulagraph-lite/releases)
[![pypi-version](https://img.shields.io/pypi/v/nebulagraph-lite)](https://pypi.org/project/nebulagraph-lite/)
[![python-version](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-blue)](https://www.python.org/)
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://bit.ly/nebula-colab)

Try NebulaGraph with `pip install`, on Linux/ WSL2 or even [Google Colab](https://bit.ly/nebula-colab)!

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ dev = [

[tool.pdm.scripts]
nebulagraph = {call = "nebulagraph_lite.cli:main"}
fmt = "black -l 84 ."
fmt = "black --line-length 84 ."
lint = "black --line-length 84 --check ."

[project.scripts]
nebulagraph = "nebulagraph_lite.cli:main"
2 changes: 1 addition & 1 deletion src/nebulagraph_lite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__all__ = ["nebulagraph_let"]

__version__ = "0.0.9"
__version__ = "0.1.0"
23 changes: 15 additions & 8 deletions src/nebulagraph_lite/nebulagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
BANNER_ASCII,
get_pid_by_port,
kill_process_by_pid,
process_listening_on_port,
)

LOCALHOST_V4 = "127.0.0.1"
Expand Down Expand Up @@ -184,9 +185,7 @@ def _run_udocker(self, command: str):
f"udocker command failed with return code {result.returncode}"
)
if output and self._debug:
fancy_print(
f"Info: [DEBUG] udocker command output:\n{output.decode()}"
)
fancy_print(f"Info: [DEBUG] udocker command output:\n{output.decode()}")
return result

def _run_udocker_ps_filter(self, filter: str):
Expand Down Expand Up @@ -279,7 +278,7 @@ def start_metad(self, shoot=False):
self._run_udocker_background(udocker_command)
time.sleep(10)
if not self.on_colab:
self._run_udocker_ps_filter("metad")
process_listening_on_port(9559)

def start_graphd(self):
self._try_shoot_service("graphd")
Expand Down Expand Up @@ -307,7 +306,8 @@ def start_graphd(self):
self._run_udocker_background(udocker_command)
time.sleep(10)
if not self.on_colab:
self._run_udocker_ps_filter("graphd")
# self._run_udocker_ps_filter("graphd")
process_listening_on_port(self.port)

def activate_storaged(self):
udocker_command = (
Expand Down Expand Up @@ -346,6 +346,7 @@ def load_basketballplayer_dataset(self):
f"-addr {self.host} -port {self.port} -u root -p nebula -e ':play basketballplayer'"
)
try:
time.sleep(10)
self._run_udocker(udocker_command)
except Exception as e:
fancy_dict_print(
Expand All @@ -355,8 +356,13 @@ def load_basketballplayer_dataset(self):
"udocker_command": udocker_command,
}
)
raise Exception("Failed to load basketballplayer dataset")
time.sleep(10)
fancy_dict_print(
{
"Info:": "Failed to load basketballplayer dataset, probably because the graphd is not ready yet or the cluster is not healthy, try this later from the console manually",
"command": f"udocker {udocker_command}",
"error": str(e),
}
)

def start_storaged(self, shoot=False):
if shoot:
Expand Down Expand Up @@ -392,7 +398,8 @@ def start_storaged(self, shoot=False):
self._run_udocker_background(udocker_command)
time.sleep(20)
if not self.on_colab:
self._run_udocker_ps_filter("storaged")
# self._run_udocker_ps_filter("storaged")
pass

def start(self, fresh=False):
shoot = bool(fresh)
Expand Down
8 changes: 8 additions & 0 deletions src/nebulagraph_lite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ def kill_process_by_pid(pid):
print(f"Process with PID {pid} has been terminated.")
except psutil.NoSuchProcess:
print(f"No process with PID {pid} exists.")


@retry((Exception,), tries=3, delay=5, backoff=3)
def process_listening_on_port(port):
for conn in psutil.net_connections():
if conn.laddr.port == port and conn.status == "LISTEN":
return True
return False

0 comments on commit f61f248

Please sign in to comment.