Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove framework specific deps from main requirements #1912

Merged
merged 7 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .ci/check_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,13 @@ def complain(message):
try:
get = requests.get(url, timeout=10)
if get.status_code != 200:
if get.status_code in [500, 429, 443] and any(
[known_url in url for known_url in EXCEPTIONS_URLs]
):
print(
f"SKIP - {md_path}: URL can not be reached {url!r}, status code {get.status_code}"
)
if get.status_code in [500, 429, 443] and any([known_url in url for known_url in EXCEPTIONS_URLs]):
print(f"SKIP - {md_path}: URL can not be reached {url!r}, status code {get.status_code}")
continue
complain(
f"{md_path}: URL can not be reached {url!r}, status code {get.status_code}"
)
complain(f"{md_path}: URL can not be reached {url!r}, status code {get.status_code}")
except Exception as err:
if any([known_url in url for known_url in EXCEPTIONS_URLs]):
print(
f"SKIP - {md_path}: URL can not be reached {url!r}, error {err}"
)
print(f"SKIP - {md_path}: URL can not be reached {url!r}, error {err}")
else:
complain(f"{md_path}: URL can not be reached {url!r}, error {err}")

Expand Down
12 changes: 3 additions & 9 deletions .ci/convert_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ def arguments():
parser = argparse.ArgumentParser()
parser.add_argument("--exclude_execution_file")
parser.add_argument("--exclude_conversion_file")
parser.add_argument(
"--timeout", type=float, default=7200, help="timeout for notebook execution"
)
parser.add_argument(
"--rst_dir", type=Path, help="rst files output directory", default=Path("rst")
)
parser.add_argument("--timeout", type=float, default=7200, help="timeout for notebook execution")
parser.add_argument("--rst_dir", type=Path, help="rst files output directory", default=Path("rst"))

return parser.parse_args()

