Reorder decorators for autodoc and dataclass#45702
Reorder decorators for autodoc and dataclass#45702zucchini-nlp wants to merge 2 commits intohuggingface:mainfrom
Conversation
| @dataclass | ||
| class MoECausalLMOutputWithPast(ModelOutput): | ||
| """ | ||
| Base class for causal language model (or autoregressive) outputs as well as Mixture of Expert's router hidden | ||
| states terms, to train a MoE model. | ||
|
|
There was a problem hiding this comment.
was defined twice, and this one is not used anywhere in codebase. Kept ref for BC with remote code at the bottom
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: aimv2, albert, align, aria, autoformer, aya_vision, bert, big_bird, blip, blip_2, bridgetower, bros, canine, chameleon, clap, clip |
vasqu
left a comment
There was a problem hiding this comment.
Nothing speaks against this, however before we merge I'd like to add a rule to https://github.com/huggingface/transformers-mlinter that detects this. This is a low hanging fruit but super annoying cc @tarekziade
| @dataclass | ||
| class MoECausalLMOutputWithPast(ModelOutput): | ||
| """ | ||
| Base class for causal language model (or autoregressive) outputs as well as Mixture of Expert's router hidden | ||
| states terms, to train a MoE model. | ||
|
|
What does this PR do?
Uncovered when working on smth else, reorders the decorators as per title to make sure the docs are added in correct
__init__With current order we are checking/setting the
__init__.__doc__on parent's__init__for model outputs which are always dataclasses. It is because decorators are applied from bottom upwards, andautodocis the first decorator called (before dataclass)Thus, a model output class (e.g.
AriaCausalLMOutputWithPast) has no__init__when trying to auto-add docstring and we generate/add/modify the docstring ofModelOutput.__init__That also uncovered an empty docstring for PeAudioVideo, fixed that one