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.111.3.tar.gz (1.3 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.111.3-cp313-cp313-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.111.3-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.111.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.111.3-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.111.3-cp313-cp313-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.111.3-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.111.3-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.111.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.111.3-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.111.3-cp312-cp312-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.111.3-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.111.3-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.111.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.111.3-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.111.3-cp311-cp311-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.111.3-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.111.3-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.111.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.111.3-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.111.3-cp310-cp310-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.111.3.tar.gz
Algorithm Hash digest
SHA256 c93d8d46f589542cf861bb097a7963648395cd292f76b516d02043533eda18c9
MD5 2710dc392fb429c87bed8aeb344bca40
BLAKE2b-256 40f6a817f81c329a62fe2fa42a38044e80349e24044fd64b62738423c21f6c98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 79451ffd4fcfadcb8796bfd36af873a953c377017d7ec88fa69be360394a7ca4
MD5 9837eed7d6505105adcd89bc482f3392
BLAKE2b-256 b70ef70bba16d1fb4b9f58eb5946d2d4cf9ec9d2e22ebb59ee63eb7e4d5ef908

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 375899e164922fbd213f8e01a4db251aea2a8add29bc6338cfd3d446c74a0020
MD5 6b1133ce2596a25d76559ba4c2a42fe9
BLAKE2b-256 430b01a831eb210c96d53726fc43224ff48cbd9f48c3220ea30cc850cc17bc15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b9767212f41df3c13008f46b4b062baf811d6ac1ddecfebbcec3ea220a1000e4
MD5 c5a4b4274ac4ce110a970355fac52ffe
BLAKE2b-256 3ea45651eac93c62324e426b8ee331a25a976f409b8d6b24765382f801539c05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f2da63d336ae333cf436a2a375b45dd0e174cc679940d1d08593005c7689021
MD5 3f8085acd77bed9fedff7f15c69b2b17
BLAKE2b-256 dfb8e372d6d0bd1dafe3fe9998c0bd9adda8d614a0a23a892bf1ee55f11e6483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 83b23a60a4fc5c83bde16073192355e28f7aee91b2ef83a9ab9db2149999cca6
MD5 741ecb88629770e3dc482be623e89a47
BLAKE2b-256 21fdb7087ff85e1a64fcaf5c7b1506e6364d0ec8ecc26e357fcfe7ea2cf97074

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a8b8421c2534f01d27592d458acb0489ba5645686367be26ad6f887982ed3127
MD5 3e4189e82a8869bdbf98dddaf6bbc51e
BLAKE2b-256 62fef6e1df99a206b9e9289f51e9e6da0093b6e9576d8b51c1aecd841e77e0e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 369d8368cb5550ff32f5632c3cee4dee689a89cf97bf76b91b488b8f90d4c30a
MD5 f1797097a999cf5363ef74e3318282b2
BLAKE2b-256 89de910102cae24782ee251b0864fb27d0bed30fac86505a86c1a058e3def358

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4cf6498bf896ae924efa42b36d03a19a2e66009e57080630476701e96da735ab
MD5 2972521586ea1debfeffbb90b97c868a
BLAKE2b-256 4a84500662f944fcdc734aec15bc63eba2b8eaa42e75b57dd48305cfe2589fd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 149efdf4b0768dc854aae095c57b840b300e2057774b2cbacae86ba302471ec8
MD5 9936572c34e4034afa6a7abdaf42c1c0
BLAKE2b-256 806041ba3d29d04a6d774df5143e2b04e69db595f6908c4d2075a387279bf634

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 34a2a4d2ce8b539b9768f6317bf667d90de15161737305db1112b7381525f39a
MD5 f1d39394022b45dfc05047c19751033a
BLAKE2b-256 f939b4342a4bcff7b3b728c707a6249e261ec81366adc9f44a7443318c2cb46a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b57428fd10638b729c57ae54b158f468b7377c680bb3fb479e68158d93040e81
MD5 24ac834d13538dfe56d99bc7ed3b02fc
BLAKE2b-256 9ac3573f07ffdf45c9bbd3318d140ee5b36e003bcb69cd587768b9bdfbce16f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 09b4ae765bf34f0f833a8e06546f76d2aa84d9bb4817f4a231a5603aeb7e5bdb
MD5 6da497359f919d5260e328ab5360677a
BLAKE2b-256 4ea83b62fd605c78bfdd5a416a9019874fffec630160253c4b1f7033e0daa2d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ba2cc6a99fda81270633da94638f5ff7befc0a75aa520396cbe509dec8b098bb
MD5 c991647dca8bb8e8fe32a7c5d2436156
BLAKE2b-256 59479dc24d78ab17007c96e2955f2456e47b78f1946b5b3febccb3fd5db64915

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2694528e4b120b10eea2a01883f45106130c034469c920a0b839f5248294d8d
MD5 3e7c67da99ad046a7b624b13eb5b0ee6
BLAKE2b-256 0c1f91e95a91e020a2ee5adf9cfb3e879a4dbfa739ae12b4f4680a3a0e5ceeda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1da26eceec22e8504fe809878409a197a0dfc2fa9c2eec79780ff51f91538a65
MD5 152eab03bc97a4d4b45939935d94fce2
BLAKE2b-256 71eb9f2e57fbee157d6edf44b68ba0e5d74652474a8d60cd2b68d84ff2736089

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a44e562f12c79b355417573f5b29903cfcaa2873a57b6731dfc0cbbc92b2c8ca
MD5 7c617f2cdb8fe3e4654b5688abbad543
BLAKE2b-256 eae1dcc8df231c15e4adb40f24cb7e9b9bf5a9f0a646e6113d981c8c554d5786

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 68de4b008aac5ef6b1a6f4f8050748f53ddb4b7ea3cdd2a394251648731af76f
MD5 e0fa00dc235331394693df473949aeb2
BLAKE2b-256 028fb1a771e4bab210334509e0ded5746fb1f7b285d966e12b9bb0cd2c1bc481

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2ccdb22e724256d9e55a90361a0acd4f870b9fa01fe85bd345128cc19d723841
MD5 87693ac162fad440e0d64dd625290ed0
BLAKE2b-256 20f70bd0393d7a9925f394bf6014412f27723732d71d6127edd877948fa09800

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e83a27d5f49dfeddb305b4c96ca7a446a9d0bd360c2dfe966e13262a6d465dc
MD5 69b5f6651991969a6279fe640a77e4df
BLAKE2b-256 7322c78976fe011b0d1ed727554f342237492344c199edc304c1ccd248b2ba74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b0295075ae190c0f13ec8a43f6367f63629e6aa51b29b327a74cd2a8bf4e3a52
MD5 7cfaafd12e9853de5d874aedf2a482ca
BLAKE2b-256 5b095f43eeb482d210c1de8e8e51735fe09c3ded7c23123ee2cac4ce22f722b6

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