Coverage for / home / jenkins / .local / lib / python3.10 / site-packages / hyper_parallel / trainer / __init__.py: 55%
11 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-12-05 05:12 +0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-12-05 05:12 +0800
1# Copyright 2026 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ============================================================================
15"""Top-level training public API.
17Rebuilt in stage 7 (05 §10.1): the trainer classes moved here from
18``auto_models/trainer/`` (S7d). Exports are lazy so that importing the
19package (e.g. for ``trainer.config`` or ``trainer.callbacks``) stays cheap
20and does not pull the model/data stack until a trainer class is touched.
21"""
23# pylint: disable=undefined-all-variable
24__all__ = [
25 "BaseTrainer",
26 "TextTrainer",
27 "VLMTrainer",
28 "DiTTrainer",
29 "TrainerState",
30]
32_LAZY_EXPORTS = {
33 "BaseTrainer": "hyper_parallel.trainer.base",
34 "TextTrainer": "hyper_parallel.trainer.text_trainer",
35 "VLMTrainer": "hyper_parallel.trainer.vlm_trainer",
36 "DiTTrainer": "hyper_parallel.trainer.dit_trainer",
37 "TrainerState": "hyper_parallel.trainer.state",
38}
41def __getattr__(name): # pylint: disable=invalid-name
42 """Resolve trainer classes lazily on first attribute access."""
43 if name in _LAZY_EXPORTS:
44 import importlib # pylint: disable=import-outside-toplevel
46 value = getattr(importlib.import_module(_LAZY_EXPORTS[name]), name)
47 globals()[name] = value
48 return value
49 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
52def __dir__(): # pylint: disable=invalid-name
53 """List lazy exports for interactive discovery."""
54 return sorted(__all__)