Chalk home page
Docs
API
CLI
  1. Resolvers
  2. Outputs

Resolvers declare the features that they resolve through a Python type annotation on the return value of the function.

Scalar output

Single output

To return a single feature from a resolver, set the return type annotation to the feature you want to resolve:

@online
def resolve(...) -> User.name:
    return "Jennifer Doudna"

Multiple outputs

To return multiple feature sets, return an instance of the feature class. In the type signature, specify the Features[...] class, parameterized by the features that you pass to the feature class.

from chalk.features import Features, ...

@online
def resolve(...) -> Features[User.name, User.employer]:
    return User(
        name="Jennifer Doudna",
        employer="University of California, Berkeley"
    )

You only need to pass a subset of the features to the constructor for the feature class.

The editor plugin will check that the type annotation you assign to the resolver matches subset of features passed to the constructor of the feature set.


DataFrame output

You can also output many instances of a feature set from a resolver by specifying a DataFrame as the return type of the function:

@offline
def get_events() -> DataFrame[Transfer.uuid, Transfer.amount, Transfer.ts]:
    return DataFrame.read_csv(...)

For more info on how to load batch data, see the Data Sources sections.