Deprecate legacy training APIs#4641
Conversation
|
@greptileai review |
Greptile SummaryThis PR deprecates the legacy
Confidence Score: 5/5Safe to merge — the change is purely additive, emitting a DeprecationWarning on instantiation of legacy classes without altering any functional behavior. The No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["ModelLearner.__init__ / NPTrainer.__init__"] -->|"calls stacklevel=3"| B["warn_deprecated"]
J["deprecated decorator new_func"] -->|"calls stacklevel=3"| B
B --> C["Acquire _DEPRECATION_WARNING_LOCK"]
C --> D["warnings.catch_warnings enter"]
D --> E["simplefilter always DeprecationWarning"]
E --> F["warnings.warn DeprecationWarning"]
F --> G["Restore saved filter state"]
G --> H["Release lock"]
H --> I["super init continues normally"]
style B fill:#f9a,stroke:#c66
style C fill:#adf,stroke:#06c
style F fill:#ffd,stroke:#aa0
Reviews (2): Last reviewed commit: "Clarify legacy API warning text" | Re-trigger Greptile |
| from nvflare.fuel.utils.deprecated import warn_deprecated | ||
| from nvflare.security.logging import secure_format_exception | ||
|
|
||
| _NP_TRAINER_DEPRECATION_MSG = "NPTrainer is deprecated. Use the Recipe API with the Client API for new projects." |
There was a problem hiding this comment.
do we want to also deprecate
- nvflare.app_common.np.np_formatter.NPFormatter
- nvflare.app_common.ccwf.comps.np_file_model_persistor.NPFileModelPersistor
There was a problem hiding this comment.
I checked current usage before expanding scope. NPFormatter and NPFileModelPersistor are still referenced by legacy job templates/docs and integration-test fixtures, so I left them out of this PR rather than broadening the warning surface. This PR now keeps the deprecation to ModelLearner and both NPTrainer classes only.
| from nvflare.app_common.utils.fl_component_wrapper import FLComponentWrapper | ||
| from nvflare.fuel.utils.deprecated import warn_deprecated | ||
|
|
||
| _MODEL_LEARNER_DEPRECATION_MSG = "ModelLearner is deprecated. Use the Recipe API with the Client API for new projects." |
There was a problem hiding this comment.
Our plan is to deprecate them in 2.9 and remove in the 2.10?
There was a problem hiding this comment.
Not sure if we need to remove them if they are still supported. Just do not recommend building on top of it.
There was a problem hiding this comment.
Updated in 0bcd08751 to avoid implying a scheduled removal: the warning now says these APIs are deprecated but remain supported for backward compatibility, and points users to Recipe API + Client API for new projects. This matches the intent of not recommending new work on top of them while keeping existing usage supported.
|
@greptileai review again |
Summary
warn_deprecatedhelper that preserves the existing always-visible deprecation behaviorModelLearnerand bothNPTrainervariants are instantiatedExisting example usage check
examples/for live imports/config references toModelLearner,ModelLearnerExecutor, and bothNPTrainerpaths.job_templates/still reference these APIs, so this PR warns on use but does not remove or break backward-compatible loading.Validation
pytest tests/unit_test/fuel/utils/deprecated_test.py tests/unit_test/app_common/abstract/model_learner_test.py tests/unit_test/app_common/np/np_trainer_test.py tests/unit_test/app_common/ccwf/ccwf_np_trainer_test.py tests/unit_test/job_config/fed_job_test.py -qgit diff --check