Skip to content

Add ability to "inject"options from the results of other Evaluatables #40

@austinwarner-8451

Description

@austinwarner-8451

There are times when you want to dynamically generate the value of an option using a dataset or other Evaluatable object. This is most often useful when using a dataset that someone else wrote.

Currently, a similar ability exists in the Map type, but only when iterating over the result of an Evaluatable that returns an interable.

The most natural way to do this would probably be to extend the WithOptions type (which powers the Dataset.with_options method) so that you can provide dynamic options as well as static ones. For example

from labrea import dataset, Option


@dataset
def foo(bar: str = Option("BAR")) -> str:
    return bar


@dataset
def bar(msg: str = Option("MSG")) -> str:
    return msg


foo.with_options({"BAR": bar}).evaluate({"MSG": "Hello World!"})
#  'Hello World!'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions