-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3_downstream_scalars.py
43 lines (34 loc) · 1.01 KB
/
3_downstream_scalars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from chalk import online
from chalk.client import ChalkClient
from chalk.features import features
@features
class User:
id: int
email: str
email_domain: str
banned_email: bool
@online
def get_email_domain(email: User.email) -> User.email_domain:
return email.split("@")[1].lower()
@online
def is_banned_email(domain: User.email_domain) -> User.banned_email:
return domain in {
"pergi.id",
"convoitucpa.com",
"vshgl.com",
"nieise.com",
"bookue.site",
"umaasa.com",
}
if __name__ == "__main__":
client = ChalkClient()
assert not client.query(
input={User.email: "katherine.johnson@nasa.gov"},
# Requesting User.banned_email requires running
# `get_email_domain` and then `is_banned_email`
output=[User.banned_email],
).get_feature_value(User.banned_email)
assert client.query(
input={User.email: "attacker@vshgl.com"},
output=[User.banned_email],
).get_feature_value(User.banned_email)