nvflare.tool.agent.frameworks.lightning module

PyTorch Lightning framework detector.

Lightning is a member of the PyTorch family: it declares family = "pytorch" and owns the base/superset promotion decision (promote_over_family) so the inspector engine stays framework-agnostic.

class LightningDetector[source]

Bases: FrameworkDetector

evidence_weights: dict[str, int] = {'lightning_class': 3, 'lightning_trainer': 3}

Evidence-kind -> ranking weight contributed by this framework.

family: str | None = 'pytorch'

Family this framework belongs to for cross-framework disambiguation (e.g. Lightning declares "pytorch"). None means standalone.

import_roots: dict[str, str] = {'lightning': 'pytorch_lightning', 'pytorch_lightning': 'pytorch_lightning'}

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 = 'pytorch_lightning'

Canonical framework name reported in inspector output (e.g. "pytorch").

new_file_state() _LightningFileState[source]

Return fresh per-file scratch state (import aliases, symbols).

on_call(call_name: str, lineno: int | None, file_state: _LightningFileState, ctx: DetectContext) None[source]

Handle a called name such as torch.optim.SGD or flare.patch.

on_class_base(base_name: str, lineno: int | None, file_state: _LightningFileState, ctx: DetectContext) None[source]

Handle a base class name in a class X(Base): definition.

on_import(alias: alias, file_state: _LightningFileState, ctx: DetectContext) None[source]

Handle import x / import x as y aliases.

on_import_from(module: str, aliases: list, file_state: _LightningFileState, 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. resolver gives access to the collected evidence and entry-context helpers so the decision stays in the framework module. Default: never promote.

recommended_skill: str | None = 'nvflare-convert-lightning'

Conversion skill recommended when this framework is primary, or None.