Class PythonRewriteRpc

java.lang.Object
org.openrewrite.rpc.RewriteRpc
org.openrewrite.python.rpc.PythonRewriteRpc

public class PythonRewriteRpc extends org.openrewrite.rpc.RewriteRpc
  • Method Details

    • get

      public static @Nullable PythonRewriteRpc get()
    • getOrStart

      public static PythonRewriteRpc getOrStart()
    • setFactory

      public static void setFactory(PythonRewriteRpc.Builder builder)
    • shutdown

      public void shutdown()
      Overrides:
      shutdown in class org.openrewrite.rpc.RewriteRpc
    • shutdownCurrent

      public static void shutdownCurrent()
    • resetCurrent

      public static void resetCurrent()
      Resets the cached state of the current Python RPC instance. This clears all parsed objects and references on both the Java and Python sides, preventing memory accumulation across multiple parse operations.

      Call this between tests or after batch operations that don't need to share state.

    • installRecipes

      public InstallRecipesResponse installRecipes(File recipes)
      Install recipes from a local file path (e.g., a local pip package).
      Parameters:
      recipes - Path to the local package directory
      Returns:
      Response with installation details
    • installRecipes

      public InstallRecipesResponse installRecipes(String packageName)
      Install recipes from a package name.
      Parameters:
      packageName - The package name to install
      Returns:
      Response with installation details
    • installRecipes

      public InstallRecipesResponse installRecipes(String packageName, @Nullable String version)
      Install recipes from a package name with a specific version.
      Parameters:
      packageName - The package name to install
      version - Optional version specification
      Returns:
      Response with installation details
    • parseProject

      public Stream<org.openrewrite.SourceFile> parseProject(Path projectPath, org.openrewrite.ExecutionContext ctx)
      Parses an entire Python project directory. Discovers and parses all relevant source files.
      Parameters:
      projectPath - Path to the project directory to parse
      ctx - Execution context for parsing
      Returns:
      Stream of parsed source files
    • parseProject

      public Stream<org.openrewrite.SourceFile> parseProject(Path projectPath, @Nullable List<String> exclusions, org.openrewrite.ExecutionContext ctx)
      Parses an entire Python project directory. Discovers and parses all relevant source files.
      Parameters:
      projectPath - Path to the project directory to parse
      exclusions - Optional glob patterns to exclude from parsing
      ctx - Execution context for parsing
      Returns:
      Stream of parsed source files
    • parseProject

      public Stream<org.openrewrite.SourceFile> parseProject(Path projectPath, @Nullable List<String> exclusions, @Nullable Path relativeTo, org.openrewrite.ExecutionContext ctx)
      Parses an entire Python project directory. Discovers and parses all relevant source files.
      Parameters:
      projectPath - Path to the project directory to parse
      exclusions - Optional glob patterns to exclude from parsing
      relativeTo - Optional path to make source file paths relative to
      ctx - Execution context for parsing
      Returns:
      Stream of parsed source files
    • builder

      public static PythonRewriteRpc.Builder builder()