Metadata-Version: 2.4 Name: pydantic-monty-client Version: 0.0.23 Classifier: Development Status :: 3 - Alpha Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 Classifier: Programming Language :: Python :: 3.14 Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: Unix Classifier: Operating System :: POSIX :: Linux Classifier: Environment :: MacOS X Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Internet Classifier: Programming Language :: Python :: Implementation Requires-Dist: typing-extensions>=4.5 Requires-Dist: opentelemetry-api>=1.39.0 ; extra == 'opentelemetry' Provides-Extra: opentelemetry Summary: Python client for the Monty sandboxed Python interpreter Home-Page: https://github.com/pydantic/monty/ License: MIT Requires-Python: >=3.10 Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM Project-URL: Homepage, https://github.com/pydantic/monty Project-URL: Source, https://github.com/pydantic/monty # pydantic-monty-client Python client for the Monty sandboxed Python interpreter. Most users want [`pydantic-monty`](https://pypi.org/project/pydantic-monty/) instead, which pulls in this package plus [`pydantic-monty-runtime`](https://pypi.org/project/pydantic-monty-runtime/) and is documented in full on its PyPI page. Install this package directly to use the websocket client alone, or if you're installing the `monty` binary another way. ```bash uv add pydantic-monty-client # or pip install pydantic-monty-client ``` ## Usage with a remote monty server and websockets You can use this library alone to connect to a remote monty server via websockets. ```python test="skip" from pydantic_monty import AsyncMontyWebsocket async def main() -> None: url = '...' async with AsyncMontyWebsocket(url) as pool: async with pool.checkout() as session: output = await session.feed_run('1 + 1') print('output ->', output) if __name__ == '__main__': import asyncio asyncio.run(main()) ``` ## Usage with a local monty worker Host objects and classes cross the boundary through the `ClassInstance` / `ClassType` wrappers; see the `pydantic-monty` README. This requires the `pydantic-monty-runtime` package, which is generally installed as part of the `pydantic-monty` meta-package. ```python from pydantic_monty import Monty with Monty() as pool: with pool.checkout(limits={'max_suspensions': 100}) as session: print(session.feed_run('1 + 2')) #> 3 ``` `max_suspensions` limits host-serviced suspensions per checkout (default 1000; it cannot be disabled). Exceeding it aborts the feed with an uncatchable `RuntimeError`; the session remains usable, but its suspension count remains spent. or in async code: ```python from pydantic_monty import AsyncMonty async def main() -> None: async with AsyncMonty() as pool: async with pool.checkout() as session: output = await session.feed_run('1 + 1') print('output from local worker ->', output) #> output from local worker -> 2 if __name__ == '__main__': import asyncio asyncio.run(main()) ``` See the [`pydantic-monty`](https://pypi.org/project/pydantic-monty/) README for more details.