Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Sktime Pytorch forecasting Object Registry

From Leeroopedia


Knowledge Sources
Domains Time_Series, Forecasting, Deep_Learning, Software_Architecture
Last Updated 2026-02-08 09:00 GMT

Overview

A class registry system that automatically discovers, lists, and filters all available estimator objects (models, metrics, and other components) within pytorch-forecasting. Built on top of skbase's all_objects utility, it provides a unified API for programmatic introspection of the library's contents.

Description

The object registry module provides a single function, all_objects, that crawls the entire pytorch-forecasting package to discover all classes inheriting from _BaseObject. This function serves as the primary mechanism for users and tooling to enumerate what is available in the library, apply filters, and retrieve metadata about each registered object.

Discovery Mechanism: The function delegates to skbase.lookup.all_objects, passing the pytorch-forecasting package root directory as the search path and _BaseObject as the base class filter. It explicitly ignores certain module paths (tests, setup, contrib, utils, all) to exclude test fixtures, utility code, and setup scripts from the registry results.

Type-Based Filtering: The object_types parameter accepts strings or lists of strings representing scitype identifiers (e.g., forecaster, metric). These are translated into tag-based filters using the object_type tag. If a class is provided instead of a string, its object_type tag is extracted automatically, allowing users to pass class objects directly as type filters.

Tag-Based Filtering: The filter_tags parameter accepts a dictionary mapping tag names to expected values. Each tag condition acts as a conjunction (AND logic) -- only objects satisfying all tag conditions are returned. Values can be strings, lists of strings, or compiled regex patterns (from scikit-base 0.8.0+). When a tag value is a list, the condition checks for containment.

Return Formats: Results can be returned as a list of classes, a list of tuples (optionally including names and tag values), or a pandas DataFrame. The return_names flag controls whether class names appear in the output, and return_tags specifies which additional tag values to fetch per object.

Object Exclusion: The exclude_objects parameter allows specific classes to be removed from results by name, useful for excluding deprecated or internal classes from public listings.

Input Coercion: The module includes helper functions to coerce class references to their string type identifiers and to validate that arguments are strings or lists of strings, raising informative TypeError messages on invalid input.

Usage

Use all_objects to programmatically list all available models, metrics, or other estimator types in pytorch-forecasting. This is useful for building auto-ML systems that need to enumerate model choices, for documentation generators that list available components, for testing frameworks that need to run conformance tests against all registered classes, and for interactive exploration in notebooks.

Theoretical Basis

Registry Pattern:

The object registry implements the Service Locator pattern adapted for Python class hierarchies. Rather than maintaining an explicit registry dictionary, it uses runtime module introspection to discover classes:

# Pseudo-code: registry discovery process
def all_objects(object_types=None, filter_tags=None):
    # Walk all modules under the package root
    classes = crawl_package(
        root="pytorch_forecasting",
        base_class=_BaseObject,
        ignore=["tests", "setup", "contrib", "utils"]
    )

    # Apply type filter via object_type tag
    if object_types:
        classes = [c for c in classes
                   if c.get_tag("object_type") in object_types]

    # Apply tag-based filters (AND logic)
    if filter_tags:
        for tag_name, expected in filter_tags.items():
            classes = [c for c in classes
                       if matches(c.get_tag(tag_name), expected)]

    return classes

Tag Matching Rules:

  • If search_value is a string and tag_value is a string: exact match required
  • If search_value is a string and tag_value is a list: containment check
  • If search_value is a regex: fullmatch against string, or any match against list elements
  • If search_value is iterable: at least one element must satisfy the above

Inheritance from skbase:

The registry leverages the scikit-base (skbase) package's generic object discovery, which itself is derived from scikit-learn's all_estimators utility. This shared lineage ensures consistency with the broader scikit ecosystem's conventions for tag-based object metadata and registry patterns.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment