tecton_client package

class tecton_client.TectonClient(url: str, api_key: str, default_workspace_name: str | None = None, client: Client = None)[source]

A lightweight http client for fetching features from Tecton in production applications.

For feature development and interacting with the rest of your Tecton deployment, use the Tecton SDK (pip install tecton) and not this client library.

Examples:

__init__(url: str, api_key: str, default_workspace_name: str | None = None, client: Client = None)[source]

Constructor for the client.

Parameters:
  • url – Base url for your tecton cluster. Ex: http://explore.tecton.ai

  • api_key – A Tecton API key that has read-access to the workspace(s) that this client will be retrieving from. See https://docs.tecton.ai/docs/ for how to create an api key.

  • default_workspace_name – The workspace from which the features will be retrieved. Can be overridden by individual calls to get_features.

  • client – An httpx.Client, allowing you to provide finer-grained customization on the request behavior, such as default timeout or connection settings. See https://www.python-httpx.org/ for more info.

get_feature_service_metadata(*, feature_service_name: str, workspace_name: str | None = None) GetFeatureServiceMetadataResponse[source]

Get metadata about a Feature Service.

Parameters:
  • feature_service_name – The name of the Feature Service to fetch metadata of.

  • workspace_name – Workspace name where feature_service is deployed. Overrides AsyncTectonClient.default_workspace_name.

get_features(*, feature_service_name: str, join_key_map: Dict[str, int | str | None] | None = None, request_context_map: Dict[str, Any] | None = None, metadata_options: MetadataOptions | None = None, workspace_name: str | None = None, request_options: RequestOptions | None = None, allow_partial_results: bool = False) GetFeaturesResponse[source]

Get feature values from a Feature Service.

Parameters:
  • feature_service_name – The name of the Feature Service to fetch features from.

  • join_key_map – The join keys (i.e. primary keys) for this Feature Service request.

  • request_context_map – The request context map (i.e. request data) for this Feature Service.

  • metadata_options – Options for including additional metadata as part of response. Useful for debugging, but may affect performance.

  • workspace_name – Workspace name where feature_service is deployed. Overrides AsyncTectonClient.default_workspace_name.

  • request_options – (Advanced) Request level options to control feature server caching behavior.

  • allow_partial_results – (Advanced) Whether incomplete results should be returned when the Online Feature Store size limit has been exceeded for this request. If this is not true, then the response will be an error in this case. This is an advanced option and should only be set after consulting with the Tecton team.

class tecton_client.AsyncTectonClient(url: str, api_key: str, default_workspace_name: str | None = None, client: AsyncClient | None = None)[source]

A lightweight http client for fetching features from Tecton in production applications.

For feature development and interacting with the rest of your Tecton deployment, use the Tecton SDK (pip install tecton) and not this client library.

Examples:

import asyncio
from tecton_client import AsyncTectonClient, MetadataOptions

async_client = AsyncTectonClient(
    url="http://explore.tecton.ai", api_key="my_key", default_workspace_name="prod"
)
asyncio.run(
    async_client.get_features(
        feature_service_name="fraud_detection_feature_service:v2",
        join_key_map={"user_id": "user_4407104885"},
        request_context_map={"amount": 500.00},
        metadata_options=MetadataOptions(include_data_types=True),
    )
)
__init__(url: str, api_key: str, default_workspace_name: str | None = None, client: AsyncClient | None = None)[source]

Constructor for the client.

Parameters:
  • url – Base url for your tecton cluster. Ex: http://explore.tecton.ai

  • api_key – A Tecton API key that has read-access to the workspace(s) that this client will be retrieving from. See https://docs.tecton.ai/docs/ for how to create an api key.

  • default_workspace_name – The workspace from which the features will be retrieved. Can be overridden by individual calls to get_features.

  • client – An httpx.Client, allowing you to provide finer-grained customization on the request behavior, such as default timeout or connection settings. See https://www.python-httpx.org/ for more info.

async get_feature_service_metadata(*, feature_service_name: str, workspace_name: str | None = None) GetFeatureServiceMetadataResponse[source]

Get metadata about a Feature Service.

Parameters:
  • feature_service_name – The name of the Feature Service to fetch metadata of.

  • workspace_name – Workspace name where feature_service is deployed. Overrides AsyncTectonClient.default_workspace_name.

async get_features(*, feature_service_name: str, join_key_map: Dict[str, int | str | None] | None = None, request_context_map: Dict[str, Any] | None = None, metadata_options: MetadataOptions | None = None, workspace_name: str | None = None, request_options: RequestOptions | None = None, allow_partial_results: bool = False) GetFeaturesResponse[source]

