diff --git a/.github/workflows/link_checker.yml b/.github/workflows/link_checker.yml index 6b5240dc9..806034e06 100644 --- a/.github/workflows/link_checker.yml +++ b/.github/workflows/link_checker.yml @@ -17,6 +17,7 @@ concurrency: jobs: link-checker: + if: github.repository == 'sony/model_optimization' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f7fa7b894..c6fc7b816 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -36,6 +36,6 @@ jobs: twine upload --repository pypi dist/* --verbose -u __token__ -p ${{ secrets.PYPI_API_SSI_DEV_NIGHTLY_KEY }} - name: Post publish import test run: | - pip install mct-nightly tensorflow torch + pip install mct-nightly tensorflow torch torchvision version=$(python -c 'import model_compression_toolkit; print(model_compression_toolkit.__version__)') echo $version \ No newline at end of file diff --git a/model_compression_toolkit/target_platform_capabilities/schema/v2.py b/model_compression_toolkit/target_platform_capabilities/schema/v2.py index facd37bd9..aac5a7f0f 100644 --- a/model_compression_toolkit/target_platform_capabilities/schema/v2.py +++ b/model_compression_toolkit/target_platform_capabilities/schema/v2.py @@ -214,6 +214,7 @@ class TargetPlatformCapabilities(BaseModel): add_metadata (bool): Flag to determine if metadata should be added. name (str): Name of the Target Platform Model. is_simd_padding (bool): Indicates if SIMD padding is applied. + insert_preserving_quantizers (bool): Whether to include quantizers for quantization preserving operations in the quantized model. SCHEMA_VERSION (int): Version of the schema for the Target Platform Model. """ default_qco: QuantizationConfigOptions @@ -224,7 +225,9 @@ class TargetPlatformCapabilities(BaseModel): tpc_platform_type: Optional[str] add_metadata: bool = True name: Optional[str] = "default_tpc" + is_simd_padding: bool = False + insert_preserving_quantizers: bool = False SCHEMA_VERSION: int = 2 diff --git a/tests/doc_tests/test_docs_links.py b/tests/doc_tests/test_docs_links.py index 8f06a5598..be6279701 100644 --- a/tests/doc_tests/test_docs_links.py +++ b/tests/doc_tests/test_docs_links.py @@ -12,15 +12,33 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +import os import unittest import subprocess from shutil import rmtree from os import walk, getcwd, getenv from os.path import join, isdir, isfile +from urllib.parse import urlparse + import requests import re +def parse_github_blob_url(url): + + parsed = urlparse(url) + parts = parsed.path.strip("/").split("/") + + if len(parts) < 5 or parts[2] != "blob": + raise ValueError("Invalid GitHub blob URL") + + owner, repo = parts[0], parts[1] + branch = parts[3] + filepath = "/".join(parts[4:]) + + return owner, repo, branch, filepath + + class TestDocsLinks(unittest.TestCase): """ A test for checking links in 'readme' (.md files), notebooks (.ipynb files) and '.rst' files. @@ -30,12 +48,11 @@ class TestDocsLinks(unittest.TestCase): @staticmethod def check_link(_url, branch_name): try: - response = requests.get(_url) + response = requests.head(_url, allow_redirects=True) if response.status_code == 200: return True except Exception as e: print(f"Error checking link '{_url}': {e}") - try: _url = _url.replace('/main/', f'/{branch_name}/') response = requests.get(_url) @@ -44,6 +61,18 @@ def check_link(_url, branch_name): except Exception as e: print(f"Error checking link '{_url}': {e}") + try: + # GitHub action have limited requests-rate for 'blob' pages + if 'blob' in _url: + owner, repo, branch, filepath = parse_github_blob_url(_url) + _url = f"https://api.github.com/repos/{owner}/{repo}/contents/{filepath}" + print(_url) + response = requests.head(_url, allow_redirects=True) + if response.status_code == 200: + return True + except Exception as e: + print(f"Error checking link '{_url}': {e}") + return False def test_readme_and_rst_files(self): @@ -67,6 +96,8 @@ def test_readme_and_rst_files(self): _link = link_str.split(']')[-1][1:-1] # replace colab link with actual github link because accessing a broken link through colab doesn't return an error _link = _link.replace('://colab.research.google.com/github/', '://github.com/') + if '/model_optimization/blob/main/' in _link: + _link = join(mct_folder, _link.split('/model_optimization/blob/main/')[1]) if _link[0] == '#': # A link starting with '#' is a local reference to a headline in the current file --> ignore pass @@ -96,6 +127,8 @@ def test_readme_and_rst_files(self): # format: search for a string between <>, which is the link _strs = re.findall(r"<([^<>]+)>", l) for _link in _strs: + if '/model_optimization/blob/main/' in _link: + _link = join(mct_folder, _link.split('/model_optimization/blob/main/')[1]) if _link.startswith('ug-'): # A link starting with 'ug-' is a reference to another .rst file --> ignore # This link is checked when generating the docs