-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata previewImages validation (#887)
- Loading branch information
Showing
12 changed files
with
291 additions
and
54 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
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.9" | ||
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
41 changes: 41 additions & 0 deletions
41
...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,41 @@ | ||
import os | ||
import json | ||
from pathlib import Path | ||
from typing import List | ||
|
||
from tqdm import tqdm | ||
|
||
|
||
def validate_metadata_preview_images(metadata_files: List[str], sphinx_build_directory: Path): | ||
working_dir = Path(os.getcwd()) | ||
|
||
if sphinx_build_directory.is_absolute(): | ||
sphinx_build_directory = sphinx_build_directory | ||
else: | ||
sphinx_build_directory = working_dir / 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}" |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.