Expand Down Expand Up @@ -57,9 +53,7 @@ def main():
if str(notebook_path) in ignore_conversion_list:
continue
disable_gradio_debug(notebook_path)
notebook_executed = notebook_path.parent / notebook_path.name.replace(
".ipynb", "-with-output.ipynb"
)
notebook_executed = notebook_path.parent / notebook_path.name.replace(".ipynb", "-with-output.ipynb")
start = time.perf_counter()
print(f"Convert {notebook_path}")
if str(notebook_path) not in ignore_execution_list:
Expand Down
29 changes: 7 additions & 22 deletions .ci/patch_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,17 @@ def patch_notebooks(notebooks_dir, test_device=""):
"""

nb_convert_config = Config()
nb_convert_config.NotebookExporter.preprocessors = [
"nbconvert.preprocessors.ClearOutputPreprocessor"
]
nb_convert_config.NotebookExporter.preprocessors = ["nbconvert.preprocessors.ClearOutputPreprocessor"]
output_remover = nbconvert.NotebookExporter(nb_convert_config)
for notebookfile in Path(notebooks_dir).glob("**/*.ipynb"):
if (
not str(notebookfile.name).startswith("test_")
and notebookfile.name not in EXCLUDED_NOTEBOOKS
):
if not str(notebookfile.name).startswith("test_") and notebookfile.name not in EXCLUDED_NOTEBOOKS:
nb = nbformat.read(notebookfile, as_version=nbformat.NO_CONVERT)
found = False
device_found = False
for cell in nb["cells"]:
if test_device and DEVICE_WIDGET in cell["source"]:
device_found = True
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 @@ -81,26 +74,18 @@ def patch_notebooks(notebooks_dir, test_device=""):
found = True
for source_value, target_value in replace_dict.items():
if source_value not in cell["source"]:
raise ValueError(
f"Processing {notebookfile} failed: {source_value} does not exist in cell"
)
cell["source"] = cell["source"].replace(
source_value, target_value
)
raise ValueError(f"Processing {notebookfile} failed: {source_value} does not exist in cell")
cell["source"] = cell["source"].replace(source_value, target_value)
cell["source"] = "# Modified for testing\n" + cell["source"]
print(
f"Processed {notebookfile}: {source_value} -> {target_value}"
)
print(f"Processed {notebookfile}: {source_value} -> {target_value}")
if test_device and not device_found:
print(f"No device replacement found for {notebookfile}")
if not found:
print(f"No replacements found for {notebookfile}")
disable_gradio_debug(nb, notebookfile)
disable_skip_ext(nb, notebookfile)
nb_without_out, _ = output_remover.from_notebook_node(nb)
with notebookfile.with_name(f"test_{notebookfile.name}").open(
"w", encoding="utf-8"
) as out_file:
with notebookfile.with_name(f"test_{notebookfile.name}").open("w", encoding="utf-8") as out_file:
out_file.write(nb_without_out)


Expand Down
10 changes: 2 additions & 8 deletions .ci/spellcheck/ipynb_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def setup(self):

def filter(self, source_file, encoding): # noqa A001
"""Open and filter the file from disk."""
nb: nbformat.NotebookNode = nbformat.read(
source_file, as_version=nbformat.NO_CONVERT
)
nb: nbformat.NotebookNode = nbformat.read(source_file, as_version=nbformat.NO_CONVERT)

return [filters.SourceText(self._filter(nb), source_file, encoding, "ipynb")]

Expand All @@ -42,11 +40,7 @@ def _filter(self, nb):

def sfilter(self, source):
"""Execute filter."""
return [
filters.SourceText(
self._filter(source.text), source.context, source.encoding, "ipynb"
)
]
return [filters.SourceText(self._filter(source.text), source.context, source.encoding, "ipynb")]


def get_plugin():
Expand Down
4 changes: 1 addition & 3 deletions .ci/spellcheck/run_spellcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
env=dict(os.environ, PYTHONPATH=PYTHONPATH),
)

result_output = (
result.stdout.strip("\n") if result.stdout else result.stderr.strip("\n")
)
result_output = result.stdout.strip("\n") if result.stdout else result.stderr.strip("\n")

print(result_output, file=sys.stderr if result.returncode else sys.stdout, flush=True)

Expand Down
20 changes: 5 additions & 15 deletions .ci/table_of_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def create_link_for_tc(title):
def remove_old_tc(cell, idx):
if cell is not None:
for line in cell["source"][idx:]:
if re.match(r"\s*-\s*\[.*\]\(#.*\).*", line) or re.match(
TABLE_OF_CONTENT, line
):
if re.match(r"\s*-\s*\[.*\]\(#.*\).*", line) or re.match(TABLE_OF_CONTENT, line):
cell["source"].remove(line)
return cell

Expand All @@ -56,9 +54,7 @@ def get_tc_line(title, title_for_tc, link, tc_list, titles_list):
elif indents_num - tc_list[-1].index("-") > 4:
# when previous list item have n indents and current have n+4+1 it broke the alignment
indents_num = tc_list[-1].index("-") + 4
elif indents_num != tc_list[-1].index("-") and title.index(" ") == titles_list[
-1
].index(" "):
elif indents_num != tc_list[-1].index("-") and title.index(" ") == titles_list[-1].index(" "):
# when we have several titles with same wrong alignments
indents_num = tc_list[-1].index("-")

Expand Down Expand Up @@ -101,9 +97,7 @@ def generate_table_of_content(notebook_path: pathlib.Path):
if not notebook_json["cells"]:
return

table_of_content_cell, table_of_content_cell_idx = find_tc_in_cell(
notebook_json["cells"][0]
)
table_of_content_cell, table_of_content_cell_idx = find_tc_in_cell(notebook_json["cells"][0])

all_titles = []
for cell in filter(is_markdown, notebook_json["cells"][1:]):
Expand All @@ -124,9 +118,7 @@ def generate_table_of_content(notebook_path: pathlib.Path):
title = title.strip()
title_for_tc = create_title_for_tc(title)
link_for_tc = create_link_for_tc(title_for_tc)
new_line = get_tc_line(
title, title_for_tc, link_for_tc, table_of_content, all_titles
)
new_line = get_tc_line(title, title_for_tc, link_for_tc, table_of_content, all_titles)

if table_of_content.count(new_line) > 1:
print(
Expand All @@ -141,9 +133,7 @@ def generate_table_of_content(notebook_path: pathlib.Path):
table_of_content = ["\n", "#### Table of contents:\n\n"] + table_of_content + ["\n"]

if table_of_content_cell is not None:
table_of_content_cell = remove_old_tc(
table_of_content_cell, table_of_content_cell_idx
)
table_of_content_cell = remove_old_tc(table_of_content_cell, table_of_content_cell_idx)

if table_of_content_cell is not None:
table_of_content_cell["source"].extend(table_of_content)
Expand Down
12 changes: 3 additions & 9 deletions .ci/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def test_readme():
# item is a notebook directory
notebook_dir = item.relative_to(Path("notebooks"))
if str(notebook_dir)[0].isdigit():
assert "README.md" in [
filename.name for filename in item.iterdir()
], f"README not found in {item}"
assert "README.md" in [filename.name for filename in item.iterdir()], f"README not found in {item}"


def test_requirements_docker():
Expand All @@ -60,9 +58,7 @@ def test_requirements_docker():
docker_requirements = set(list(pipfile_contents["packages"].keys()))

pip_requirements = get_parsed_requirements("requirements.txt")
assert pip_requirements.issubset(
docker_requirements
), f"Docker Pipfile misses: {pip_requirements.difference(docker_requirements)}"
assert pip_requirements.issubset(docker_requirements), f"Docker Pipfile misses: {pip_requirements.difference(docker_requirements)}"


def test_requirements_binder():
Expand All @@ -72,9 +68,7 @@ def test_requirements_binder():
"""
pip_requirements = get_parsed_requirements("requirements.txt")
binder_requirements = get_parsed_requirements(".binder/requirements.txt")
assert pip_requirements.issubset(
binder_requirements
), f"Binder requirements misses: {pip_requirements.difference(binder_requirements)}"
assert pip_requirements.issubset(binder_requirements), f"Binder requirements misses: {pip_requirements.difference(binder_requirements)}"


