architecture-design

Implements factory and registry patterns for new registrable ML components in PyTorch projects.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill architecture-design-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: architecture-design
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/architecture-design
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill architecture-design-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch, and includes references (resource) components.

What problem does it solve? When extending a machine learning codebase, new datasets, models, and augmentations must follow consistent factory and registry patterns or the project becomes fragmented and hard to maintain. This Skill enforces a standardized architecture so every new component registers correctly and stays config-driven. ## Core Features & Use Cases - Registry Pattern Guidance: Shows how to add new Dataset, Model, and Augmentation classes using @register_dataset, @register_model, and @register_augmentation decorators. - Config-Driven Model Design: Enforces models whose __init__ accepts only a Hydra cfg object and whose forward() returns a dict with loss, labels, and logits. - Auto-Import Discovery: Explains how module __init__.py files auto-discover submodules so new files register without manual imports. - Use Case: When adding a new brain-decoder model to an ML research project, follow the Skill to create the file in src/model_module/, decorate it with @register_model('MyModel'), wire all hyperparameters through the Hydra config, and return the standard output dict. ## Quick Start Ask the AI to create a new dataset class for the project following the architecture-design patterns with the proper registration decorator and config-driven structure.

Frequently Asked Questions about architecture-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new dataset class to a PyTorch project with a registry pattern?

Create a file in src/data_module/dataset/, inherit from torch.utils.data.Dataset, and decorate the class with @register_dataset("name"). Implement __init__, __len__, and __getitem__, and the auto-import in the module __init__.py registers it automatically.

How do I create a config-driven PyTorch model with Hydra?

Decorate the model with @register_model('ModelName') and make __init__ accept only a cfg parameter, reading all hyperparameters from cfg.model and cfg.dataset. The forward method should return a dict containing loss, labels, and logits.

What is the difference between the factory pattern and registry pattern in Python?

The registry pattern uses decorators to add classes to a central dictionary at import time, while the factory pattern looks up names in that dictionary to instantiate classes dynamically. They work together: registration populates the factory.

When should I not use the factory and registry architecture?

Skip it when fixing bugs, modifying existing functions, adding helper utilities, editing configuration files, or refactoring without new registrable components. It only applies when a task requires a @register_* decorator or Factory wiring.

Why is my new model not found by ModelFactory?

The model file may not be auto-imported. Ensure it sits in the correct module directory, does not start with an underscore, and uses the @register_model decorator so import_modules() triggers registration at import time.