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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.112.1-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.112.1-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.112.1-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.112.1-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.112.1-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.112.1-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.112.1.tar.gz.

File metadata

  • Download URL: chalkpy-2.112.1.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.112.1.tar.gz
Algorithm Hash digest
SHA256 fb73895f0b5220d6e41a426e94c151714af8ddcc7c6de139bd8c85999dc35f7f
MD5 cc9f11fefcb46d3b68cd0cfaf52ba861
BLAKE2b-256 e1b7839682a4109fb99cfe0deb6718b321014e93be01a652d6afbe9579253702

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a1647ed5a859b3c9ffbb9a6b946de4f07f863b6ad34d9130e3c77483109c28b2
MD5 973444eda5e380592a1d76cbebdb42be
BLAKE2b-256 415aea3e224104c6e44253e095a88500012c1d62cc2ae6c1b6382da83d6d2dae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62ea3f1ec115c70bcf7db772d8c4a8bc105f2263aa933fef84cf591f8e4dd1aa
MD5 37f30a6bec35e24fd28f418b950c6247
BLAKE2b-256 31b85d4822769cc251744124ec473e3fa2a44856eab367eea43c91062c5d05c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4c2f319d998579578df3da1b577c1ec7f82b96c9db2eb1b1f2daf986c62d3225
MD5 6003ebc1790c9b05c10113a43efecf46
BLAKE2b-256 dc98c20d22231dedb3b23247fbc96793a5ab8481b97c0ddf4e89eac29a864739

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27084cdf0ca289965415568418edb4ea7e7803cd60d9cb5fd8316c3daa1dddfc
MD5 b43f62f5b6d88bab4acb7b5e9c9d0f8b
BLAKE2b-256 f04e349402392ab4a75630c3eb377b4e09e056b2b3e314e3da1b474f7581ac67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d0d3e9e51daf6ba3a22ee1c6f6e19b8340d02075ec9c287aaa8f0b68dfaf2d34
MD5 4d3e93a4c34c4691d433a4afdbfa3433
BLAKE2b-256 7c7f8836df2888b690e0554b1ab770dc0c004e17fc159e34370d8cc7a4ba08cf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 426fdc33b1a555aacb875d83bc3d3bdbe2ddae405fc1493cde5274966bf476d6
MD5 500b9fad2d4f20796dee7476e54f7897
BLAKE2b-256 aed7161559d63f20a82b2e56cbaeb0285b602eeeedb68c9acadb5358dec6ff08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b34eca66fbe1129db216d1e09e85ee5eca5e08f6f330000b31d1bd55995c836
MD5 f451712bc8d60c77e9c4fc42f8eb27cb
BLAKE2b-256 dc35335588a1456ee2b0db5f050444496d84fadb90f8203769a4fb92f15ee70b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2ef064a8da0a8f3e86638e8f9fc0eac8b7a9f8dd1ebc18c1bdb80683dd3e3b4c
MD5 cb400b99dee1fb608fc1289bde2d3488
BLAKE2b-256 5b791d3b3965a947b827d5b6600d8b68d5737c073f1ced0cf5af201b06aed76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 256eb7803869559f99d3cb87425f765dacebc9ccb950a29e4133d0c20afa009a
MD5 f039bd4a013da301cb241746d07b501c
BLAKE2b-256 0ac636c8fa7714f6bae2201a0c0d328d1b2f21ec36d0b7ee8ab5a7debfdb2709

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ddc8748047368549e68e5f61cd0177d7909dba95fb2e42816764624450695514
MD5 a187c80254699e3acae6984b3ba9b0a2
BLAKE2b-256 6dd2172e58b6664daacb44cfc590d2e8d70466e726a5bb599895b4d496c73bad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d247a26b1798ecd067b5d131b1207c77a245eedfca084ace5cd480b698a13373
MD5 dcf6b52ac4b364cbc2d754d2eeed212a
BLAKE2b-256 43fb8e47f51db136c80367972608ab6b8679e0f2f8dab27bed17aab98686f176

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0f94c03b0f7ef247c2fdef4fa4b39f1de8be9da6ccae807823d15a1b553a760e
MD5 f629c0deb8a80170962542d996d7c280
BLAKE2b-256 99009f2ed21fa55bf806d844c5c954363591ca6dba3132319675d1e8d26f9473

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 806c68e9f649f2f97bb790dd9e0cb63040e2c2fa34edbcaa6018130a0e34462a
MD5 7c2ccf74f44de8a68f955e85316f9ba8
BLAKE2b-256 5102176149269c00b6490cf8bab4a2604d486af7e43ff58108d62411bb5d3376

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c8ebabbe7ee2d60b387bb0921f0b649951d7b5ce4894507aa225433877a711c
MD5 169ceab1175847e0228d52e2671110c2
BLAKE2b-256 c81749ade94a8406ff418c609cf019541f606a3c06d824a5ab818e022cbc8947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5a8f2591fb17c20ac4cc5aa9b8507a811f6deaf672630726944d9c2841bf1df6
MD5 3dd4b6147473e349d8cd1cbc6245bdca
BLAKE2b-256 3f47cd05df1d4f1150a5ec8c3f13932eb32e9ef5c7b019bdc9089c7c5e0265f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 408c0e12bd9f2f512ba7dca2dec25d0c0f2d19eb4f9913baac7c4c19727177e3
MD5 77c4677af159195b14bf82f5c1d39747
BLAKE2b-256 ee5d3b5d91da782887f56577baaa1d9b46b9ca8bd4cfbeb234c6344e7caa9fa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 42667f4ae98b897e1970132511e3e3bcc5acfbd08e2b58c84865ccf57238fa36
MD5 39f42f1b909c694e692252420fb13d1c
BLAKE2b-256 5c1eeb73519f538e902612226dc66b48765ae017c2f745bc660cdf22d898323f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4300a5e692448b795bfd611dc25e512509844a3ab21242546229e3c0c4f28044
MD5 d910164e3f279014dfe536ccb28d441d
BLAKE2b-256 520fce26c68994c666ecb3475b8e146cd04c8e4199002b85e3275967d276bbe1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3fbefc169880067acfb2d9dcc70b48c56579f25bb7e450e05599dd13a1e8faec
MD5 77da4e53a36b8c94fb5e2e8908f29fd6
BLAKE2b-256 4919127359a345ee7ca3d38f5236aaf8e782b3bacf13ae6b0684962e682a1d3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 35cb0cdff53cffe36af9b34a41798b31f55ddb3e7c3bbcf3cf0a808090af6ec9
MD5 e413b9ed71dcfd7ec3f1ff8339c93e0d
BLAKE2b-256 38f88462201de2a7fbaff9bff66d42c5c51c9ac16082d8990db7bdae8e236b56

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