Skip to main content

Python SDK for Chalk

Project description

Chalk

Chalk enables innovative machine learning teams to focus on building the unique products and models that make their business stand out. Behind the scenes Chalk seamlessly handles data infrastructure with a best-in-class developer experience. Here’s how it works –


Develop

Chalk makes it simple to develop feature pipelines for machine learning. Define Python functions using the libraries and tools you're familiar with instead of specialized DSLs. Chalk then orchestrates your functions into pipelines that execute in parallel on a Rust-based engine and coordinates the infrastructure required to compute features.

Features

To get started, define your features with Pydantic-inspired Python classes. You can define schemas, specify relationships, and add metadata to help your team share and re-use work.

@features
class User:
    id: int
    full_name: str
    nickname: Optional[str]
    email: Optional[str]
    birthday: date
    credit_score: float
    datawarehouse_feature: float

    transactions: DataFrame[Transaction] = has_many(lambda: Transaction.user_id == User.id)

Resolvers

Next, tell Chalk how to compute your features. Chalk ingests data from your existing data stores, and lets you use Python to compute features with feature resolvers. Feature resolvers are declared with the decorators @online and @offline, and can depend on the outputs of other feature resolvers.

Resolvers make it easy to rapidly integrate a wide variety of data sources, join them together, and use them in your model.

SQL

pg = PostgreSQLSource()

@online
def get_user(uid: User.id) -> Features[User.full_name, User.email]:
    return pg.query_string(
        "select email, full_name from users where id=:id",
        args=dict(id=uid)
    ).one()

REST

import requests

@online
def get_socure_score(uid: User.id) -> Features[User.socure_score]:
    return (
        requests.get("https://api.socure.com", json={
            id: uid
        }).json()['socure_score']
    )

Execute

Once you've defined your features and resolvers, Chalk orchestrates them into flexible pipelines that make training and executing models easy.

Chalk has built-in support for feature engineering workflows -- no need to manage Airflow or orchestrate complicated streaming flows. You can execute resolver pipelines with declarative caching, ingest batch data on a schedule, and easily make slow sources available online for low-latency serving.

Caching

Many data sources (like vendor APIs) are too slow for online use cases and/or charge a high dollar cost-per-call. Chalk lets you optimize latency and cost by defining declarative caching policies which are well-integrated throughout the system. You no longer have to manage Redis, Memcached, DynamodDB, or spend time tuning cache-warming pipelines.

Add a caching policy with one line of code in your feature definition:

@features
class ExternalBankAccount:
-   balance: int
+   balance: int = feature(max_staleness="**1d**")

Optionally warm feature caches by executing resolvers on a schedule:

@online(cron="**1d**")
def fn(id: User.id) -> User.credit_score:
  return redshift.query(...).all()

Or override staleness tolerances at query time when you need fresher data for your models:

chalk.query(
    ...,
    outputs=[User.fraud_score],
    max_staleness={User.fraud_score: "1m"}
)

Batch ETL ingestion

Chalk also makes it simple to generate training sets from data warehouse sources -- join data from services like S3, Redshift, BQ, Snowflake (or other custom sources) with historical features computed online. Specify a cron schedule on an @offline resolver and Chalk automatically ingests data with support for incremental reads:

@offline(cron="**1h**")
def fn() -> Feature[User.id, User.datawarehouse_feature]:
  return redshift.query(...).incremental()

Chalk makes this data available for point-in-time-correct dataset generation for data science use-cases. Every pipeline has built-in monitoring and alerting to ensure data quality and timeliness.

Reverse ETL

When your model needs to use features that are canonically stored in a high-latency data source (like a data warehouse), Chalk's Reverse ETL support makes it simple to bring those features online and serve them quickly.

Add a single line of code to an offline resolver, and Chalk constructs a managed reverse ETL pipeline for that data source:

@offline(offline_to_online_etl="5m")

Now data from slow offline data sources is automatically available for low-latency online serving.


Deploy + query

Once you've defined your pipelines, you can rapidly deploy them to production with Chalk's CLI:

chalk apply

This creates a deployment of your project, which is served at a unique preview URL. You can promote this deployment to production, or perform QA workflows on your preview environment to make sure that your Chalk deployment performs as expected.