Get feature values from a Feature Service.

Parameters:
  • feature_service_name – The name of the Feature Service to fetch features from.

  • join_key_map – The join keys (i.e. primary keys) for this Feature Service request.

  • request_context_map – The request context map (i.e. request data) for this Feature Service.

  • metadata_options – Options for including additional metadata as part of response. Useful for debugging, but may affect performance.

  • workspace_name – Workspace name where feature_service is deployed. Overrides AsyncTectonClient.default_workspace_name.

  • request_options – (Advanced) Request level options to control feature server caching behavior.

  • allow_partial_results – (Advanced) Whether incomplete results should be returned when the Online Feature Store size limit has been exceeded for this request. If this is not true, then the response will be an error in this case. This is an advanced option and should only be set after consulting with the Tecton team.

class tecton_client.MetadataOptions(include_names: bool = True, include_data_types: bool = True, include_effective_times: bool = False, include_slo_info: bool = False, include_serving_status: bool = False, include_feature_descriptions: bool = False, include_feature_tags: bool = False)[source]

Passed into metadata_options on get_features, controls what metadata is returned as part of the response.

include_names

Include the name of each feature in the response

Type:

bool

include_data_types

Include the data type of each feature in the response

Type:

bool

include_effective_times

Include the effective times of the feature values in the response.

Type:

bool

include_slo_info

Include the SLO information as well as the Batch SLO Information in the response.

Type:

bool

include_serving_status

Include feature statuses in the response.

Type:

bool

include_feature_descriptions

Include user-defined feature descriptions in the response.

Type:

bool

include_feature_tags

Include user-defined feature tags in the response.

Type:

bool

__init__(include_names: bool = True, include_data_types: bool = True, include_effective_times: bool = False, include_slo_info: bool = False, include_serving_status: bool = False, include_feature_descriptions: bool = False, include_feature_tags: bool = False) None
class tecton_client.RequestOptions(read_from_cache: bool = True, write_to_cache: bool = True)[source]

Passed into request_options on get_features, request level options to control feature server behavior.

read_from_cache

Disable if you want to skip the cache and read from the online store. Defaults to True.

Type:

bool

write_to_cache

Disable if you want to skip writing to the cache. Defaults to True.

Type:

bool

__init__(read_from_cache: bool = True, write_to_cache: bool = True) None
class tecton_client.GetFeaturesResponse(result: GetFeaturesResult, metadata: Dict | None, slo_info: SLOInfo | None)[source]

Response from get_feature_service_metadata.

result

The raw data returned by the FeatureService; includes just the feature values. For a mapping of feature names to values, use get_features_dict()

Type:

tecton_client._internal.response_utils.GetFeaturesResult

metadata

Any metadata returned. Control what metadata is returned from service using metadata_options parameter of get_features.

Type:

Dict | None

slo_info

SLO and Serving time information. This is useful for debugging latency. Note: This will only be included if MetadataOption.include_slo_info is set to True in get_features(), otherwise it will be None.

Type:

tecton_client._internal.response_utils.SLOInfo | None

class tecton_client.GetFeatureServiceMetadataResponse(input_join_keys: List[dict] | None, input_request_context_keys: List[dict] | None, feature_values: List[dict])[source]

Response from get_feature_service_metadata.

input_join_keys

The expected fields to be passed in the joinKeyMap parameter.

Type:

List[dict] | None

input_request_context_keys

The expected fields to be passed in the requestContextMap parameter.

Type:

List[dict] | None

feature_values

The fields to be returned in the features list in GetFeaturesResponse or QueryFeaturesResponse. The order of returned features will match the order returned by GetFeaturesResponse or QueryFeaturesResponse.

Type:

List[dict]

exceptions

exception tecton_client.exceptions.BadRequestError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 400 Bad Request error.

exception tecton_client.exceptions.ForbiddenError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 403 Forbidden error.

exception tecton_client.exceptions.GatewayTimeoutError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 504 Gateway Timeout error.

exception tecton_client.exceptions.NotFoundError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 404 Not Found error.

exception tecton_client.exceptions.ResourceExhaustedError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 429 Resources Exhausted error.

exception tecton_client.exceptions.ServiceUnavailableError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 503 Service Unavailable error.

exception tecton_client.exceptions.TectonHttpException(status_code: int, reason_phrase: str, message: str)[source]

Bases: Exception

Base class for exceptions raised when the Tecton API returns an error response.

exception tecton_client.exceptions.UnauthorizedError(status_code: int, reason_phrase: str, message: str)[source]

Bases: TectonHttpException

Raised when the Tecton API returns a 401 Unauthorized error.