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.123.0.tar.gz (1.6 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.123.0-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.0-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.123.0-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.123.0-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.123.0-cp313-cp313-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.123.0-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.0-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.123.0-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.123.0-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.123.0-cp312-cp312-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.123.0-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.123.0-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.123.0-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.123.0-cp311-cp311-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.123.0-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.123.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.123.0-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.0-cp310-cp310-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.123.0.tar.gz
Algorithm Hash digest
SHA256 08a9d3226a4fc15dd225d61f1a7518c56098108e89610fee14e3c41ac9b5ef7a
MD5 ea6a63c8025194344e64d6944263db19
BLAKE2b-256 2e39578eeb5106144de64f3fbf821643e80881de18dd374918b4c6468f30c65f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0cbec6be2909451da09895d73382ac150e30211b79c99fe9d597dc086ef8197c
MD5 445996e38270b22a97c835caf8924799
BLAKE2b-256 c4084be355babd931ca465a37ac45e039d616bcbdb8bd9952fb240b135e1281a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd5573fc7dbee4dbd222c06f1b56ea04df4dedbece21024bf428c7482d32bb81
MD5 a93cedb6ed979234f298d9655fe74671
BLAKE2b-256 22dd1895501899483004534b0525f09b54ab23d2c3fb30117fc0b63eb0be8b00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8d31e21f2f8a426b59a8a646dab314ea396cfeb11bb88c87ee4e65c62f0e4617
MD5 60e35da9bfe44bf2c77cca574bf0e730
BLAKE2b-256 1755c09653d3c8c8ecbd99bc8e95df45d5cb2b90c90e9fc956a08bff46bb6b6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a0fe6a1fc93b5bee1ae5517c80a13dfdcd3c215fc70f0395bbe31391d9e7760
MD5 748e6085acb5fa9ee724f50ed1a1b1af
BLAKE2b-256 e9f27e8e96cd471a3cee74cb38101be71000138472ceff4d4dcdfdae5bc5fe74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b9fc50823fa83079ef7f1fcfc0d68de3221e787f78324be64c6204ce8f4da7d7
MD5 a3c1f469842b3dbe45ab66b603bb95be
BLAKE2b-256 7ab9289ce524d3856bc5e394cd7ec9778483ad6a32d5b6bd18dbf4c64f992490

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 80b5ec50d37da5167f7681a32b7a382742053a284636d99ca4c522dba3d8170c
MD5 b062ddeae83afed98139d3ce6bb22e92
BLAKE2b-256 4ddc375e2c2ff88c344c402777ce6d4250325526d192269a5c2827c30cc69f9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12a2b3957fa01cba31ff04a5c1bd69b26b75744b30ea31b3aa8496d359da5d90
MD5 cee5bc3965638de25b87a702568fc0eb
BLAKE2b-256 3eeac40fdc8f3c1113743f87496a9093140a3a8d4eb1ddc9f316af11d69e5fd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 106a83e60f7c7c3cdb58e3998daef38b4a6e506168064ec5c1ec271b4cc1f2ad
MD5 d5c5fb8bd829caf534237856af4eac1c
BLAKE2b-256 742a65b864542b2749c7c0b88d25c2427c3efa61d99b4a113a3b5122e651f18a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7cdded9758e58ab3bd515bbab4fb7f2f3167c60754e3a92664492fa90d24edfb
MD5 1c846763b77f052e27e7d68f88d6a5bc
BLAKE2b-256 b785e6abc7ecc01b88ab31175d786c31b633f108bf6b0867f5b67a515b6d79dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 72584ef3d8cd3e307c59a9aaf4e67f7f2dc0cd0cbfaab1ad520e22794fc92502
MD5 a9a03615da0639695adb482def63d91f
BLAKE2b-256 48792e47c8e7f2e79f2b9a1a8a115d91e03ed8623bd85ccece97273cd8d4baed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f5d9e870e65ded07b2937b38abd5536729ff31eb481d23a382874eaad803a153
MD5 35da90f45be04977db07210770421a96
BLAKE2b-256 8877b82b601997b1177929ba8d4f9787ff96ecd1be621dac601c4cf89bfdf274

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b9bc26c96c941641649f9b3a6000bc255850bd5ebe3c22686139e7380f585d7c
MD5 9fc514135a1ed370ebb1629aae962644
BLAKE2b-256 33feb9c8d96706f4b82612d27d5b522d15aed14c56e8e59aa3fe0e1cfa2af74d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 390491d425398abfee3d2d5c63e74da26c5b6261d7963e6cef33e67b2fd87986
MD5 17db24e5a32479eb96eafad27ccaa6a7
BLAKE2b-256 6294dec0b8ed0d6a240bf9ea8654ebdbcfcdb5823bc82cdc72c9d66b0d0b7f6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 81b6dcf2982b891380fd3a892d9266716e66feb46e654ba385276d535acbf636
MD5 912d78c666dabd2f2bb6155af5e255c7
BLAKE2b-256 570c71c0ad41b04331e3589081728f33ddb9e83a673e638fd2bad72ac2df86d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9f0b5649c8d8f5413e02bdbfcc4f67f7a4f96e1bcde6b5da6d180e6febc93578
MD5 67b4f0624ac5b09860b346d9392ec960
BLAKE2b-256 9237c6289fc7af524e90cc065dfd8b3c0866e58cc72c60bcd19271986dab52d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3e080e91c170a2dc2eb82049e4b3e68c6e83cc5fbb6fb48bded3e52381b2c2b0
MD5 dc90ae2c33ef95598629dda96a8c8d20
BLAKE2b-256 8453be2d57de55605364fdc5065291f04be902b57ea62ace7d5bc8f415be01f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2bf0629ea9f5e9a7bbacf51083a5247f6195118729053b89d7250342795fbc67
MD5 52b21045792b764d92d769c88fadc0d8
BLAKE2b-256 1b061c5c61d8cab0842736172d55115d61dd8159e5ea50ed28f8a22adf9d7826

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cf1ba3bfacb6c6fd4c030d669f06957eb9397faf2601b44ac7f966aecb8b7f18
MD5 d80538b3b58bcda03e2915bcfcc4c359
BLAKE2b-256 c5a55e7fa0aeedf72f5c4051e1ca6c81cd178888fc12c85464d069366bda1de5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6aa5ee3938cccc96b3a6d4769727eea1f9ced29b9f91c9690a394a342d562e8f
MD5 b6afab8b76304ce401b54d8778b79368
BLAKE2b-256 749d5874910032d5dd00d37d7d80578b1062a93297c468c83bfa5f3beaeaf8f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3a3e47ee4a89ee40f932a1581a6ca90b72b75aed2c28e8b3fefd94d755a1e2f2
MD5 5d1200889132f1966471d1011e026aa6
BLAKE2b-256 387af9b2d122b6a4324639d2effbd5299794b9716e7096e64771416eadb0ece3

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