ATH-MaaS/Pixelle-Video · error · FileNotFoundError

Resource not found: {os.path.join(resource_type, *paths)}

Error message

Resource not found: {os.path.join(resource_type, *paths)}
  Searched locations:
    1. {custom_path} (custom)
    2. {default_path} (default)

What it means

get_resource_path resolves bundled resources (templates, workflows, BGM, etc.) by checking a custom overrides directory first, then the default packaged location. If the joined resource path exists in neither, it raises FileNotFoundError listing both searched locations. It means the requested resource_type/paths combination is not shipped with the package and no custom override was provided.

Source

Thrown at pixelle_video/utils/os_util.py:372

        
        >>> get_resource_path("workflows", "selfhost", "image_flux.json")
        # Returns: "data/workflows/selfhost/image_flux.json" or "workflows/selfhost/image_flux.json"
    """
    # Build custom path (data/*)
    custom_path = get_data_path(resource_type, *paths)
    
    # Build default path (root/*)
    default_path = get_root_path(resource_type, *paths)
    
    # Priority: custom > default
    if os.path.exists(custom_path):
        return custom_path
    
    if os.path.exists(default_path):
        return default_path
    
    # Not found in either location
    raise FileNotFoundError(
        f"Resource not found: {os.path.join(resource_type, *paths)}\n"
        f"  Searched locations:\n"
        f"    1. {custom_path} (custom)\n"
        f"    2. {default_path} (default)"
    )


def list_resource_files(
    resource_type: Literal["bgm", "templates", "workflows"],
    subdir: str = ""
) -> list[str]:
    """
    List resource files with custom override support
    
    Merges files from both default and custom locations:
        - Files from data/{resource_type}/* (custom, higher priority)
        - Files from {resource_type}/* (default)
        - Duplicate names are deduplicated (custom takes precedence)

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Read the two searched paths from the error and check which one you were expected to provide — create the file in the custom location.
  2. Verify the exact resource name/spelling and available sizes via list_templates_for_size or by listing the package's templates directory.
  3. If packaging stripped data files, reinstall the package or include resource dirs in your build (package_data / PyInstaller --add-data).
  4. Point the custom resource directory configuration at a folder containing the needed resource.
  5. Catch FileNotFoundError and fall back to a supported default template/size.

Example fix

// before
tpl = get_template_full_path("4096x2160", "cinematic.html")
// after
try:
    tpl = get_template_full_path("4096x2160", "cinematic.html")
except FileNotFoundError:
    tpl = get_template_full_path("1080x1920", "default.html")  # bundled fallback
Defensive patterns

Strategy: fallback

Validate before calling

import os
from pixelle_video.utils.os_util import get_resource_path  # or reimplement the two-location probe

def resource_exists(resource_type: str, *paths: str) -> bool:
    try:
        get_resource_path(resource_type, *paths)
        return True
    except FileNotFoundError:
        return False
# check before rendering: resource_exists("templates", "1080x1920", "default.html")

Type guard

def resolve_or_none(resource_type: str, *paths: str):
    try:
        return get_resource_path(resource_type, *paths)
    except FileNotFoundError:
        return None

Try / catch

try:
    tpl = get_template_full_path(size, name)
except FileNotFoundError as e:
    logger.error("Resource missing: %s", e)
    tpl = get_template_full_path("1080x1920", "default.html")  # bundled fallback

Prevention

When it happens

Trigger: Calls like get_resource_path("templates", "1080x1920", "default.html"), _scan_workflows, _resolve_bgm_path, resolve_template_path, or list_local_media_workflows referencing a size/name that does not exist on disk — e.g. a typo'd template name, a resolution the package does not include, or a missing custom resource directory.

Common situations: Requesting a resolution (e.g. 2048x2048) the library does not bundle; resources directory stripped by packaging (wheel/sdist excludes data files or PyInstaller missing data hooks); project moved to a machine without the custom assets folder; renaming template files without updating config.

Related errors


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/297c1483374f52d8. Report an issue: GitHub.