@pytest.mark.skip(reason="URL existence is tested in docker_treon")
Expand Down
22 changes: 5 additions & 17 deletions .ci/validate_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def prepare_test_plan(test_list, ignore_list, nb_dir=None):
for ig_nb in ignore_list:
if ig_nb.endswith(".txt"):
with open(ig_nb, "r") as f:
ignored_notebooks.extend(
list(map(lambda x: x.strip(), f.readlines()))
)
ignored_notebooks.extend(list(map(lambda x: x.strip(), f.readlines())))
else:
ignored_notebooks.append(ig_nb)
print(f"ignored notebooks: {ignored_notebooks}")
Expand All @@ -76,9 +74,7 @@ def prepare_test_plan(test_list, ignore_list, nb_dir=None):
break
if changed_path.suffix == ".md":
continue
notebook_subdir = find_notebook_dir(
changed_path.resolve(), orig_nb_dir.resolve()
)
notebook_subdir = find_notebook_dir(changed_path.resolve(), orig_nb_dir.resolve())
if notebook_subdir is None:
continue
testing_notebooks.append(notebook_subdir)
Expand Down Expand Up @@ -189,9 +185,7 @@ def main():
if args.keep_artifacts:
keep_artifacts = True

test_plan = prepare_test_plan(
args.test_list, args.ignore_list, notebooks_moving_dir
)
test_plan = prepare_test_plan(args.test_list, args.ignore_list, notebooks_moving_dir)
for notebook, report in test_plan.items():
if report["status"] == "SKIPPED":
continue
Expand All @@ -203,21 +197,15 @@ def main():
if status:
report["status"] = "TIMEOUT" if status == -42 else "FAILED"
else:
report["status"] = (
"SUCCESS"
if not report["status"] in ["TIMEOUT", "FAILED"]
else report["status"]
)
report["status"] = "SUCCESS" if not report["status"] in ["TIMEOUT", "FAILED"] else report["status"]
if status:
if status == -42:
timeout_notebooks.append(str(subnotebook))
else:
failed_notebooks.append(str(subnotebook))
if args.early_stop:
break
exit_status = finalize_status(
failed_notebooks, timeout_notebooks, test_plan, reports_dir, root
)
exit_status = finalize_status(failed_notebooks, timeout_notebooks, test_plan, reports_dir, root)
return exit_status


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
nbqa flake8 --ignore=E124,E203,E231,E266,E402,E501,E703,F821,W503,W291,W293 --nbqa-exclude="(tensorflow-training-openvino)|(pytorch-quantization-aware-training)" notebooks
- name: Black
run: |
black --check .
black --check -l 160 .
- name: Test READMEs and requirements
run: |
python -m pytest .ci/test_notebooks.py
Expand Down
43 changes: 10 additions & 33 deletions check_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def show_supported(supported):


