Context#
- class sycamore.context.Context(exec_mode: ~sycamore.context.ExecMode = ExecMode.RAY, ray_args: dict[str, ~typing.Any] | None = None, rewrite_rules: list[~typing.Callable[[~sycamore.plan_nodes.Node], ~sycamore.plan_nodes.Node] | ~sycamore.plan_nodes.NodeTraverse] = <factory>, params: dict[str, ~typing.Any] = <factory>)[source]#
A class to implement a Sycamore Context, which initializes a Ray Worker and provides the ability to read data into a DocSet
- ray_args: dict[str, Any] | None = None#
Allows for the registration of Rules in the Sycamore Context that allow for transforming the nodes before execution. These rules can optimize ray execution or perform other manipulations.
- rewrite_rules: list[Callable[[Node], Node] | NodeTraverse]#
Define parameters for global usage
- class sycamore.context.ExecMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
- class sycamore.context.OperationTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
- sycamore.context.context_params(*names)[source]#
Applies kwargs from the context to a function call. Requires 'context': Context, to be an argument to the method.
There is a fair bit of complexity regarding arg management but the comments should be clear.
- sycamore.context.get_val_from_context(context: Context, val_key: str, param_names: List[str] | None = None, ignore_default: bool = False) Any | None [source]#
Helper function: Given a Context object, return the possible value for a given val. This assumes context.params is not a nested dict. @param context: Context to use @param val_key: Key for the value to be returned @param param_names: List of parameter namespaces to look for.
Always uses OperationTypes.DEFAULT unless configured otherwise.
@param ignore_default: disable usage for OperationTypes.DEFAULT parameter namespace @return: Optional value given configs.