Packages
snakepit
0.3.3
0.13.0
0.12.0
0.11.1
0.11.0
0.10.1
0.10.0
0.9.1
0.9.0
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.7
0.7.6
0.7.5
0.7.4
0.7.3
0.7.2
0.7.1
0.7.0
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
High-performance pooler and session manager for external language integrations. Supports Python, Node.js, Ruby, and more with gRPC streaming, session management, and production-ready process cleanup.
Current section
53 Versions
Jump to
Current section
53 Versions
Compare versions
6
files changed
+409
additions
-21
deletions
| @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. | |
| 5 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 6 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 7 | |
| 8 | + ## [0.3.3] - 2025-07-20 |
| 9 | + |
| 10 | + ### Added |
| 11 | + - Support for custom adapter arguments in gRPC adapter via pool configuration |
| 12 | + - Enhanced Python API commands (call, store, retrieve, list_stored, delete_stored) in gRPC adapter |
| 13 | + - Dynamic command validation based on adapter type in gRPC adapter |
| 14 | + |
| 15 | + ### Changed |
| 16 | + - GRPCPython adapter now accepts custom adapter arguments through pool_config.adapter_args |
| 17 | + - Improved supported_commands/0 to dynamically include commands based on the adapter in use |
| 18 | + |
| 19 | + ### Fixed |
| 20 | + - gRPC adapter now properly supports third-party Python adapters like DSPy integration |
| 21 | + |
| 8 22 | ## [0.3.2] - 2025-07-20 |
| 9 23 | |
| 10 24 | ### Fixed |
| @@ -106,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
| 106 120 | - Configurable pool sizes and timeouts |
| 107 121 | - Built-in bridge scripts for Python and JavaScript |
| 108 122 | |
| 123 | + [0.3.3]: https://github.com/nshkrdotcom/snakepit/releases/tag/v0.3.3 |
| 109 124 | [0.3.2]: https://github.com/nshkrdotcom/snakepit/releases/tag/v0.3.2 |
| 110 125 | [0.3.1]: https://github.com/nshkrdotcom/snakepit/releases/tag/v0.3.1 |
| 111 126 | [0.3.0]: https://github.com/nshkrdotcom/snakepit/releases/tag/v0.3.0 |
| @@ -74,7 +74,7 @@ Snakepit is a battle-tested Elixir library that provides a robust pooling system | |
| 74 74 | # In your mix.exs |
| 75 75 | def deps do |
| 76 76 | [ |
| 77 | - {:snakepit, "~> 0.3.2"} |
| 77 | + {:snakepit, "~> 0.3.3"} |
| 78 78 | ] |
| 79 79 | end |
| 80 80 | |
| @@ -104,7 +104,7 @@ Application.put_env(:snakepit, :pool_config, %{pool_size: 4}) | |
| 104 104 | ```elixir |
| 105 105 | def deps do |
| 106 106 | [ |
| 107 | - {:snakepit, "~> 0.3.2"} |
| 107 | + {:snakepit, "~> 0.3.3"} |
| 108 108 | ] |
| 109 109 | end |
| 110 110 | ``` |
| @@ -713,6 +713,32 @@ end) | |
| 713 713 | - âś… **Rich error handling** - gRPC status codes with detailed context |
| 714 714 | - âś… **Protocol buffers** - Efficient binary serialization |
| 715 715 | - âś… **Cancellable operations** - Stop long-running tasks gracefully |
| 716 | + - âś… **Custom adapter support** - Use third-party Python adapters via pool configuration |
| 717 | + |
| 718 | + #### Custom Adapter Support (v0.3.3+) |
| 719 | + |
| 720 | + The gRPC adapter now supports custom Python adapters through pool configuration: |
| 721 | + |
| 722 | + ```elixir |
| 723 | + # Configure with a custom Python adapter (e.g., DSPy integration) |
| 724 | + Application.put_env(:snakepit, :adapter_module, Snakepit.Adapters.GRPCPython) |
| 725 | + Application.put_env(:snakepit, :pool_config, %{ |
| 726 | + pool_size: 4, |
| 727 | + adapter_args: ["--adapter", "snakepit_bridge.adapters.dspy_grpc.DSPyGRPCHandler"] |
| 728 | + }) |
| 729 | + |
| 730 | + # The adapter can provide custom commands beyond the standard set |
| 731 | + {:ok, result} = Snakepit.Python.call("dspy.Predict", %{signature: "question -> answer"}) |
| 732 | + {:ok, result} = Snakepit.Python.call("stored.predictor.__call__", %{question: "What is DSPy?"}) |
| 733 | + ``` |
| 734 | + |
| 735 | + ##### Available Custom Adapters |
| 736 | + |
| 737 | + - **`snakepit_bridge.adapters.dspy_grpc.DSPyGRPCHandler`** - DSPy integration for declarative language model programming |
| 738 | + - Supports DSPy modules (Predict, ChainOfThought, ReAct, etc.) |
| 739 | + - Enhanced Python API with `call`, `store`, `retrieve` commands |
| 740 | + - Automatic signature parsing and field mapping |
| 741 | + - Session management for stateful operations |
| 716 742 | |
| 717 743 | #### Installation & Usage |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/nshkrdotcom/snakepit">>}]}. |
| 2 2 | {<<"name">>,<<"snakepit">>}. |
| 3 | - {<<"version">>,<<"0.3.2">>}. |
| 3 | + {<<"version">>,<<"0.3.3">>}. |
| 4 4 | {<<"description">>, |
| 5 5 | <<"High-performance pooler and session manager for external language integrations">>}. |
| 6 6 | {<<"elixir">>,<<"~> 1.18">>}. |
| @@ -50,6 +50,7 @@ | |
| 50 50 | <<"priv/python/snakepit_bridge/grpc/snakepit_pb2_grpc.py">>, |
| 51 51 | <<"priv/python/snakepit_bridge/adapters">>, |
| 52 52 | <<"priv/python/snakepit_bridge/adapters/__init__.py">>, |
| 53 | + <<"priv/python/snakepit_bridge/adapters/dspy_grpc.py">>, |
| 53 54 | <<"priv/python/snakepit_bridge/adapters/grpc_streaming.py">>, |
| 54 55 | <<"priv/python/snakepit_bridge/adapters/generic.py">>,<<"priv/javascript">>, |
| 55 56 | <<"priv/javascript/generic_bridge.js">>,<<"assets">>, |
| @@ -58,40 +58,79 @@ defmodule Snakepit.Adapters.GRPCPython do | |
| 58 58 | |
| 59 59 | @impl true |
| 60 60 | def script_args do |
| 61 | - # Use the streaming test handler for gRPC streaming commands |
| 61 | + # Check if custom adapter args are provided in pool config |
| 62 | + pool_config = Application.get_env(:snakepit, :pool_config, %{}) |
| 63 | + adapter_args = Map.get(pool_config, :adapter_args, nil) |
| 64 | + |
| 65 | + if adapter_args do |
| 66 | + # Use custom adapter args if provided |
| 67 | + adapter_args |
| 68 | + else |
| 69 | + # Default to streaming test handler |
| 62 70 | ["--adapter", "snakepit_bridge.adapters.grpc_streaming.GRPCStreamingHandler"] |
| 63 71 | end |
| 72 | + end |
| 64 73 | |
| 65 74 | @impl true |
| 66 75 | def supported_commands do |
| 67 | - # Basic commands + streaming commands |
| 68 | - [ |
| 76 | + # Check if we're using DSPy adapter |
| 77 | + pool_config = Application.get_env(:snakepit, :pool_config, %{}) |
| 78 | + adapter_args = Map.get(pool_config, :adapter_args, []) |
| 79 | + |
| 80 | + base_commands = [ |
| 69 81 | "ping", |
| 70 82 | "echo", |
| 71 83 | "compute", |
| 72 84 | "info", |
| 73 | - # Streaming commands |
| 85 | + # Enhanced Python API |
| 86 | + "call", |
| 87 | + "store", |
| 88 | + "retrieve", |
| 89 | + "list_stored", |
| 90 | + "delete_stored" |
| 91 | + ] |
| 92 | + |
| 93 | + streaming_commands = [ |
| 74 94 | "ping_stream", |
| 75 95 | "batch_inference", |
| 76 96 | "process_large_dataset", |
| 77 97 | "tail_and_analyze" |
| 78 98 | ] |
| 99 | + |
| 100 | + dspy_commands = [ |
| 101 | + "configure_lm", |
| 102 | + "create_program", |
| 103 | + "create_gemini_program", |
| 104 | + "execute_program", |
| 105 | + "execute_gemini_program", |
| 106 | + "list_programs", |
| 107 | + "delete_program", |
| 108 | + "get_stats", |
| 109 | + "cleanup", |
| 110 | + "reset_state", |
| 111 | + "get_program_info", |
| 112 | + "cleanup_session", |
| 113 | + "shutdown" |
| 114 | + ] |
| 115 | + |
| 116 | + # Include DSPy commands if using DSPy adapter |
| 117 | + if Enum.any?(adapter_args, &String.contains?(&1, "dspy")) do |
| 118 | + base_commands ++ streaming_commands ++ dspy_commands |
| 119 | + else |
| 120 | + base_commands ++ streaming_commands |
| 121 | + end |
| 79 122 | end |
| 80 123 | |
| 81 124 | @impl true |
| 82 | - def validate_command(command, _args) when command in ["ping", "echo", "compute", "info"], |
| 83 | - do: :ok |
| 125 | + def validate_command(command, _args) do |
| 126 | + supported = supported_commands() |
| 84 127 | |
| 85 | - def validate_command(command, _args) |
| 86 | - when command in [ |
| 87 | - "ping_stream", |
| 88 | - "batch_inference", |
| 89 | - "process_large_dataset", |
| 90 | - "tail_and_analyze" |
| 91 | - ], |
| 92 | - do: :ok |
| 93 | - |
| 94 | - def validate_command(command, _args), do: {:error, "Unsupported command: #{command}"} |
| 128 | + if command in supported do |
| 129 | + :ok |
| 130 | + else |
| 131 | + {:error, "Unsupported command: #{command}"} |
| 132 | + end |
| 133 | + end |
| 95 134 | |
| 96 135 | # Optional callbacks for gRPC-specific functionality |
| @@ -4,7 +4,7 @@ defmodule Snakepit.MixProject do | |
| 4 4 | def project do |
| 5 5 | [ |
| 6 6 | app: :snakepit, |
| 7 | - version: "0.3.2", |
| 7 | + version: "0.3.3", |
| 8 8 | elixir: "~> 1.18", |
| 9 9 | start_permanent: Mix.env() == :prod, |
| 10 10 | description: |
| @@ -59,7 +59,16 @@ defmodule Snakepit.MixProject do | |
| 59 59 | "CHANGELOG*", |
| 60 60 | "DIAGS*" |
| 61 61 | ], |
| 62 | - exclude_patterns: ["**/__pycache__", "**/*.pyc", "**/*.egg-info", "**/*.bak", "priv/plts"] |
| 62 | + exclude_patterns: [ |
| 63 | + "**/__pycache__", |
| 64 | + "**/*.pyc", |
| 65 | + "**/*.egg-info", |
| 66 | + "**/*.bak", |
| 67 | + "priv/plts", |
| 68 | + "priv/python/snakepit_bridge/__pycache__", |
| 69 | + "priv/python/snakepit_bridge/grpc/__pycache__", |
| 70 | + "priv/python/snakepit_bridge/adapters/__pycache__" |
| 71 | + ] |
| 63 72 | ] |
| 64 73 | end |
Loading more files…