nvflare.tool.agent.frameworks package
Submodules
- nvflare.tool.agent.frameworks.base module
DetectContextFrameworkDetectorFrameworkDetector.evidence_weightsFrameworkDetector.familyFrameworkDetector.import_rootsFrameworkDetector.is_active_evidence()FrameworkDetector.nameFrameworkDetector.new_file_state()FrameworkDetector.on_call()FrameworkDetector.on_class_base()FrameworkDetector.on_import()FrameworkDetector.on_import_from()FrameworkDetector.promote_over_family()FrameworkDetector.recommended_skill
- nvflare.tool.agent.frameworks.lightning module
LightningDetectorLightningDetector.evidence_weightsLightningDetector.familyLightningDetector.import_rootsLightningDetector.is_active_evidence()LightningDetector.nameLightningDetector.new_file_state()LightningDetector.on_call()LightningDetector.on_class_base()LightningDetector.on_import()LightningDetector.on_import_from()LightningDetector.promote_over_family()LightningDetector.recommended_skill
- nvflare.tool.agent.frameworks.pytorch module
PyTorchDetectorPyTorchDetector.evidence_weightsPyTorchDetector.import_rootsPyTorchDetector.is_active_evidence()PyTorchDetector.namePyTorchDetector.new_file_state()PyTorchDetector.on_call()PyTorchDetector.on_class_base()PyTorchDetector.on_import()PyTorchDetector.on_import_from()PyTorchDetector.recommended_skill
- nvflare.tool.agent.frameworks.registry module
Module contents
Per-framework static-detection plugins for the agent inspector.
The inspector engine (inspector.py) stays framework-agnostic: it walks each
Python AST once and dispatches every node to the registered
FrameworkDetector plugins. All framework-specific knowledge – import
roots, symbols, evidence kinds and weights, the recommended conversion skill,
and cross-framework family/promotion rules – lives in a detector module here.
Adding a framework (XGBoost, TensorFlow, Hugging Face, …) means adding a
detector module and registering it in registry.py; the engine does not
change.
- class DetectContext(emit_evidence, add_flare_call, add_integration_signal)[source]
Bases:
objectPer-file sink the engine hands to detector hooks.
The detector records framework evidence and FLARE-integration signals through this context instead of touching inspector internals directly, so the engine owns how those signals are stored and ranked.
- class FrameworkDetector[source]
Bases:
objectStatic-detection plugin for a single framework.
Subclasses set the class attributes and override the
on_*hooks they need. Every hook is optional; the base implementations do nothing.- evidence_weights: dict[str, int] = {}
Evidence-kind -> ranking weight contributed by this framework.
- family: str | None = None
Family this framework belongs to for cross-framework disambiguation (e.g. Lightning declares
"pytorch").Nonemeans standalone.
- import_roots: dict[str, str] = {}
Top-level import module names that map to this framework’s evidence bucket, e.g.
{"torch": "pytorch"}. Used for ranked import evidence.
- is_active_evidence(evidence: dict) bool[source]
Whether an evidence item counts as active (in-use) for this framework.
Used by family disambiguation to distinguish active use from an incidental import. Defaults to non-import evidence.
- name: str = ''
Canonical framework name reported in inspector output (e.g.
"pytorch").
- on_call(call_name: str, lineno: int | None, file_state: Any, ctx: DetectContext) None[source]
Handle a called name such as
torch.optim.SGDorflare.patch.
- on_class_base(base_name: str, lineno: int | None, file_state: Any, ctx: DetectContext) None[source]
Handle a base class name in a
class X(Base):definition.
- on_import(alias: alias, file_state: Any, ctx: DetectContext) None[source]
Handle
import x/import x as yaliases.
- on_import_from(module: str, aliases: list, file_state: Any, ctx: DetectContext) None[source]
Handle
from module import ...symbols.
- promote_over_family(family_base: str, resolver) bool[source]
For a family member, decide whether to win over the family base.
Only called for detectors that declare a
family.resolvergives access to the collected evidence and entry-context helpers so the decision stays in the framework module. Default: never promote.
- recommended_skill: str | None = None
Conversion skill recommended when this framework is primary, or
None.
- detectors() list[FrameworkDetector][source]
- family_base_has_member(base: str | None, evidence_by_framework: dict) str | None[source]
If
baseis a family base with a member present in evidence, return the member name.
- framework_for_import(module: str) str | None[source]
Map an imported module to its framework bucket by top-level segment.
- resolve_primary_framework(primary: str, evidence_by_framework: dict, resolver) str[source]
Disambiguate a family conflict (e.g. PyTorch vs PyTorch Lightning).
Returns the framework that should be primary. Only overrides
primarywhen it is part of a family whose base and member both have evidence; the member detector owns the promotion decision.