Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sbalandi committed Sep 19, 2024
1 parent a598335 commit 0947ae7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
20 changes: 15 additions & 5 deletions .ci/patch_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ def disable_skip_ext(nb, notebook_path, test_device=""):
skip_for_device = None if test_device else False
for cell in nb["cells"]:
if test_device is not None and skip_for_device is None:
if 'skip_for_device = "{}" in device.value'.format(test_device.upper()) in cell["source"] and (
"to_quantize = widgets.Checkbox(value=not skip_for_device" in cell["source"]
or "to_quantize = quantization_widget(not skip_for_device" in cell["source"]
if (
'skip_for_device = "{}" in device.value'.format(test_device.upper()) in cell["source"]
and (
"to_quantize = widgets.Checkbox(value=not skip_for_device" in cell["source"]
or "to_quantize = quantization_widget(not skip_for_device" in cell["source"]
)
or ("to_quantize = quantization_widget(False" in cell["source"])
):
skip_for_device = True

Expand Down Expand Up @@ -152,7 +156,11 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False):
if test_device and (DEVICE_WIDGET in cell["source"] or DEVICE_WIDGET_NEW in cell["source"]):
device_found = True
if not DEVICE_WIDGET_NEW in cell["source"]:
cell["source"] = re.sub(r"value=.*,", f"value='{test_device.upper()}',", cell["source"])
cell["source"] = re.sub(
r"value=.*,",
f"value='{test_device.upper()}',",
cell["source"],
)
cell["source"] = re.sub(
r"options=",
f"options=['{test_device.upper()}'] + ",
Expand All @@ -161,7 +169,9 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False):
print(f"Replaced testing device to {test_device}")
else:
cell["source"] = re.sub(
r"device_widget\(.*\)", f"device_widget(default='{test_device.upper()}', added=['{test_device.upper()}'])", cell["source"]
r"device_widget\(.*\)",
f"device_widget(default='{test_device.upper()}', added=['{test_device.upper()}'])",
cell["source"],
)
replace_dict = cell.get("metadata", {}).get("test_replace")
if replace_dict is not None:
Expand Down
2 changes: 2 additions & 0 deletions .ci/skipped_notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,12 @@
- '3.9'
- os:
- macos-12
- windows-2019
- notebook: notebooks/segment-anything/segment-anything-2-video.ipynb
skips:
- python:
- '3.8'
- '3.9'
- os:
- macos-12
- windows-2019
12 changes: 7 additions & 5 deletions notebooks/segment-anything/segment-anything-2-image.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"id": "662e0f0d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -160,14 +160,17 @@
],
"source": [
"import sys\n",
"import os\n",
"\n",
"sam2_dir = Path(\"segment-anything-2\")\n",
"\n",
"if not sam2_dir.exists():\n",
" !git clone https://github.com/facebookresearch/segment-anything-2.git\n",
" exit_code = os.system(\"git clone https://github.com/facebookresearch/segment-anything-2.git\")\n",
" if exit_code != 0:\n",
" raise Exception(\"Failed to clone the repository!\")\n",
"\n",
"# append to sys.path so that modules from the repo could be imported\n",
"sys.path.append(str(sam2_dir))\n",
"sys.path.insert(0, str(sam2_dir.resolve()))\n",
"\n",
"%env SAM2_BUILD_CUDA=0"
]
Expand Down Expand Up @@ -1442,8 +1445,7 @@
"source": [
"from notebook_utils import quantization_widget\n",
"\n",
"skip_for_device = \"CPU\" in device.value\n",
"to_quantize = quantization_widget(not skip_for_device)\n",
"to_quantize = quantization_widget(False)\n",
"to_quantize"
]
},
Expand Down
15 changes: 13 additions & 2 deletions notebooks/segment-anything/segment-anything-2-video.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,29 @@
],
"source": [
"import sys\n",
"import os\n",
"\n",
"sam2_dir = Path(\"segment-anything-2\")\n",
"\n",
"if not sam2_dir.exists():\n",
" !git clone https://github.com/facebookresearch/segment-anything-2.git\n",
" exit_code = os.system(\"git clone https://github.com/facebookresearch/segment-anything-2.git\")\n",
" if exit_code != 0:\n",
" raise Exception(\"Failed to clone the repository!\")\n",
"\n",
"# append to sys.path so that modules from the repo could be imported\n",
"sys.path.append(str(sam2_dir))\n",
"sys.path.insert(0, str(sam2_dir.resolve()))\n",
"\n",
"%env SAM2_BUILD_CUDA=0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "feea9e6b",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
Expand Down

0 comments on commit 0947ae7

Please sign in to comment.