MCPcopy Create free account
hub / github.com/modelscope/modelscope / AnalysisSourceFileRegisterModules

Class AnalysisSourceFileRegisterModules

modelscope/utils/input_output.py:371–393  ·  view source on GitHub ↗

Get register_module call of the python source file. Args: ast (NodeVisitor): The ast node. Examples: >>> with open(source_file_path, "rb") as f: >>> src = f.read() >>> analyzer = AnalysisSourceFileRegisterModules(source_file_path) >>> an

Source from the content-addressed store, hash-verified

369
370
371class AnalysisSourceFileRegisterModules(ast.NodeVisitor):
372 """Get register_module call of the python source file.
373
374
375 Args:
376 ast (NodeVisitor): The ast node.
377
378 Examples:
379 >>> with open(source_file_path, "rb") as f:
380 >>> src = f.read()
381 >>> analyzer = AnalysisSourceFileRegisterModules(source_file_path)
382 >>> analyzer.visit(ast.parse(src, filename=source_file_path))
383 """
384
385 def __init__(self, source_file_path, class_name) -> None:
386 super().__init__()
387 self.source_file_path = source_file_path
388 self.class_name = class_name
389 self.class_define = None
390
391 def visit_ClassDef(self, node: ast.ClassDef):
392 if node.name == self.class_name:
393 self.class_define = node
394
395
396def get_pipeline_input_parameters(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…