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.118.4.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.118.4-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.118.4-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.118.4.tar.gz.

File metadata

  • Download URL: chalkpy-2.118.4.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.118.4.tar.gz
Algorithm Hash digest
SHA256 4c9de1c2762b94af8b82e8c87eb359209a021f46041974dd577fe2937ebc07c3
MD5 fd72174ecf890640cc2c40f90df5e088
BLAKE2b-256 6b2d4a38a0a54873f076acd02f7266fd931244872c4e96c807c453b425bd2b45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.4-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.118.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f31debcc2383524593276c3831512919f7faf8034272767bbf99525628572fb0
MD5 f4eac6502a54668f78cf0adbe7819a06
BLAKE2b-256 1672a240ba5ba3b5e2db1688686815b6815887e6eb64f8ad0050b06ace6a8b8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f73d50085a7619df2516428d4beac650ba5ed0f7b8b26a6fda0322fdd1e0d1c9
MD5 cd1fe9c1783e60c18f8b8ed8a1f6a51b
BLAKE2b-256 0fefadca38a1cb150041cab2140fc964f546793e6329b047b97def1b5119f798

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f51be396d745d735195cb1070088b280a7cd8089667bf866262e413a8378e1b1
MD5 2b3f9d985c50204ef9f85c47a937123b
BLAKE2b-256 6eb461c17998e7883ceb73c7f151495b17368a5ac6449837dd937505022be69b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1f7bc87b64ea38fa2bcaaf01919d264d739be8d9e7bc11743e9fbe9bc6149e7
MD5 dada03b317c2a67d960d460a002cda60
BLAKE2b-256 9fb14791824c19899635d775301ec0a2d018619ecb526167d8a1e1a77d3061fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 55d4e493029adbf28b6907321e6c44eb105ddca7a46673658c506b3d048f8b52
MD5 dc3cb5dc1ca932d4e1951d32432dd91f
BLAKE2b-256 d8ee43aea18f948b947f18bda6ca3f3fa5ef164c7a31e5d5c5b6fcc5a3ff9698

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.4-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.118.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 400e1df362460a3b6646e389032eeeccf66053ba8482530a390534e80458bf9f
MD5 0221fbacf4d1153e52dcf20d07b3b903
BLAKE2b-256 7eed5b8281cb9174c88753b5d7caf7b41e44c6aec1e749f70940f729f18e9253

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b8db74b30d8d02fb36dbacfd05b16e429f3fe523816fc8322963ed324327bfd1
MD5 cc565669a440a1c470cf8ba4c0ec69be
BLAKE2b-256 6921e6cb4576a366c99f93413945c4cb58014ff5ba3419cc714f9ae2005aaaeb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e46dc710b68012670b7c83a4b283cde05dd5344a4f3495d381f301e9d307bd82
MD5 0373192c7251dc2d03edababedaa6d23
BLAKE2b-256 8f1f0a08bf028279e6aa299a3625c87dba9b7afd4bcf45c8ba3c37e75b875d82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b160b31baa46087ce15953d3cf1b38a27c248e6a292ca0986245ec4ffa1e7783
MD5 c513a8426eab1c0b181cd9fd0da23962
BLAKE2b-256 c88a83e9cfe7a3d8a08552e5e60f8ca2bea3a0ea73e932d273e5ac9c28967cbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6e197606105907bc0b6e6156530d6607e53272f1e40b5d435937f672122d42cd
MD5 5fb48afe7fe9ef303d52cc4dbf7d2685
BLAKE2b-256 0a71dca09e5fedbad7ce02037dc506dd31bd623bded5dba6f7b2fb7a8a6f5b69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.4-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.118.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cbd66dfc10b0c5cd0be2c76b675fbd799aa81477d52d280da282f216b7f1331d
MD5 babf041b181ae1fbaf0996e55a5dae93
BLAKE2b-256 3c4526577b7484c4f7719fb939758b6656c58612e6f403d6accaaa0e6cd5d83e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de5a57d982e9b299b99288ecd9ce28d42be2c5ef85f11b2fe34fcfc18e61a455
MD5 215483599e8cbc692b33570974207372
BLAKE2b-256 bd53604c5d941a26b4144dfd417056ad7640deacd75aca14bb3979e9893226bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 87e9dab4d994221491dd6a8331cc2e8296bfa89201b7a331a512a0755975cf09
MD5 2f92bf09de2edd647516eb41f84f26e8
BLAKE2b-256 cd0608ae314b0906dbdaeb2fbd79143e00d8533947b8b85ad6d0c5a406be6983

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 63e905882d34df57f7634b066a73b8909ada9368d5aa6f2989638afc2cd19212
MD5 fbe524b783a9168491cf71d272ace3c3
BLAKE2b-256 80065be424786ea5fd06a6adbc232e3183d0d6ac4d006bc1e09ffe693b2b3620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1170ee073809ba89292cc944206ef98791430d3e8754c036c259313831cafc26
MD5 d6e955ee7e2a24c36aed89cd65b70984
BLAKE2b-256 96e7726f8da2d1f42c3fc64e49fe7bc8ac430c186979b9fa16b079171fec9df1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.4-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.118.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 24b8c7d3f8d09dc071943bac9ff3e2a685fc5fa42abfc0563a3bebe783adbffe
MD5 e8c3313c19db6793f30c10c0c21b538d
BLAKE2b-256 842506c1e64859043ce08a4f497ab4ee0504b77681c3ac5dc5472e0229a7d0f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 115b2b3ed9f278a887f83e971e9eb6e70b294e280e0954baef01bfbe1050c7f9
MD5 7d5bfe0c2aefcc5fd7a36bcec8284739
BLAKE2b-256 6fc4279ca7ee845f6c1954595362f38297e32ec3871505c47e4b778d9554e407

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2fbdcd88b1d30d9ced4b1659d25b5d96086d93d5402cdded0e4b8b49f64a8b66
MD5 f3a5c33ab2d031b5272509bd50efdc8f
BLAKE2b-256 752b901776f92e01e07872693164509bc27b500da3bd9a22492cd242c74e5ba0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cae97fa9e6516ce42bc21c693e5d228046e5bff0b1f7bddd6d3fbd08bc0b7498
MD5 c02db43aa52a73625c4be3c95bb97e03
BLAKE2b-256 dad562e276290a37514196c620043118eb3bfade61b365c6420506a55c38bb77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 82a952758559ef53079d165a8f734f9f5b343a9d25772a9c5ae5820e8f46d008
MD5 8c3523972980de9b7fa89e00146a8c10
BLAKE2b-256 4054716f8e8c8e2e4c608834cc39dbee5f1a75a3218c62a86a0e7597cd56aaca

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