Skip to content

discover_imports

relationalai.agent.cortex.discover_imports
discover_imports(file_path: Optional[str] = None) -> List[Tuple[str, str]]

Discover all user (non-dependency) imports from the given file and its dependencies.

Recursively discovers imports from imported modules (transitive dependencies). Only includes top-level custom modules (not standard library or dependencies). Always returns an empty list on errors, with warnings logged.

Output is intended to be passed directly to the imports parameter of the snowflake.snowpark.Session.sproc.register().

  • file_path

    (str, default: None) - Path to a file to analyze. If None, uses the calling file.
  • list of tuple of (str, str) - List of (module_path, module_name) tuples for discovered user modules.
>>> imports = discover_imports()
>>> imports
[('src/myproject/', 'myproject')]