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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.115.3-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.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.115.3-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.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.115.3-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.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.115.3-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.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.115.3-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.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.115.3.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.3.tar.gz
Algorithm Hash digest
SHA256 0ff27a9dd103b33024a5f5876d841207093439775843f3f60f54dfd3eb098c88
MD5 6cbe7fae95dd89325901c43e63cd1fea
BLAKE2b-256 1ddb42a4335b2d60aaec1354f45c6cea7a8b4b190bc07374365ff8fbc6a4ad21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.3-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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3787565f4e17c6aceb55401f121fff74a8002c0411a5155c4c5d2bb52c40bcf5
MD5 63af0738ad04afd51dce513d915eb09d
BLAKE2b-256 63ceb9b04f15bb5d6d9d368e5634a57206754d8851fdc13220737c8eec08b5fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe163776a0740f6a37e5704896368644460e8fb1adec5186175f3a90d6806d78
MD5 e8fd056610bb6894b1e2acc6846616ea
BLAKE2b-256 c502d1e1847c5418078c74617dd3be6bf5a5b7f0f64b5098c1e73624a2d1e427

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8b9fc346cd73635ca4b8eee1f56f39bcaa5ceae809e0514d61429419a5a142c8
MD5 c2458246513e75ef0448b9adf71e35d1
BLAKE2b-256 67f7beaf2d74af4145fe02c9a7246f426ec1a6e4d33a586abb708ff5eca0d067

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ad17d39ea2120670ed335d5d8cb5556ac412dca139229e2ad2360bfc0ff9eaf
MD5 f950e5a156121e26541499fcc63263be
BLAKE2b-256 1e689b8c79476ada037800d044e0238b8e387532075ddbf8204f74f0d580e0d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 dee16d191d06e5f494be119d5b72434a0c410c30d5c8f064bdea2c916e3f5860
MD5 e4cde6357bb097ccf8ac3a1aaacb3874
BLAKE2b-256 b204df39baefe77febef874b47d4bf969ae674e63cf6e0a74308ad46e7f71b4c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 167cb6d4d31ce6849efee9782bca920dcf450166acd7bf620f87b4afeb1da156
MD5 766933dca1fbd4a6ca4150a931923bb5
BLAKE2b-256 1aeadec1d50d58071461880172332126d6e64ad1ad40c12b2b72ca0f0f05f518

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ba67874c56cf82f72f4a7956a98777849413ac316a9a044fc489efffd2563b3
MD5 5e0384d95fde5ca2b8d305615a534b4d
BLAKE2b-256 f33397387c04c07f2ff62677fa57ea4f3e88f5eb29050c0f55026c1f11fbdbe6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 80abb62a783d85b7160fa83d0b285730e154c2106b205d4dcc8b41ac40e163f1
MD5 ed3f9052145a8949e09a311daa58da8c
BLAKE2b-256 b1f5f2d68e4a026c204b03cb3f78f3dbfb2f6117592ca847c3d748aa3b46df56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78a9be969666ab1dbea52918e455276678f5dbbb7245b65b00f175ef93661beb
MD5 cb9b47c738ae6c55fd764143e0414008
BLAKE2b-256 e741475696b335e8f7484977157cbe3297528fcc991151dec676ac7fcc566d53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 de93731d69c70419cb147c857d7ab55d909a81584485cbda3d0bc3a249886fcc
MD5 fbe2be6d6ddf5eefba68d5c8fb7df910
BLAKE2b-256 e9b15c5698a0e1c3322d33ed0d4216064eacc577378ca5beeb077e7195b4a101

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 29e02e4feda5c508ef5d895aa1721e7d2c964383aa22612f1451add486db958c
MD5 f0a6075710186bbb8f48badbb1bcffca
BLAKE2b-256 0ba70079e19f928c028674727c9c6ce24c9aee8d50551cd5217110104e12e61b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd559470122687044986b6fb25779601b5cb5feb6feddd6261f3aeceec97a635
MD5 b131dab867fa596298f27d839c9e6dfe
BLAKE2b-256 3b700a7e5b65fef0b6515defd563f92555d9213ed30916a4038b31d3a1ee36a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9f341f4a33eb894d03277df3b65690ae11d787cf76b024cd977d6601b321672d
MD5 50eb2e6b9fdaabd466ed59aea026affa
BLAKE2b-256 6eb29c5cbfa8919319feea311a8780254d0d4160d623e27e1c03d9bbe809ad8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 58576c4a7752a130d9d72f53f7c8b448e254b64c64d53371b69dc0a6f3e6e22b
MD5 6aee9cb978e17e41f4ad9637d32f6693
BLAKE2b-256 cab46cdfde9343ff7e436f67194667b6e186ea38f02add2da8c06ccd3096b3e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ef172769e1479910e5109a5fcad25fa23ad14f937d8ffc95926b8f0b693a738d
MD5 fff6bdd5d9de01251b060f7533c4c443
BLAKE2b-256 23d62db6ad8aee0909c3c8fa12efe74aa0cf21020a0bbc384128765205ec11ea

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.3-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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 41b7a62a5fcc176e2b5e787c502fd3a06af4b0c466389d00a9268b9b09cbfe98
MD5 39fbf7e084e6cc81622ef85d63c33cd9
BLAKE2b-256 615f9fc887639c458fae098f1756fe65c20772ffb2e808c028804f77af5a8bcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 063025b8a757ac88cd3627d0182cea86aad1aebf52f22485272d463fb8570397
MD5 134e05457954e2f6203dd40ea9babc8b
BLAKE2b-256 80b77723812ddd7b444514053c6cef6f57083007c83c559ce78b9f09d021519e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d693aff276b607ef6c4d6f3d8c0159e69f38d94b1cbe474f5b35f24f0bf74fa4
MD5 c081283dd8949414d523703c7a0379f4
BLAKE2b-256 5d19f6de5bd56c38fae1e5c1a260dd71075d1dc5ca3fe09ae239d75a9e324d63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e75c040f487f8e1b2ef436d51d9064f5e5b7a28ac70d53ef72cd838fa5f691df
MD5 247e8618066887de835f8fbdbecb74f6
BLAKE2b-256 3caca75460a5bfee9f722f81af0bc8ddc1d93c23b50f97e0a0562f1772f47450

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a9b63b64e69035937b22f882674ca0cf757a69b3ef4a8c8608529c84f003f081
MD5 81dd660241c3e4df3cd1caf68f49ab26
BLAKE2b-256 b245d4b8709d1d8687364e1742d1808b1347bcdf48fe7bf8505fdc64d1d817d7

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