ml_switcheroo.analysis.dependencies¶
Static Dependency Analysis for Transpilation Safety.
This module provides the DependencyScanner, a LibCST visitor that identifies
third-party dependencies imported in the source code.
It serves as a safety check during transpilation:
Identifies imports (e.g.,
import pandas,from sklearn import metrics).Filters out Standard Library modules (e.g.,
os,sys,json).Filters out the Source Framework (e.g.,
torch), as these are handled by the coreImportFixerandPivotRewriter.Validates the remaining imports against the Semantics Manager.
If a third-party import (e.g., cv2) is found but not mapped in the
semantics (Import Map), it warns the user that the target environment
might lack the equivalent library or that the mapping logic is missing.
Classes¶
Scans for 3rd-party imports not covered by the Semantic Knowledge Base. |
Module Contents¶
- class ml_switcheroo.analysis.dependencies.DependencyScanner(semantics: ml_switcheroo.semantics.manager.SemanticsManager, source_fw: str)¶
Bases:
libcst.CSTVisitorScans for 3rd-party imports not covered by the Semantic Knowledge Base.
- semantics¶
- source_fw¶
- unknown_imports: Set[str]¶
- visit_Import(node: libcst.Import) None¶
Visits
import x,import x.y. Checks the root package name.
- visit_ImportFrom(node: libcst.ImportFrom) None¶
Visits
from x import y. Checks the module root package name.