Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/link_checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ concurrency:

jobs:
link-checker:
if: github.repository == 'sony/model_optimization'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
37 changes: 35 additions & 2 deletions tests/doc_tests/test_docs_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down