huggingface / huggingface/diffusers
Question about the `# Copied from` system
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 34.5k
- Forks
- 7.3k
- Ø Merge
- 3 T. 3 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
Hi team! 👋
While working on improving docstrings and type hints across scheduler files (issue #9567), I've noticed the # Copied from pattern used extensively throughout the codebase.
Examples:
- Functions like
betas_for_alpha_barare duplicated across multiple schedulers - Output classes like
DDPMSchedulerOutputare copied with name replacements (e.g., DDPM->EulerDiscrete)
My question: What's the rationale behind this duplication system instead of:
- Using a shared utils.py or common.py file for common functions
- Using class inheritance for similar Output classes
I understand there might be good architectural reasons (module independence, API stability, avoiding circular dependencies, etc.), but this isn't documented anywhere that I could find.
Suggested action: Regardless of the answer, I think we should either:
- Option A: Refactor to use inheritance/shared utilities (if the current system is legacy)
- Option B: Document this design decision in:
- A CONTRIBUTING.md or architecture doc
- Comments in the utils/check_copies.py script itself
- Another README in the diffusers directory
This would help future contributors (like me! 😅) understand why this pattern exists and how to work with it properly when improving documentation. What do you think?
Thanks for maintaining such a great library! 🚀
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Lies zunächst die im Issue genannten Scheduler-Beispiele und utils/check_copies.py, und prüfe anschließend die Diskussion auf eine Entscheidung zu Duplizierung, gemeinsam genutzten Hilfsfunktionen oder Vererbung. Als abgeschlossen gilt die Aufgabe, wenn die Begründung und der Workflow für Mitwirkende an einer vereinbarten Stelle wie CONTRIBUTING.md, einem Architekturdokument oder Kommentaren im Skript zur Prüfung von Kopien dokumentiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- developer-experience, documentation
- Issue-Typ
- Dokumentation
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100