diff --git a/docs/chains/doc_gen/API-reference.mdx b/docs/chains/doc_gen/API-reference.mdx index 3c337764a..551a2020d 100644 --- a/docs/chains/doc_gen/API-reference.mdx +++ b/docs/chains/doc_gen/API-reference.mdx @@ -86,12 +86,12 @@ an access token for downloading model weights). **Parameters:** -| Name | Type | Description | -|-----------------------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | -| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#class-truss-chains-deployedservicedescriptor)]]* | A mapping from chainlet names to service descriptors. This is used create RPCs sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | -| `secrets` | *Mapping[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | -| `environment` | *[Environment](#class-truss-chains-definitions-environment)\|None* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | +| Name | Type | Description | +|-----------------------|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | +| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#class-truss-chains-deployedservicedescriptor)]]* | A mapping from chainlet names to service descriptors. This is used to create RPC sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | +| `secrets` | *Mapping[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | +| `environment` | *[Environment](#class-truss-chains-definitions-environment)\|None* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | #### get_baseten_api_key() diff --git a/docs/chains/doc_gen/generated-reference.mdx b/docs/chains/doc_gen/generated-reference.mdx index c668871af..bbc226cda 100644 --- a/docs/chains/doc_gen/generated-reference.mdx +++ b/docs/chains/doc_gen/generated-reference.mdx @@ -7,6 +7,7 @@ https://github.com/basetenlabs/truss/tree/main/docs/chains/doc_gen APIs for creating user-defined Chainlets. + ### *class* `truss_chains.ChainletBase` Base class for all chainlets. @@ -70,6 +71,7 @@ context instance is provided. * **Return type:** [*DeploymentContext*](#truss_chains.DeploymentContext) + ### *class* `truss_chains.DeploymentContext` Bases: `pydantic.BaseModel` @@ -86,7 +88,7 @@ an access token for downloading model weights). | Name | Type | Description | |------|------|-------------| | `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | -| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#truss_chains.DeployedServiceDescriptor* | A mapping from chainlet names to service descriptors. This is used create RPCs sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | +| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#truss_chains.DeployedServiceDescriptor* | A mapping from chainlet names to service descriptors. This is used to create RPC sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | | `secrets` | *MappingNoIter[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | | `environment` | *[Environment](#truss_chains.definitions.Environment* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | @@ -110,6 +112,7 @@ an access token for downloading model weights). #### secrets *: MappingNoIter[str, str]* + ### *class* `truss_chains.definitions.Environment` Bases: `pydantic.BaseModel` @@ -120,6 +123,7 @@ The environment the chainlet is deployed in. **name** (*str*) – The name of the environment. #### name *: str* + ### *class* `truss_chains.ChainletOptions` Bases: `pydantic.BaseModel` @@ -136,6 +140,7 @@ Bases: `pydantic.BaseModel` #### env_variables *: Mapping[str, str]* + ### *class* `truss_chains.RPCOptions` Bases: `pydantic.BaseModel` @@ -184,6 +189,7 @@ class MyChainlet(ChainletBase): These data structures specify for each chainlet how it gets deployed remotely, e.g. dependencies and compute resources. + ### *class* `truss_chains.RemoteConfig` Bases: `pydantic.BaseModel` @@ -237,6 +243,7 @@ class MyChainlet(chains.ChainletBase): #### options *: [ChainletOptions](#truss_chains.ChainletOptions)* + ### *class* `truss_chains.DockerImage` Bases: `pydantic.BaseModel` @@ -275,6 +282,7 @@ modules and keep their requirement files right next their python source files. #### pip_requirements_file *: AbsPath | None* + ### *class* `truss_chains.BasetenImage` Bases: `Enum` @@ -288,6 +296,7 @@ uses GPUs, drivers will be included in the image. #### PY39 *= 'py39'* + ### *class* `truss_chains.CustomImage` Bases: `pydantic.BaseModel` @@ -309,6 +318,7 @@ Configures the usage of a custom image hosted on dockerhub. #### python_executable_path *: str | None* + ### *class* `truss_chains.Compute` Specifies which compute resources a chainlet has in the *remote* deployment. @@ -347,6 +357,7 @@ two ways: * **Return type:** *ComputeSpec* + ### *class* `truss_chains.Assets` Specifies which assets a chainlet can access in the remote deployment. @@ -416,6 +427,7 @@ Deploys a chain remotely (with all dependent chainlets). * **Return type:** *BasetenChainService* + ### *class* `truss_chains.deployment.deployment_client.ChainService` Bases: `ABC` @@ -578,6 +590,7 @@ if __name__ == "__main__": Refer to the [local debugging guide](https://docs.baseten.co/chains/guide#test-a-chain-locally) for more details. + ### *class* `truss_chains.DeployedServiceDescriptor` Bases: `ServiceDescriptor` @@ -594,6 +607,7 @@ Bases: `ServiceDescriptor` #### predict_url *: str* + ### *class* `truss_chains.StubBase` Bases: `BasetenSession`, `ABC` @@ -611,12 +625,12 @@ flexibly supports JSON and pydantic inputs and output. Example usage: import pydantic import truss_chains as chains + class WhisperOutput(pydantic.BaseModel): ... class DeployedWhisper(chains.StubBase): - # Input JSON, output JSON. async def run_remote(self, audio_b64: str) -> Any: return await self.predict_async( @@ -685,6 +699,7 @@ Factory method, convenient to be used in chainlet’s `__init__`-method. #### predict_sync(inputs: InputT, output_model: None = None) → Any + ### *class* `truss_chains.RemoteErrorDetail` Bases: `pydantic.BaseModel` diff --git a/docs/chains/doc_gen/reference.patch b/docs/chains/doc_gen/reference.patch index 58adbce91..d1a911c9f 100644 --- a/docs/chains/doc_gen/reference.patch +++ b/docs/chains/doc_gen/reference.patch @@ -1,14 +1,6 @@ ---- docs/chains/doc_gen/generated-reference.mdx 2024-12-11 16:49:26.186551700 -0800 -+++ docs/chains/doc_gen/API-reference.mdx 2024-12-12 12:42:19.759044842 -0800 -@@ -7,6 +7,7 @@ - - APIs for creating user-defined Chainlets. - -+ - ### *class* `truss_chains.ChainletBase` - - Base class for all chainlets. -@@ -18,32 +19,33 @@ +--- docs/chains/doc_gen/generated-reference.mdx 2024-12-12 12:51:17.671757358 -0800 ++++ docs/chains/doc_gen/API-reference.mdx 2024-12-12 12:51:17.673757449 -0800 +@@ -19,32 +19,33 @@ [example chainlet](https://github.com/basetenlabs/truss/blob/main/truss-chains/truss_chains/example_chainlet.py) for more guidance on how to create subclasses. @@ -51,7 +43,7 @@ * **Returns:** A “symbolic marker” to be used as a default argument in a chainlet’s -@@ -51,6 +53,7 @@ +@@ -52,6 +53,7 @@ * **Return type:** *ChainletT* @@ -59,7 +51,7 @@ ### `truss_chains.depends_context` Sets a “symbolic marker” for injecting a context object at runtime. -@@ -59,16 +62,16 @@ +@@ -60,16 +62,15 @@ [example chainlet](https://github.com/basetenlabs/truss/blob/main/truss-chains/truss_chains/example_chainlet.py) for more guidance on the `__init__`-signature of chainlets. @@ -75,18 +67,17 @@ initializer. -* **Return type:** - [*DeploymentContext*](#truss_chains.DeploymentContext) -+ - ### *class* `truss_chains.DeploymentContext` -@@ -83,18 +86,12 @@ + ### *class* `truss_chains.DeploymentContext` +@@ -85,18 +86,12 @@ **Parameters:** -| Name | Type | Description | -|------|------|-------------| -| `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | --| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#truss_chains.DeployedServiceDescriptor* | A mapping from chainlet names to service descriptors. This is used create RPCs sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | +-| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#truss_chains.DeployedServiceDescriptor* | A mapping from chainlet names to service descriptors. This is used to create RPC sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | -| `secrets` | *MappingNoIter[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | -| `environment` | *[Environment](#truss_chains.definitions.Environment* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | - @@ -95,45 +86,44 @@ -#### data_dir *: Path | None* - -#### environment *: [Environment](#truss_chains.definitions.Environment) | None* -+| Name | Type | Description | -+|-----------------------|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -+| `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | -+| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#class-truss-chains-deployedservicedescriptor)]]* | A mapping from chainlet names to service descriptors. This is used create RPCs sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | -+| `secrets` | *Mapping[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | -+| `environment` | *[Environment](#class-truss-chains-definitions-environment)\|None* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | ++| Name | Type | Description | ++|-----------------------|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ++| `data_dir` | *Path\|None* | The directory where the chainlet can store and access data, e.g. for downloading model weights. | ++| `chainlet_to_service` | *Mapping[str,[DeployedServiceDescriptor](#class-truss-chains-deployedservicedescriptor)]]* | A mapping from chainlet names to service descriptors. This is used to create RPC sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. | ++| `secrets` | *Mapping[str,str]* | A mapping from secret names to secret values. It contains only the secrets that are listed in `remote_config.assets.secret_keys` of the current chainlet. | ++| `environment` | *[Environment](#class-truss-chains-definitions-environment)\|None* | The environment that the chainlet is deployed in. None if the chainlet is not associated with an environment. | #### get_baseten_api_key() -@@ -103,12 +100,15 @@ +@@ -105,12 +100,14 @@ #### get_service_descriptor(chainlet_name) -* **Parameters:** - **chainlet_name** (*str*) +-* **Return type:** +- [*DeployedServiceDescriptor*](#truss_chains.DeployedServiceDescriptor) +**Parameters:** -+ + +-#### secrets *: MappingNoIter[str, str]* +| Name | Type | Description | +|-----------------|-------|---------------------------| +| `chainlet_name` | *str* | The name of the chainlet. | + - * **Return type:** -- [*DeployedServiceDescriptor*](#truss_chains.DeployedServiceDescriptor) ++* **Return type:** + [*DeployedServiceDescriptor*](#class-truss-chains-deployedservicedescriptor) --#### secrets *: MappingNoIter[str, str]* ### *class* `truss_chains.definitions.Environment` - -@@ -118,7 +118,7 @@ +@@ -121,7 +118,6 @@ * **Parameters:** **name** (*str*) – The name of the environment. -#### name *: str* -+ - ### *class* `truss_chains.ChainletOptions` -@@ -127,14 +127,11 @@ + ### *class* `truss_chains.ChainletOptions` +@@ -131,14 +127,10 @@ **Parameters:** @@ -143,16 +133,16 @@ -| `env_variables` | *Mapping[str,str]* | static environment variables available to the deployed chainlet. | - -#### enable_b10_tracing *: bool* +- +-#### env_variables *: Mapping[str, str]* +| Name | Type | Description | +|------------------------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `enable_b10_tracing` | *bool* | enables baseten-internal trace data collection. This helps baseten engineers better analyze chain performance in case of issues. It is independent of a potentially user-configured tracing instrumentation. Turning this on, could add performance overhead. | +| `env_variables` | *Mapping[str,str]* | static environment variables available to the deployed chainlet. | --#### env_variables *: Mapping[str, str]* ### *class* `truss_chains.RPCOptions` - -@@ -142,20 +139,14 @@ +@@ -147,20 +139,14 @@ Options to customize RPCs to dependency chainlets. @@ -166,19 +156,19 @@ -| `use_binary` | *bool* | Whether to send data in binary format. This can give a parsing speedup and message size reduction (~25%) for numpy arrays. Use `NumpyArrayField` as a field type on pydantic models for integration and set this option to `True`. For simple text data, there is no significant benefit. | - -#### retries *: int* +- +-#### timeout_sec *: int* +| Name | Type | Description | +|---------------|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `timeout_sec` | *int* | | +| `retries` | *int* | | +| `use_binary` | *bool* | Whether to send data in binary format. This can give a parsing speedup and message size reduction (~25%) for numpy arrays. Use `NumpyArrayField` as a field type on pydantic models for integration and set this option to `True`. For simple text data, there is no significant benefit. | --#### timeout_sec *: int* -- -#### use_binary *: bool* ### `truss_chains.mark_entrypoint` -@@ -167,23 +158,29 @@ +@@ -172,18 +158,23 @@ Example usage: @@ -206,13 +196,7 @@ # Remote Configuration - These data structures specify for each chainlet how it gets deployed remotely, e.g. dependencies and compute resources. - -+ - ### *class* `truss_chains.RemoteConfig` - - Bases: `pydantic.BaseModel` -@@ -192,7 +189,7 @@ +@@ -198,7 +189,7 @@ This is specified as a class variable for each chainlet class, e.g.: @@ -221,7 +205,7 @@ import truss_chains as chains -@@ -208,72 +205,39 @@ +@@ -214,34 +205,13 @@ **Parameters:** @@ -232,15 +216,8 @@ -| `assets` | *[Assets](#truss_chains.Assets* | | -| `name` | *str\|None* | | -| `options` | *[ChainletOptions](#truss_chains.ChainletOptions* | | -+| Name | Type | Description | -+|----------------|----------------------------------------------------------|-------------| -+| `docker_image` | *[DockerImage](#class-truss-chains-dockerimage)* | | -+| `compute` | *[Compute](#class-truss-chains-compute)* | | -+| `assets` | *[Assets](#class-truss-chains-assets)* | | -+| `name` | *str\|None* | | -+| `options` | *[ChainletOptions](#class-truss-chains-chainletoptions)* | | - - +- +- -#### assets *: [Assets](#truss_chains.Assets)* - -#### compute *: [Compute](#truss_chains.Compute)* @@ -260,10 +237,17 @@ -#### name *: str | None* - -#### options *: [ChainletOptions](#truss_chains.ChainletOptions)* -- - ### *class* `truss_chains.DockerImage` ++| Name | Type | Description | ++|----------------|----------------------------------------------------------|-------------| ++| `docker_image` | *[DockerImage](#class-truss-chains-dockerimage)* | | ++| `compute` | *[Compute](#class-truss-chains-compute)* | | ++| `assets` | *[Assets](#class-truss-chains-assets)* | | ++| `name` | *str\|None* | | ++| `options` | *[ChainletOptions](#class-truss-chains-chainletoptions)* | | + - Bases: `pydantic.BaseModel` + ### *class* `truss_chains.DockerImage` +@@ -250,37 +220,23 @@ Configures the docker image in which a remoted chainlet is deployed. @@ -289,15 +273,7 @@ -| `external_package_dirs` | *list[AbsPath]\|None* | A list of directories containing additional python packages outside the chain’s workspace dir, e.g. a shared library. This code is copied into the docker image and importable at runtime. | - -#### apt_requirements *: list[str]* -+| Name | Type | Description | -+|-------------------------|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -+| `base_image` | *[BasetenImage](#class-truss-chains-basetenimage)\|[CustomImage](#class-truss-chains-customimage)* | The base image used by the chainlet. Other dependencies and assets are included as additional layers on top of that image. You can choose a baseten default image for a supported python version (e.g. `BasetenImage.PY311`), this will also include GPU drivers if needed, or provide a custom image (e.g. `CustomImage(image="python:3.11-slim")`). | -+| `pip_requirements_file` | *AbsPath\|None* | Path to a file containing pip requirements. The file content is naively concatenated with `pip_requirements`. | -+| `pip_requirements` | *list[str]* | A list of pip requirements to install. The items are naively concatenated with the content of the `pip_requirements_file`. | -+| `apt_requirements` | *list[str]* | A list of apt requirements to install. | -+| `data_dir` | *AbsPath\|None* | Data from this directory is copied into the docker image and accessible to the remote chainlet at runtime. | -+| `external_package_dirs` | *list[AbsPath]\|None* | A list of directories containing additional python packages outside the chain’s workspace dir, e.g. a shared library. This code is copied into the docker image and importable at runtime. | - +- -#### base_image *: [BasetenImage](#truss_chains.BasetenImage) | [CustomImage](#truss_chains.CustomImage)* - -#### data_dir *: AbsPath | None* @@ -309,27 +285,35 @@ -#### pip_requirements *: list[str]* - -#### pip_requirements_file *: AbsPath | None* ++| Name | Type | Description | ++|-------------------------|----------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ++| `base_image` | *[BasetenImage](#class-truss-chains-basetenimage)\|[CustomImage](#class-truss-chains-customimage)* | The base image used by the chainlet. Other dependencies and assets are included as additional layers on top of that image. You can choose a baseten default image for a supported python version (e.g. `BasetenImage.PY311`), this will also include GPU drivers if needed, or provide a custom image (e.g. `CustomImage(image="python:3.11-slim")`). | ++| `pip_requirements_file` | *AbsPath\|None* | Path to a file containing pip requirements. The file content is naively concatenated with `pip_requirements`. | ++| `pip_requirements` | *list[str]* | A list of pip requirements to install. The items are naively concatenated with the content of the `pip_requirements_file`. | ++| `apt_requirements` | *list[str]* | A list of apt requirements to install. | ++| `data_dir` | *AbsPath\|None* | Data from this directory is copied into the docker image and accessible to the remote chainlet at runtime. | ++| `external_package_dirs` | *list[AbsPath]\|None* | A list of directories containing additional python packages outside the chain’s workspace dir, e.g. a shared library. This code is copied into the docker image and importable at runtime. | - ### *class* `truss_chains.BasetenImage` -@@ -282,11 +246,12 @@ + ### *class* `truss_chains.BasetenImage` +@@ -290,11 +246,11 @@ Default images, curated by baseten, for different python versions. If a Chainlet uses GPUs, drivers will be included in the image. -#### PY310 *= 'py310'* - -#### PY311 *= 'py311'* +- +-#### PY39 *= 'py39'* +| Enum Member | Value | +|-------------|---------| +| `PY310` | *py310* | +| `PY311 ` | *py311* | +| `PY39` | *py39* | --#### PY39 *= 'py39'* ### *class* `truss_chains.CustomImage` - -@@ -296,42 +261,36 @@ +@@ -305,43 +261,36 @@ **Parameters:** @@ -338,6 +322,13 @@ -| `image` | *str* | | -| `python_executable_path` | *str\|None* | | -| `docker_auth` | *DockerAuthSettings\|None* | | +- +- +-#### docker_auth *: DockerAuthSettings | None* +- +-#### image *: str* +- +-#### python_executable_path *: str | None* +| Name | Type | Description | +|--------------------------|----------------------------|----------------------------------------------------------------------------------------------------------| +| `image` | *str* | Reference to image on dockerhub. | @@ -345,12 +336,6 @@ +| `docker_auth` | *DockerAuthSettings\|None* | See [corresponding truss config](https://docs.baseten.co/truss-reference/config#base-image-docker-auth). | --#### docker_auth *: DockerAuthSettings | None* -- --#### image *: str* -- --#### python_executable_path *: str | None* -- ### *class* `truss_chains.Compute` Specifies which compute resources a chainlet has in the *remote* deployment. @@ -388,7 +373,7 @@ It is important to understand the difference between predict_concurrency and the concurrency target (used for autoscaling, i.e. adding or removing replicas). Furthermore, the `predict_concurrency` of a single instance is implemented in -@@ -342,10 +301,6 @@ +@@ -352,11 +301,6 @@ - With a threadpool if it’s a synchronous function. This requires that the threads don’t have significant CPU load (due to the GIL). @@ -396,10 +381,11 @@ - -* **Return type:** - *ComputeSpec* +- ### *class* `truss_chains.Assets` -@@ -353,7 +308,7 @@ +@@ -364,7 +308,7 @@ For example, model weight caching can be used like this: @@ -408,7 +394,7 @@ import truss_chains as chains from truss.base import truss_config -@@ -367,32 +322,19 @@ +@@ -378,32 +322,19 @@ See [truss caching guide](https://docs.baseten.co/deploy/guides/model-cache#enabling-caching-for-a-model) for more details on caching. @@ -447,7 +433,7 @@ ### `truss_chains.push` Deploys a chain remotely (with all dependent chainlets). -@@ -400,25 +342,24 @@ +@@ -411,56 +342,38 @@ **Parameters:** @@ -478,14 +464,14 @@ - *BasetenChainService* + [*ChainService*](#class-truss-chains-remote-chainservice) --### *class* `truss_chains.deployment.deployment_client.ChainService` --Bases: `ABC` -+### *class* `truss_chains.deployment.deployment_client.ChainService` + ### *class* `truss_chains.deployment.deployment_client.ChainService` +-Bases: `ABC` +- Handle for a deployed chain. -@@ -426,29 +367,13 @@ + A `ChainService` is created and returned when using `push`. It bundles the individual services for each chainlet in the chain, and provides utilities to query their status, invoke the entrypoint etc. @@ -518,7 +504,7 @@ * **Return type:** list[*DeployedChainlet*] -@@ -458,21 +383,27 @@ +@@ -470,21 +383,27 @@ Invokes the entrypoint with JSON data. @@ -550,7 +536,7 @@ ### `truss_chains.make_abs_path_here` Helper to specify file paths relative to the *immediately calling* module. -@@ -491,12 +422,12 @@ +@@ -503,12 +422,12 @@ You can now in `root/sub_package/chainlet.py` point to the requirements file like this: @@ -565,7 +551,7 @@ This helper uses the directory of the immediately calling module as an absolute reference point for resolving the file location. Therefore, you MUST NOT wrap the instantiation of `make_abs_path_here` into a -@@ -504,7 +435,7 @@ +@@ -516,7 +435,7 @@ Ok: @@ -574,7 +560,7 @@ def foo(path: AbsPath): abs_path = path.abs_path -@@ -514,7 +445,7 @@ +@@ -526,7 +445,7 @@ Not Ok: @@ -583,7 +569,7 @@ def foo(path: str): dangerous_value = make_abs_path_here(path).abs_path -@@ -522,33 +453,41 @@ +@@ -534,33 +453,41 @@ foo("./somewhere") ``` @@ -635,7 +621,7 @@ import os import truss_chains as chains -@@ -575,24 +514,27 @@ +@@ -587,7 +514,8 @@ print(result) ``` @@ -644,23 +630,25 @@ +[local debugging guide](https://docs.baseten.co/chains/guide#test-a-chain-locally) for more details. -+ - ### *class* `truss_chains.DeployedServiceDescriptor` + +@@ -595,17 +523,17 @@ Bases: `ServiceDescriptor` -**Parameters:** -+Bundles values to establish an RPC session to a dependency chainlet, -+specifically with `StubBase`. - +- -| Name | Type | Description | -|------|------|-------------| -| `name` | *str* | | -| `display_name` | *str* | | -| `options` | *[RPCOptions](#truss_chains.RPCOptions* | | -| `predict_url` | *str* | | ++Bundles values to establish an RPC session to a dependency chainlet, ++specifically with `StubBase`. + +**Parameters:** +-#### predict_url *: str* +| Name | Type | Description | +|---------------|------------------------------------------------|-------------| +| `name` | *str* | | @@ -668,11 +656,9 @@ +| `options` | *[RPCOptions](#class-truss-chains-rpcoptions)* | | +| `predict_url` | *str* | | --#### predict_url *: str* ### *class* `truss_chains.StubBase` - -@@ -607,10 +549,11 @@ +@@ -621,7 +549,7 @@ in user-code for wrapping a deployed truss model into the Chains framework. It flexibly supports JSON and pydantic inputs and output. Example usage: @@ -681,13 +667,11 @@ import pydantic import truss_chains as chains -+ - class WhisperOutput(pydantic.BaseModel): - ... +@@ -631,19 +559,20 @@ -@@ -618,18 +561,18 @@ - class DeployedWhisper(chains.StubBase): + class DeployedWhisper(chains.StubBase): ++ # Input JSON, output JSON. - async def run_remote(self, audio_b64: str) -> Any: + async def run_remote(self, audio_b64: str) -> Any: @@ -707,7 +691,7 @@ return await self.predict_async(data, output_model=WhisperOutput) -@@ -650,40 +593,38 @@ +@@ -664,40 +593,37 @@ **Parameters:** @@ -755,17 +739,16 @@ -* **Return type:** - *AsyncIterator*[bytes] +#### predict_sync(inputs: PydanticModel, output_model: Type[PydanticModel]) → PydanticModel -+ -+#### predict_sync(inputs: JSON, output_model: Type[PydanticModel]) → PydanticModel -#### predict_sync(inputs: InputT, output_model: Type[OutputModelT]) → OutputModelT -+#### predict_sync(inputs: JSON) → JSON ++#### predict_sync(inputs: JSON, output_model: Type[PydanticModel]) → PydanticModel -#### predict_sync(inputs: InputT, output_model: None = None) → Any ++#### predict_sync(inputs: JSON) → JSON - ### *class* `truss_chains.RemoteErrorDetail` -@@ -695,19 +636,12 @@ + ### *class* `truss_chains.RemoteErrorDetail` +@@ -710,19 +636,12 @@ **Parameters:** diff --git a/truss-chains/truss_chains/definitions.py b/truss-chains/truss_chains/definitions.py index 0a9e5612c..c9e051161 100644 --- a/truss-chains/truss_chains/definitions.py +++ b/truss-chains/truss_chains/definitions.py @@ -451,7 +451,7 @@ class DeploymentContext(SafeModelNonSerializable): data_dir: The directory where the chainlet can store and access data, e.g. for downloading model weights. chainlet_to_service: A mapping from chainlet names to service descriptors. - This is used create RPCs sessions to dependency chainlets. It contains only + This is used to create RPC sessions to dependency chainlets. It contains only the chainlet services that are dependencies of the current chainlet. secrets: A mapping from secret names to secret values. It contains only the secrets that are listed in ``remote_config.assets.secret_keys`` of the