Once you promote your deployment to production, Chalk makes features available for low-latency online inference and offline training. Significantly, Chalk uses the exact same source code to serve temporally-consistent training sets to data scientists and live feature values to models. This re-use ensures that feature values from online and offline contexts match and dramatically cuts development time.

Online inference

Chalk's online store & feature computation engine make it easy to query features with ultra low-latency, so you can use your feature pipelines to serve online inference use-cases.

Integrating Chalk with your production application takes minutes via Chalk's simple REST API:

result = ChalkClient().query(
    input={
        User.name: "Katherine Johnson"
    },
    output=[User.fico_score],
    staleness={User.fico_score: "10m"},
)
result.get_feature_value(User.fico_score)

Features computed to serve online requests are also replicated to Chalk's offline store for historical performance tracking and training set generation.

Offline training

Data scientists can use Chalk's Jupyter integration to create datasets and train models. Datasets are stored and tracked so that they can be re-used by other modelers, and so that model provenance is tracked for audit and reproducibility.

X = ChalkClient.offline_query(
    input=labels[[User.uid, timestamp]],
    output=[
        User.returned_transactions_last_60,
        User.user_account_name_match_score,
        User.socure_score,
        User.identity.has_verified_phone,
        User.identity.is_voip_phone,
        User.identity.account_age_days,
        User.identity.email_age,
    ],
)

Chalk datasets are always "temporally consistent." This means that you can provide labels with different past timestamps and get historical features that represent what your application would have retrieved online at those past times. Temporal consistency ensures that your model training doesn't mix "future" and "past" data.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chalkpy-2.115.5.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chalkpy-2.115.5-cp313-cp313-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.115.5-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.115.5-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.115.5-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.115.5-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.115.5-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.115.5-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.115.5-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.115.5-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.115.5-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.115.5-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.115.5-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.115.5-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.115.5-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.115.5-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.115.5-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.115.5-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.115.5-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.115.5-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.115.5-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.115.5.tar.gz.

File metadata

  • Download URL: chalkpy-2.115.5.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.5.tar.gz