def pip_check():
result = subprocess.run(
["pip", "check"], universal_newlines=True, stdout=subprocess.PIPE
)
result = subprocess.run(["pip", "check"], universal_newlines=True, stdout=subprocess.PIPE)
if "No broken requirements found" in result.stdout:
return True, ""
else:
Expand All @@ -62,12 +60,8 @@ def kernel_check():
CORRECT_KERNEL_PYTHON = PYTHON_EXECUTABLE == KERNEL_PYTHON

IN_OPENVINO_ENV = "openvino_env" in sys.executable
SUPPORTED_PYTHON_VERSION = PYTHON_VERSION.major == 3 and (
PYTHON_VERSION.minor >= 8 and PYTHON_VERSION.minor <= 11
)
GLOBAL_OPENVINO_INSTALLED = "openvino_202" in os.environ.get(
"LD_LIBRARY_PATH", ""
) + ":".join(sys.path)
SUPPORTED_PYTHON_VERSION = PYTHON_VERSION.major == 3 and (PYTHON_VERSION.minor >= 8 and PYTHON_VERSION.minor <= 11)
GLOBAL_OPENVINO_INSTALLED = "openvino_202" in os.environ.get("LD_LIBRARY_PATH", "") + ":".join(sys.path)


try:
Expand Down Expand Up @@ -105,20 +99,12 @@ def kernel_check():
print(f"Jupyter kernel installed for openvino_env: {show_supported(KERNEL_INSTALLED)}")
if KERNEL_INSTALLED:
print(f"Jupyter kernel Python executable: {KERNEL_PYTHON}")
print(
"Jupyter kernel Python and OpenVINO environment Python match: "
f"{show_supported(CORRECT_KERNEL_PYTHON)}"
)
print(
f"Python version: {PYTHON_VERSION.major}.{PYTHON_VERSION.minor} "
f"{show_supported(SUPPORTED_PYTHON_VERSION)}"
)
print("Jupyter kernel Python and OpenVINO environment Python match: " f"{show_supported(CORRECT_KERNEL_PYTHON)}")
print(f"Python version: {PYTHON_VERSION.major}.{PYTHON_VERSION.minor} " f"{show_supported(SUPPORTED_PYTHON_VERSION)}")
print(f"OpenVINO pip package installed: {show_supported(PIP_OPENVINO_INSTALLED)}")
print(f"OpenVINO import succeeds: {show_supported(OPENVINO_IMPORT)}")
print(f"OpenVINO development tools installed: {show_supported(DEVTOOLS_INSTALLED)}")
print(
f"OpenVINO not installed globally: {show_supported(not GLOBAL_OPENVINO_INSTALLED)}"
)
print(f"OpenVINO not installed globally: {show_supported(not GLOBAL_OPENVINO_INSTALLED)}")

print(f"No broken requirements: {show_supported(NO_BROKEN_REQUIREMENTS)}")
print()
Expand All @@ -132,10 +118,7 @@ def kernel_check():
sys.exit(0)

if not OPENVINO_IMPORT and OS != "win32" and not GLOBAL_OPENVINO_INSTALLED:
print(
"OpenVINO is installed, but importing fails. This is likely due to a missing\n"
"libpython.so library for the Python version you are using.\n"
)
print("OpenVINO is installed, but importing fails. This is likely due to a missing\n" "libpython.so library for the Python version you are using.\n")
if OS == "linux":
print(
"If you have multiple Python version installed, use the full path to the Python\n"
Expand Down Expand Up @@ -202,8 +185,7 @@ def kernel_check():
if not DEVTOOLS_INSTALLED:
print()
print(
"OpenVINO development tools are not installed in this Python environment. \n"
"Please follow the instructions in the README to install `openvino-dev`\n"
"OpenVINO development tools are not installed in this Python environment. \n" "Please follow the instructions in the README to install `openvino-dev`\n"
)

if not NO_BROKEN_REQUIREMENTS:
Expand All @@ -225,13 +207,8 @@ def kernel_check():
if NO_BROKEN_REQUIREMENTS:
print("Everything looks good!")
else:
print(
"Summary: The installation looks good, but there are conflicting requirements."
)
print("Summary: The installation looks good, but there are conflicting requirements.")
else:
print(
"The README.md file is located in the openvino_notebooks directory \n"
"and at https://github.com/openvinotoolkit/openvino_notebooks"
)
print("The README.md file is located in the openvino_notebooks directory \n" "and at https://github.com/openvinotoolkit/openvino_notebooks")
if not NO_BROKEN_REQUIREMENTS:
print("Broken requirements are often harmless, but could cause issues.")
Loading
Loading