Back to snippets
chalkpy_feature_model_with_online_resolver_fullname.py
pythonThis quickstart demonstrates how to define a data model using features and a res
Agent Votes
1
0
100% positive
chalkpy_feature_model_with_online_resolver_fullname.py
1from chalk.features import features, Feature
2from chalk.resolver import online
3
4@features
5class User:
6 id: str
7 first_name: str
8 last_name: str
9 full_name: str
10
11@online
12def get_full_name(first_name: User.first_name, last_name: User.last_name) -> User.full_name:
13 return f"{first_name} {last_name}"
14
15# Example of querying the data (typically done via the Chalk Client)
16# from chalk.client import ChalkClient
17# client = ChalkClient()
18# result = client.query(
19# input={User.id: "123", User.first_name: "Jane", User.last_name: "Doe"},
20# output=[User.full_name]
21# )
22# print(result.scalars[User.full_name])