diff --git a/examples/NebulaGraph_Lite.ipynb b/examples/NebulaGraph_Lite.ipynb index 780124f..e052ce9 100644 --- a/examples/NebulaGraph_Lite.ipynb +++ b/examples/NebulaGraph_Lite.ipynb @@ -24,7 +24,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "ExecutionIndicator": { "show": false @@ -39,39 +39,7 @@ "id": "xUypluvKsQOu", "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://mirrors.aliyun.com/pypi/simple\n", - "Collecting nebulagraph_lite\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/32/ca/a8c72c10dde8ff013ee283c00f0a5c0fa4bb680c966385dcfd54f9d7e136/nebulagraph_lite-0.2.1-py3-none-any.whl (16 kB)\n", - "Collecting udocker==1.3.13 (from nebulagraph_lite)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/28/f9/34a41eded7f2277c198286bdaa08b2b1ca619e56b1c5afccc1700fe41479/udocker-1.3.13-py2.py3-none-any.whl (118 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m118.6/118.6 kB\u001b[0m \u001b[31m9.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: psutil>=5.9.6 in /opt/conda/lib/python3.10/site-packages (from nebulagraph_lite) (5.9.7)\n", - "Collecting nebula3-python>=3.5.0 (from nebulagraph_lite)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/17/9c/46735c3f5e3dd62e8d568cd95114cc940896209b1eac75d16b5865b84f3f/nebula3_python-3.5.0-py3-none-any.whl (326 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m326.3/326.3 kB\u001b[0m \u001b[31m7.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: future>=0.18.0 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->nebulagraph_lite) (0.18.3)\n", - "Collecting httplib2>=0.20.0 (from nebula3-python>=3.5.0->nebulagraph_lite)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/a8/6c/d2fbdaaa5959339d53ba38e94c123e4e84b8fbc4b84beb0e70d7c1608486/httplib2-0.22.0-py3-none-any.whl (96 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m96.9/96.9 kB\u001b[0m \u001b[31m13.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: pytz>=2021.1 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->nebulagraph_lite) (2023.3.post1)\n", - "Requirement already satisfied: six>=1.16.0 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->nebulagraph_lite) (1.16.0)\n", - "Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /opt/conda/lib/python3.10/site-packages (from httplib2>=0.20.0->nebula3-python>=3.5.0->nebulagraph_lite) (3.1.1)\n", - "\u001b[33mDEPRECATION: pytorch-lightning 1.7.7 has a non-standard dependency specifier torch>=1.9.*. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pytorch-lightning or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", - "\u001b[0mInstalling collected packages: udocker, httplib2, nebula3-python, nebulagraph_lite\n", - "Successfully installed httplib2-0.22.0 nebula3-python-3.5.0 nebulagraph_lite-0.2.1 udocker-1.3.13\n", - "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n", - "\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "%pip install nebulagraph_lite" ] @@ -233,12 +201,12 @@ "id": "NRCyJEwrw3Bn" }, "source": [ - "## Play with ipython-ngql" + "## Play with [jupyter_nebulagraph](https://jupyter-nebulagraph.readthedocs.io/en/stable/)" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -254,62 +222,9 @@ "outputId": "82b91249-0dea-4a59-c268-96cedd589ed7", "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://mirrors.aliyun.com/pypi/simple\n", - "Collecting ipython-ngql\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/e5/4e/99c02b9f696bf1b2df4b657ce615a0a946b188138832877131ea1e653cef/ipython_ngql-0.8.0-py3-none-any.whl (10 kB)\n", - "Collecting pyvis\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/ab/4b/e37e4e5d5ee1179694917b445768bdbfb084f5a59ecd38089d3413d4c70f/pyvis-0.3.2-py3-none-any.whl (756 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m756.0/756.0 kB\u001b[0m \u001b[31m10.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: Jinja2 in /opt/conda/lib/python3.10/site-packages (from ipython-ngql) (3.1.2)\n", - "Requirement already satisfied: nebula3-python>=3.5.0 in /opt/conda/lib/python3.10/site-packages (from ipython-ngql) (3.5.0)\n", - "Requirement already satisfied: pandas in /opt/conda/lib/python3.10/site-packages (from ipython-ngql) (2.1.4)\n", - "Requirement already satisfied: ipython>=5.3.0 in /opt/conda/lib/python3.10/site-packages (from pyvis) (8.19.0)\n", - "Collecting jsonpickle>=1.4.1 (from pyvis)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/d6/be/c11f919e02622f15b942c0f2867dff6c3836ce32cd617627dda73bc9e5b7/jsonpickle-3.0.3-py3-none-any.whl (40 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.8/40.8 kB\u001b[0m \u001b[31m4.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: networkx>=1.11 in /opt/conda/lib/python3.10/site-packages (from pyvis) (2.8.4)\n", - "Requirement already satisfied: decorator in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (4.4.2)\n", - "Requirement already satisfied: jedi>=0.16 in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (0.19.1)\n", - "Requirement already satisfied: matplotlib-inline in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (0.1.6)\n", - "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (3.0.43)\n", - "Requirement already satisfied: pygments>=2.4.0 in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (2.17.2)\n", - "Requirement already satisfied: stack-data in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (0.6.3)\n", - "Requirement already satisfied: traitlets>=5 in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (5.14.1)\n", - "Requirement already satisfied: exceptiongroup in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (1.2.0)\n", - "Requirement already satisfied: pexpect>4.3 in /opt/conda/lib/python3.10/site-packages (from ipython>=5.3.0->pyvis) (4.9.0)\n", - "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.10/site-packages (from Jinja2->ipython-ngql) (2.1.3)\n", - "Requirement already satisfied: future>=0.18.0 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->ipython-ngql) (0.18.3)\n", - "Requirement already satisfied: httplib2>=0.20.0 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->ipython-ngql) (0.22.0)\n", - "Requirement already satisfied: pytz>=2021.1 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->ipython-ngql) (2023.3.post1)\n", - "Requirement already satisfied: six>=1.16.0 in /opt/conda/lib/python3.10/site-packages (from nebula3-python>=3.5.0->ipython-ngql) (1.16.0)\n", - "Requirement already satisfied: numpy<2,>=1.22.4 in /opt/conda/lib/python3.10/site-packages (from pandas->ipython-ngql) (1.26.3)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/conda/lib/python3.10/site-packages (from pandas->ipython-ngql) (2.8.2)\n", - "Requirement already satisfied: tzdata>=2022.1 in /opt/conda/lib/python3.10/site-packages (from pandas->ipython-ngql) (2023.4)\n", - "Requirement already satisfied: pyparsing!=3.0.0,!=3.0.1,!=3.0.2,!=3.0.3,<4,>=2.4.2 in /opt/conda/lib/python3.10/site-packages (from httplib2>=0.20.0->nebula3-python>=3.5.0->ipython-ngql) (3.1.1)\n", - "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /opt/conda/lib/python3.10/site-packages (from jedi>=0.16->ipython>=5.3.0->pyvis) (0.8.3)\n", - "Requirement already satisfied: ptyprocess>=0.5 in /opt/conda/lib/python3.10/site-packages (from pexpect>4.3->ipython>=5.3.0->pyvis) (0.7.0)\n", - "Requirement already satisfied: wcwidth in /opt/conda/lib/python3.10/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=5.3.0->pyvis) (0.2.12)\n", - "Requirement already satisfied: executing>=1.2.0 in /opt/conda/lib/python3.10/site-packages (from stack-data->ipython>=5.3.0->pyvis) (2.0.1)\n", - "Requirement already satisfied: asttokens>=2.1.0 in /opt/conda/lib/python3.10/site-packages (from stack-data->ipython>=5.3.0->pyvis) (2.4.1)\n", - "Requirement already satisfied: pure-eval in /opt/conda/lib/python3.10/site-packages (from stack-data->ipython>=5.3.0->pyvis) (0.2.2)\n", - "\u001b[33mDEPRECATION: pytorch-lightning 1.7.7 has a non-standard dependency specifier torch>=1.9.*. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of pytorch-lightning or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", - "\u001b[0mInstalling collected packages: jsonpickle, ipython-ngql, pyvis\n", - "Successfully installed ipython-ngql-0.8.0 jsonpickle-3.0.3 pyvis-0.3.2\n", - "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n", - "\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ - "%pip install ipython-ngql pyvis" + "%pip install jupyter_nebulagraph pyvis" ] }, { @@ -1068,6 +983,7 @@ } ], "source": [ + "!sleep 12\n", "%ngql SHOW TAGS" ] }, @@ -1379,11 +1295,13 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], - "source": [] + "source": [ + "### Explore Additional Datasets\n", + "\n", + "Our NebulaGraph Graph Dataset community offers a variety of datasets. For example, you can access a shareholding dataset [here](https://graph-hub.siwei.io/en/stable/datasets/shareholding/#__tabbed_4_3). Discover more datasets by visiting [NebulaGraph Graph Hub](https://graph-hub.siwei.io/).\n" + ] } ], "metadata": { diff --git a/src/nebulagraph_lite/__init__.py b/src/nebulagraph_lite/__init__.py index c6aadda..bc0ae78 100644 --- a/src/nebulagraph_lite/__init__.py +++ b/src/nebulagraph_lite/__init__.py @@ -2,4 +2,4 @@ __all__ = ["nebulagraph_let"] -__version__ = "0.2.3" +__version__ = "0.2.4" diff --git a/src/nebulagraph_lite/nebulagraph.py b/src/nebulagraph_lite/nebulagraph.py index 41381ad..cd8af39 100644 --- a/src/nebulagraph_lite/nebulagraph.py +++ b/src/nebulagraph_lite/nebulagraph.py @@ -613,7 +613,8 @@ def start(self, fresh=False): # if on_modelscope, we should load the model first if self.on_modelscope: fancy_print( - f"Info: loading nebulagraph_lite model from {self.modelscope_file}..." + f"Info: loading nebulagraph_lite model from {self.modelscope_file}...", + color="light_green", ) os.system(f"tar -xzf {self.modelscope_file} -C {self.base_path}") @@ -633,7 +634,10 @@ def start(self, fresh=False): except Exception as e: if self._debug: fancy_print(f"Info: [DEBUG] error when load model, {e}") - fancy_print(f"Info: nebulagraph_lite model loaded successfully!") + fancy_print( + f"Info: nebulagraph_lite model loaded successfully!", + color="light_blue", + ) # async pull images if not self.on_modelscope: self.udocker_pull( @@ -656,10 +660,12 @@ def start(self, fresh=False): f"{self._container_image_prefix}vesoft/nebula-console:v3" ) time.sleep(20) - fancy_print("Info: loading basketballplayer dataset...") + fancy_print("Info: loading basketballplayer dataset...", color="green") self.load_basketballplayer_dataset() fancy_print(BANNER_ASCII) - fancy_print("[ OK ] nebulagraph_lite started successfully!", "purple") + fancy_print( + "[ OK ] nebulagraph_lite started successfully!", color="light_purple" + ) self.docker_ps() def check_status(self): diff --git a/src/nebulagraph_lite/utils.py b/src/nebulagraph_lite/utils.py index 6de1848..0ca9f63 100644 --- a/src/nebulagraph_lite/utils.py +++ b/src/nebulagraph_lite/utils.py @@ -16,6 +16,14 @@ "red": "#f95d6a", "orange": "#ff7c43", "yellow": "#ffa600", + "green": "#a8ff9f", + "light_green": "#baf278", + "light_blue": "#78caff", + "light_purple": "#d2a6ff", + "light_pink": "#ff94d2", + "light_red": "#ff79c6", + "light_orange": "#ffb47b", + "light_yellow": "#ffe8a1", } COLORS_rgb = { @@ -27,6 +35,14 @@ "red": "38;2;249;93;106", "orange": "38;2;255;124;67", "yellow": "38;2;255;166;0", + "green": "38;2;168;255;159", + "light_green": "38;2;186;252;78", + "light_blue": "38;2;120;198;255", + "light_purple": "38;2;210;161;255", + "light_pink": "38;2;255;148;181", + "light_red": "38;2;255;129;159", + "light_orange": "38;2;255;186;119", + "light_yellow": "38;2;255;239;0", } BANNER_ASCII = r"""