Skip to content

Commit

Permalink
use function for install deps (#2349)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Sep 2, 2024
1 parent ae8406f commit bd1fd6d
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 380 deletions.
14 changes: 12 additions & 2 deletions .ci/patch_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def has_additional_deps(str_part):
return False
return True

lines = cell["source"].split("\n")
lines = cell["source"].replace("pip_instal(", "pip_install( ").split("\n")
for line in lines:
if "openvino" in line:
if "optimum-cli" in line or line.startswith("#"):
Expand All @@ -73,18 +73,28 @@ def has_additional_deps(str_part):
package_found = False
for part in line.split(" "):
if "openvino-dev" in part:
if part.endswith(")"):
updated_line_content.append(")")
package_found = True
continue
if "openvino-nightly" in part:
package_found = True
if part.endswith(")"):
updated_line_content.append(")")
continue
if "openvino-tokenizers" in part:
package_found = True
if part.endswith(")"):
updated_line_content.append(")")
continue
if "openvino-genai" in part:
package_found = True
if part.endswith(")"):
updated_line_content.append(")")
continue
if "openvino>" in part or "openvino=" in part or "openvino" == part:
if part.endswith(")"):
updated_line_content.append(")")
package_found = True
continue
if empty:
Expand Down Expand Up @@ -133,7 +143,7 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False):
found = False
device_found = False
for cell in nb["cells"]:
if skip_ov_install and "%pip" in cell["source"]:
if skip_ov_install and "%pip" in cell["source"] or "pip_install(" in cell["source"]:
remove_ov_install(cell)
if test_device and (DEVICE_WIDGET in cell["source"] or DEVICE_WIDGET_NEW in cell["source"]):
device_found = True
Expand Down
36 changes: 23 additions & 13 deletions notebooks/llm-agent-react/llm-agent-rag-llamaindex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,32 @@
"outputs": [],
"source": [
"import os\n",
"import requests\n",
"\n",
"os.environ[\"GIT_CLONE_PROTECTION_ACTIVE\"] = \"false\"\n",
"\n",
"%pip uninstall -q -y optimum optimum-intel\n",
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \\\n",
"\"llama-index\" \"llama-index-readers-file\" \"llama-index-llms-openvino>=0.2.2\" \"llama-index-embeddings-openvino>=0.2.0\" \"transformers>=4.43.1\"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"os.environ[\"GIT_CLONE_PROTECTION_ACTIVE\"] = \"false\"\n",
"\n",
"%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\" \\\n",
"\"git+https://github.com/openvinotoolkit/nncf.git\" \\\n",
"\"datasets\" \\\n",
"\"accelerate\"\n",
"%pip install --pre -Uq \"openvino>=2024.2.0\" openvino-tokenizers[transformers] --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly"
"from notebook_utils import pip_install\n",
"\n",
"pip_install(\n",
" \"-q\",\n",
" \"--extra-index-url\",\n",
" \"https://download.pytorch.org/whl/cpu\",\n",
" \"llama-index\",\n",
" \"llama-index-readers-file\",\n",
" \"llama-index-llms-openvino>=0.2.2\",\n",
" \"llama-index-embeddings-openvino>=0.2.0\",\n",
" \"transformers>=4.43.1\",\n",
")\n",
"pip_install(\"-q\", \"git+https://github.com/huggingface/optimum-intel.git\", \"git+https://github.com/openvinotoolkit/nncf.git\", \"datasets\", \"accelerate\")\n",
"pip_install(\n",
" \"--pre\", \"-Uq\", \"openvino>=2024.2.0\", \"openvino-tokenizers[transformers]\", \"--extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly\"\n",
")"
]
},
{
Expand All @@ -93,10 +107,6 @@
"import requests\n",
"import io\n",
"\n",
"r = requests.get(\n",
" url=\"https://raw.githubusercontent.com/openvinotoolkit/openvino_notebooks/latest/utils/notebook_utils.py\",\n",
")\n",
"open(\"notebook_utils.py\", \"w\").write(r.text)\n",
"\n",
"text_example_en_path = Path(\"text_example_en.pdf\")\n",
"text_example_en = \"https://github.com/user-attachments/files/16171326/xeon6-e-cores-network-and-edge-brief.pdf\"\n",
Expand Down
Loading

0 comments on commit bd1fd6d

Please sign in to comment.