benchling_sdk.apps.config.framework module¶

class BenchlingConfigProvider¶

Bases: benchling_sdk.apps.config.framework.ConfigProvider

Benchling Config provider.

Provides a BenchlingAppConfiguration retrieved from Benchling’s API.

__init__(benchling: Benchling, app_id: str)¶

Initialize Benchling Config Provider.

Parameters
  • benchling – A Benchling instance.

  • app_id – The app_id from which to retrieve configuration.

config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Provide a Benchling app configuration from Benchling’s APIs.

class ConfigItemStore¶

Bases: object

Dependency Link Store.

Marshals an app configuration from the configuration provider into an indexed structure. Only retrieves app configuration once unless its cache is invalidated.

__init__(configuration_provider: ConfigProvider)¶

Initialize Dependency Link Store.

Parameters

configuration_provider – A ConfigProvider that will be invoked to provide the

underlying config from which to organize dependency links.

array_rows_to_dict(path: List[str]) → OrderedDict[str, Dict[str, ConfigItemWrapper]]¶

Given a path to the root of a config array, return each element as a named dict.

config_by_path(path: List[str]) → ConfigItemWrapper¶

Config by path.

Find an app config item by its exact path match, if it exists. Does not search partial paths.

config_keys_by_path(path: List[str]) → ordered_set.OrderedSet[str]¶

Config keys by path.

Find a set of app config keys at the specified path, if any. Does not return keys that are nested beyond the current level.

For instance, given paths: [“One”, “Two”] [“One”, “Two”, “Three”] [“One”, “Two”, “Four”] [“One”, “Two”, “Three”, “Five”] [“Zero”, “One”, “Two”, “Three”]

The expected return from this method when path=[“One”, “Two”] is a set {“Three”, “Four”}.

property configuration: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Get the underlying configuration.

Return the raw, stored configuration. Can be used if the provided accessors are inadequate to find particular configuration items.

property configuration_path_dict: Dict[Tuple[str, ...], ConfigItemWrapper]¶

Config links.

Return a dict of configuration item paths to their corresponding configuration items.

invalidate_cache() → None¶

Invalidate Cache.

Will force retrieval of configuration from the ConfigProvider the next time the link store is accessed.

class ConfigItemWrapper¶

Bases: object

Config Item Wrapper.

A decorator class for AppConfigItem to assist with typesafe access to its values. Access the item attribute for the original config item, if present.

__init__(item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]], path: List[str]) → None¶

Init Pathed Config Item.

item: Optional[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶
linked_resource() → Optional[LinkedAppConfigResourceSummary]¶

Return an optional LinkedAppConfigResourceSummary.

Raises exceptions if the config item is not of the type that supports linked resources, or the linked resource is inaccessible.

path: List[str]¶
required() → RequiredConfigItemWrapper¶

Return a RequiredPathedConfigItem to enforce that config item is not optional.

value() → Optional[Union[str, float, int, bool]]¶

Return the value of the config item, if present.

value_str() → Optional[str]¶

Return the value of the config item as a string, if present.

class ConfigProvider¶

Bases: Protocol

Config provider.

Provides a list of ConfigurationReference.

__init__(*args, **kwargs)¶
config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Implement to provide a list of configuration items, for instance from Benchling APIs.

class RequiredConfigItemWrapper¶

Bases: benchling_sdk.apps.config.framework.ConfigItemWrapper

Required Config Item Wrapper.

A decorator class for AppConfigItem to assist with typesafe access to its values. Enforces that a config item is present, and that it’s value is not None. Access the item attribute for the original config item.

__init__(item: Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem], path: List[str]) → None¶

Init Required Pathed Config Item.

item: Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]¶
linked_resource() → LinkedAppConfigResourceSummary¶

Return a LinkedAppConfigResourceSummary.

Raises exceptions if the config item is not of the type that supports linked resources, or the linked resource is inaccessible.

value() → Union[str, float, int, bool]¶

Return the value of the config item.

value_str() → str¶

Return the value of the config item as a string.

class StaticConfigProvider¶

Bases: benchling_sdk.apps.config.framework.ConfigProvider

Static Config provider.

Provides a BenchlingAppConfiguration from a static declaration. Useful for mocking or testing.

__init__(configuration_items: List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]])¶

Initialize Static Config Provider.

Parameters

configuration_items – The configuration items to return.

config() → List[Union[ArrayElementAppConfigItem, DateAppConfigItem, DatetimeAppConfigItem, JsonAppConfigItem, EntitySchemaAppConfigItem, FieldAppConfigItem, BooleanAppConfigItem, IntegerAppConfigItem, FloatAppConfigItem, GenericApiIdentifiedAppConfigItem, SecureTextAppConfigItem, TextAppConfigItem]]¶

Provide Benchling app configuration items from a static reference.