-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
287 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "qml_pipeline_utils" | ||
version = "1" | ||
requires-python = ">= 3.7" | ||
dependencies = [ | ||
'tqdm~=4.66.0' | ||
] | ||
|
||
[project.scripts] | ||
qml_pipeline_utils = "qml_pipeline_utils.cli:cli_parser" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...kflows/qml_pipeline_utils/qml_pipeline_utils/services/validate_metadata_preview_images.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import json | ||
from pathlib import Path | ||
from typing import List, Union, TYPE_CHECKING | ||
|
||
from tqdm import tqdm | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
def validate_metadata_preview_images(metadata_files: List[str], sphinx_build_directory: Path): | ||
working_dir = Path(os.getcwd()) | ||
|
||
sphinx_build_directory = working_dir / sphinx_build_directory \ | ||
if not sphinx_build_directory.is_absolute() \ | ||
else sphinx_build_directory | ||
|
||
for metadata_file in metadata_files: | ||
if not metadata_file.startswith("/"): | ||
metadata_file_path = Path(working_dir) / metadata_file | ||
else: | ||
metadata_file_path = Path(metadata_file) | ||
|
||
with metadata_file_path.open() as fh: | ||
metadata = json.load(fh) | ||
|
||
preview_images = metadata.get("previewImages", []) | ||
|
||
image_uris = [ | ||
image["uri"] | ||
for image in preview_images | ||
] | ||
|
||
for image_uri in tqdm(image_uris, ascii=True, desc=metadata_file): | ||
if not image_uri.startswith("/"): | ||
print(f" Metadata file {metadata_file} contains either remote image uri or non-absolute path " | ||
f"for previewImage {image_uri}. Remote image paths cannot be validated at this time. Skipping.") | ||
continue | ||
|
||
uri_path = sphinx_build_directory / image_uri[1:] | ||
|
||
assert uri_path.exists(), f"Could not find previewImage {image_uri}" | ||
|
||
return None | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.