Algorithm Hash digest
SHA256 6264660def5978b08ce1f9f6ea00b9783bea03a47734802c800876395239c169
MD5 149ef708c6ee22f5a8b306b72043ba91
BLAKE2b-256 cedfae19eefcf2f37f429a981f473984002c73bd4922c0b246e64f1d3e76ee29

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: chalkpy-2.115.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a44f92ddcca48fa451b0ce801179bc5f3a63e0a2bf2c1069a5578140cfaf5b88
MD5 917e16204dd435bd84df5811cc3efe96
BLAKE2b-256 088e53ff9dddbd012e13c15d001ac186b2dd483cff40a16b6acf65dc9e9e8862

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 509c950022f1da391dd029c1420f3721133a23901c58b50b39e6a34905eb4931
MD5 9fd3192eaae24c10ad3240237645e738
BLAKE2b-256 b9e3aefbc8d21c2f1dd32fe3f0053e945480b04d14cd06103df6013589855b1d

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0e0bf06cf803cdf0ac2c7d8cb07a6fe4cb00ac1d804144f80ddfc768eb9bd538
MD5 a7a78d9272ff36fd6909c77d4efda74a
BLAKE2b-256 3a9b073086bf6406ec4df5f6f607543b3dcd80dcef95b61a47b36b0be8a6780b

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06b20d0714e8af39a6e164fc3c86895a7cf570428f305a87208ee3eb0407bdf7
MD5 ea0dc6a5de5d091d910ecddca97ae04f
BLAKE2b-256 141849d183d5d8284d49d19c80d72dd08d6af04fab923e9339859812cfecde8f

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5aec5d2e0a09beb7f1867c8804883ec7311839021ff8298ee89f8f45a37e73e3
MD5 4205c2dd3c1acda204aa6a8f7220c801
BLAKE2b-256 8acaeb06c6981d63b20a554f90bda3fab345eae4f8fe7da5936cbe74c8d431ab

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: chalkpy-2.115.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f2f2267dcee66b8fe90dc69d9e75130850a3c36ba588595265121711e70dd0fd
MD5 2e95322f2710c8be7d93caa5da8c1f0e
BLAKE2b-256 accf46a3edcccc1eaac610005cd5208ba0f81784da23a9ef3e5003e462c14d36

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78d4e3d11d703f33243dd4cb81a53fcd8aaeff91dca91c51a077c635e94ae444
MD5 7e6feba48ae9e818b967b09ead515d9c
BLAKE2b-256 ef4b064b57f6619a1ddc86f41997e22103a46bd28ff560db8218332b3398f343

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 289665a13b858997d6493b0700f4e072f429d84ce55a5c900795cf48e327517e
MD5 a6faf4610aeb922226b5847bce7260dc
BLAKE2b-256 691f28d91e5aad230a88ede941836f6930931175ac27b59663c7808835cd4e31

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26ecf14dd0c9d30af8ea3c34ca5ee626a508296ce32be226b0bb313b725af784
MD5 603021a234d98325a99c27ccea790e49
BLAKE2b-256 c3dc5010016cc68fae59ec55c88582a8057627b6ff9f2c543bbc169c4e1152e4

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 99df2a102f06bfa83ff35a37b3a30d818e886d3507d40799979ae2431533b904
MD5 7302db30a19cd1ca52a3cbf57abfc58a
BLAKE2b-256 72fea28af79f3217798135712bda4168c63b768ab35052f767a88fc9443e4129

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: chalkpy-2.115.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 68fca165547fcce6de4d85ce8c16e0a5aefe3aa26a2f0f9683c20ae2f5d77d4f
MD5 2632e5f892ca3672c1b68bd7d085db94
BLAKE2b-256 f2c783a33ae494b4a6a1f710bfb4cee3c12933b8e53a2f6837d6a1eb73f10d63

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d07c7348ae9f1ee617489c0c23bde53294bbd349981092bdae247ff290a9500
MD5 ca19704d7d26d3a309b8c76629c5cc29
BLAKE2b-256 b5eba3136ac3766cb6b91f73786787e7310ca8eccef6788325f40c93f9de2d5a

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f9fdf0d315a859dd5217252187f775bbdb77c34cfacdc1636e8a3069a8c760a
MD5 622bc14c5788e9ff8d1079601408716a
BLAKE2b-256 aeaae4857a25178cb45dd452c875480a3ea71e2df79e454b826317c0856c3160

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d164fd47868a5ee06defb99f36ce04ae1671fb7033d725576bb5544b9c6b4b38
MD5 9b7b4aec9bcd34e7a5f27f94fff3dd00
BLAKE2b-256 6a2d05ca42df25712cc9b56cbd1e667837a8594f318484f1d67b8c628ac50f5e

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8c800fe1072c197a462835c5a9271f6eed0859879ef1727500e737fad464c3dc
MD5 185bf6d7d29bb3ac90ba6339926ebfc8
BLAKE2b-256 3280ba4c2d3210d478edea9ef8b64cfeb26ad29508f0d37d30ae5097848e0391

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: chalkpy-2.115.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6a198612a67f6901ab444b75c0cfc26cfb1a1be675bd87877a485a4fb5c74f5c
MD5 ddc158df97c336508209bb2966041403
BLAKE2b-256 30397ffb9621eec08723e5a91efbc8c474252f76f168f64aa954df715520e20c

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c4a678449fbb9937040c32c514d1013caa555cfac3b2d26c60f8f6eeddf3c2de
MD5 4c4679a1585f024f10f9e358c771d62a
BLAKE2b-256 c758792bf1b62a767ea08738569df5ff0b1b31de2e97293fee258461763c8b48

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1cbfaa7eca79ad2cf2017248c807e1735ca01bb3f960c855afd6a26c83764fdb
MD5 67ffce8e2b9d8c0189fd8d8c01c5af61
BLAKE2b-256 d99e3828ca416428b181f525847e260d2ad3ce1baffdff7b0871a2196a16c31a

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 488f850fdf37f3dc6df9b0b18846cf4351cd5d185a2621b06bc7a9c170317ced
MD5 c8b152cdb668603651ee08eb66aaada7
BLAKE2b-256 033714e4bf18ba03dba5b0ed65fee1c574919a9c2d53321d36ac30023e968b85

See more details on using hashes here.

File details

Details for the file chalkpy-2.115.5-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.115.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e4f1366bbcfdfc8ec6a728f26007f235cd3f874860d6672d4f02d3c21b53cbf4
MD5 c067a48194f94d8adb7036260b6bbbc5
BLAKE2b-256 387e42c4829a056c7e37b07301fdf6469fdded63f04769efe2e3ce8e56e3d72d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page