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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.4-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.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.4-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.4-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.4-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.4-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.4-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.4-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.4-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.4.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.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.123.4.tar.gz
Algorithm Hash digest
SHA256 a78cfd84b25a2eb61df79edd701b0e1252607e0b3f65bb878be955e0f5854b0b
MD5 7d8af867cd9a4582c526531d5b16d412
BLAKE2b-256 419bf9c454b2ce2dfcd1ef13d30c121049e5b9dbfb50a3c49cce3cf2b89a4607

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.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.123.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3a385514e3ed908338e499ad1a7c62e39666df59f6872251f956f564b4d4ac60
MD5 e640d6a7ad44b072f7581fd3bd07be77
BLAKE2b-256 d355ed9f490107004eb3f7f9e4f71a0a48e967c266e71ac5630791486e9ae00b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e589f3100c9c12999370892cb991e87d7e919c27f0c8204ac4ed12d70370af12
MD5 b50778183afabb713c910d2da67597c1
BLAKE2b-256 595a7e83b0d917ef9245a042b6c63e7e1706fcdb468321d2c3eaaa171830beb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 18dc4af240ca1c60cc1e3bf3a98593240492205fc05c40282cfb06c0ba603434
MD5 49bb520218c0fd699ef67ce1929064c0
BLAKE2b-256 448e6d7ec2a4a3e672db7486feb91bce4c8cee766edec28c30707a3a4a26c0f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ba93edaa4ca22ce9ccb4553c45ebd9ad90edca8f5462a50efae84c6703182f7
MD5 d17030a6fcdc9ca8b2d0f96d830321d3
BLAKE2b-256 5208a06bd6c98cfd794f5b3ec03f79fe312ab086811fe0e217c4401f52d763cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 854472c69c67f410fd3f8ec2b34448a0524eef4f6a90f2b284248a44e5f6b415
MD5 aa4a8bdc4b4a91709ed6897af0effd6a
BLAKE2b-256 cb23e08016f73ce8cdc581f5735b2828db88f00ed0519bb4cab36c9726bd2df1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.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.123.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a0531e42ad2dc387d7018f1bb31dbcb9a84384d090254a3754db1091e2ca7af2
MD5 50a651548ac96b6be4f45467e2c28062
BLAKE2b-256 2245b64b969c1a175306a3418af6b0f5e8b157c8bb081a7bed29cbdf662b5d42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4de7e76eac4a18efe8b2edc971f555a5d5284b842c13fa33fa31617adae592ca
MD5 b7120edb6d825274f033b7d06da8de53
BLAKE2b-256 dba9b76e9881eb803078932dc8a7d07b5efca06ce06d28cd761769d2bf59532d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aabec639112fc6566312c2ee5c48e4389d251551f01ec8fbf9f2da4a8374ad11
MD5 3ba3affc83f5684595b1e1fbaf4f020f
BLAKE2b-256 08b6862c0d75972f2b62ed28ddb3c93b9bc81034a2c463b6f6d32c85ecf17261

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5acb2489a1ffad02e95cc2adb4a5d6d630e11e5d4450ba469184ce6407188683
MD5 dbc752c35041e98da115a6ff6dd83d38
BLAKE2b-256 da58306745d4756c0eadef8e82acb6f750fa0d4032d65b25b7ede5470945949b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 aeb7f266b6fdeb85f7c6869e5ed583684ba6bc683799ac75f6c2d25b5c73d34a
MD5 80bb0c815e171465c8b25cad5aab9c8b
BLAKE2b-256 0525d50dca8169e6117a8b2d8ea7bc59a19e8d2f16f3cb78793b263c8cb39904

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.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.123.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f2145fa3c2f95196ca6b35c68b38d5a0569ae66874de5584d14e409ab8a7ffd5
MD5 525bafd786b993c15d14c574c23458c9
BLAKE2b-256 60c608b541cfe224fbd19ce4670ce7de117c80324b87fbc0e028e2d402799877

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c13e8945e7aada29dfe817d37eabbb4ed78f0cae5e06e652fa1d0eac35c669fc
MD5 106fc3441e910e26789a9d546c4df0bf
BLAKE2b-256 2f8d6825dc375f17806d11399f9a70bfa7722998b32831a0891de316238e2d11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5d25bc6bb492454c885fac7a96366ae4b7e9db1527c2501d3c1a0f5d1e10d36a
MD5 c4fe79bd312544aa0d57b197253f0067
BLAKE2b-256 a1c75fadbe479e541c2bccd980871381f8247158862e4f1bfce55379a400b5cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99fdcdb7451db108d4f365fa1d7efc0508f85376866fe7c33314027aa8eb00ac
MD5 f119ffa5a586b84f8cc594d784bfcb51
BLAKE2b-256 2df8d7edf0b2289b1ad3e6d0781e4fe8cf1e6bf973b3bf835ade4cd034bc81d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5d470b95f8c0d67487bcea1ecc0b84f7a8bf521ee271817c7a1c213253a7f413
MD5 0eaa9eb936b1555521a3bb6a91fc72d3
BLAKE2b-256 65c4d71366728bcbbfde66c7696e13dafb0083a787181835597da0ec721f0987

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.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.123.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 03366a3b42e508f59c90a98c02f32db517dbfbca90cb646fa293696e45626a59
MD5 bd79d8b8db46852ed3f3c7635ca34322
BLAKE2b-256 a0d24fea3a7583e39c88c460290fe70d410342060fca222bcd0bd86d174c1e78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0045989ae14298fcd70710401040548b862eb91f0c45b29237d4aad0010f8eb4
MD5 c95acff40bb8760d08a8f95a6ec28dfd
BLAKE2b-256 b21d9efbcf8f9f2312466f46b93f03a57f0dd2d8962a05419666c14092342124

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a2ee1af0ad2c37e0aed786f21de9d4328d42b4f3916e07592967c3c4fdb733eb
MD5 a6f981e3838c75c68abe7c1217002bee
BLAKE2b-256 ac4a5d5d441b28ca2b69f403393dfb00ef4181e7701f3669f3638f7913f6e1db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f766d16f874f2f918988dea8a88ba2bd911048044cbf1b2e6ec88e1e70500f98
MD5 cf8759f233e3a7a9de1deb94d05a08a0
BLAKE2b-256 5c1cb45c511c2096c29a64da38c779da5b19204d3adb4632c82a0bcbba5e0674

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2b993b6f911c4a6093e46ed48d10900332896fe42ac2b9d65859ee71d4da4ba4
MD5 441d5daa89437edcfa52151e196ac07b
BLAKE2b-256 6c2e2a0268a9ee70691743f0d79047e65be6c43fa6194d1124537d34f5cd7c3a

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