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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.6-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.113.6-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.6-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.113.6-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.6-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.113.6.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.6.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.113.6.tar.gz
Algorithm Hash digest
SHA256 927acf5470d10840250bc7ec00a9085742ab5c77014a3d5b8e81c03bf725c5b9
MD5 f171f2c80378532db22f4e2f1fd027f3
BLAKE2b-256 741e9c6d12cd27f8041c4e087a17f3558aeafe4817572f06c00126663f19a4c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.6-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.113.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 32982d4001a4be53612fc287cb81de694d0c059f53b813cc8230541c76165ed3
MD5 625ade7a907bb9649e35dcadb4f38778
BLAKE2b-256 8210ff7ea3055069d7a2d3ff250ac8b0b21a11182e7826dcd5878e64040cde3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e1140355781fb7264167dbd43e3e37476a8bb075dd7b575dac782b3df5a78027
MD5 b1200a272df58b9bb38840becc6a80da
BLAKE2b-256 e219e1c972bda9256af0465e5c0a01f2561a01e39b06ca88861736bed44a02e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e7d6b9fe868d0b28686903f11c53e638290ee6b7ca4f45493fc5b19970bea41
MD5 89fc5e52155b97d148bad67f0009be1e
BLAKE2b-256 342f4dbdf91a7abb58f5c571f46b0b56be0e875328b6e86e22395664525678ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a80a3dfde056622f17a5fe4c79f5a6fcee07fc5de12bf68bc53e2a3071cf91d
MD5 6849a5637b873b4c3953607c51e3a587
BLAKE2b-256 b1e70e8e0059f1c3aeee7bdb13d7ae7715836c84ba34db09f8c58f8b024e1280

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6d2f511230334a2d03b257c5b92fa11075c2bbd44b2cd59cb855c19183e792b8
MD5 3e1aa2e00076d533e8806b0aa7e4b811
BLAKE2b-256 66a4dd2f41f32fc30ac1aaf3c3371421f6e9b929df1a7100f6338b88782dfde8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.6-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.113.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8d1f8410675cf15d0dc47c29f0ecc738942452438275ebc22664c3dc0960af03
MD5 4b74f8f218123e61544839558b69267c
BLAKE2b-256 c989531e44f3329f8fa151173e410669f23f682f9e90e6c0beb508d96dfd0489

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12ea9f6d747e205c7cee13d80343752ac9dce29ed35fb0c9be30ed23073c8da0
MD5 3f2ef53c94f682b74ec10d8c7119ccc3
BLAKE2b-256 c9cea4f20ff95ac29d36274a467378f1b199363950c5752fbf4757f01e600de0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 08e6ddc1e3e5f938503bd975d6f20fcd60de73fc07da11d33496cec6871be923
MD5 47fc1cf79f6c50611c52109fa0e9581f
BLAKE2b-256 c65e58ebfeb922b3bc4e420f70739e874b3e3f68b711742b7193cea2d1cf778a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 332dd990cf7055d5ec2b13b8bb465428aa779147788518eaef88e80804774b27
MD5 5ea35979427c1f90ae094eb973014673
BLAKE2b-256 b5cb4ea40ce8366d716114380a40e19330a46821b054d727ef2a553f44b181b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ffead9f8818d044413a7b6175fcd560d04be4f2c012c1bf4029089f4d58996a6
MD5 c09c8946b250fc71b8ec2578cbe15151
BLAKE2b-256 77a84400aa81773ec572745bd0e9634eb76c9f58af489e02c0aa64f299cf9eba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.6-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.113.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 60fe26a2c3567b5f761a45f89ee277ee9b1fc93f0ac51adf1e96d617973a6ed1
MD5 e362d693c4d6168afeb810ba80b1aa23
BLAKE2b-256 f5abcb3550e85dbe76eccd5366e571f4504b5e9e9426be8026b4e9ff21d73e68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 13c789d2849d82d1db77ef51abb69d85760dd81959c53a4089790caba8322927
MD5 cb9a37b7b3f2dba92be6e0c021642d96
BLAKE2b-256 1320764a3ad0023389fdbeffea423810cb2dac2ccb76892abcc01d81bf2372d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 23b1023241fecd6ad306b4eb7e3f5def44fefb468a4080245bf989d676a916b9
MD5 22d107e99fa42be4319e09cd9399a8d8
BLAKE2b-256 45f98d71d8b943f41647eb1ca39eda5e992592678633ef1325e988ca70b70a2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc745c4f5deedf365e04cd5e228b1fc819154975d598f401358ceac3cc4735bf
MD5 0d9811c9836526dd66ce7d404ca0de3a
BLAKE2b-256 814060a1bdca96dcfad9cd02dbb15074fb357c6b9ab46720a21556e34a361777

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6325bcbcbf73cf021f66bef64bd94547e597e55517faea55e4e4501635928a99
MD5 2382fef4511609bd599366fb3986dec2
BLAKE2b-256 d0b43a5f08ada75880d38dfae6e58f408795013a06b7691d3e949164858330cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.6-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.113.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4441178a01021afd1e42079a1a0df8b071552e5b1ac77a24d28adf3e9ffedc94
MD5 7e696310a72565d6c81085379e3ec630
BLAKE2b-256 985d2b059cdae18e7ed65e694df4831be7c7bd26187288e09f3721c5702c3ae8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3facec8c3a84bafc007d4a1d1cff76c0c67493a3657960c401bdf272d89df67
MD5 007daf25daab43ecf3a58714184f72f7
BLAKE2b-256 03ea0c433fecf95b25d5e200a93c40442095305a508f9cd44a6e878b23ae7a80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5163b6eb869d1116fabb97ae6c5dbde059c195e4961d3698f43cc2005254e267
MD5 54ea6de5dc230d3e9ef3fbe61fd57d4a
BLAKE2b-256 4c2b7b48b1116726ecf2f5af331b8b99db185f8138f68fdd0cf354e6461b1495

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 13b914c6efa9257d33f2bb47edac0113646402802310cda3e7e137679ee6d5a2
MD5 04c7594f658ba6db3e324019faf73b78
BLAKE2b-256 63350faf8e108d8752136d25e6a2c15b240e11a7c12883d7f5b04982f11e927c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.6-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cd33cb16c86b54970fac220bd6f18b1c732c8d511d27bc3f3c037c602a942cbb
MD5 a618e5e96ece863a7f13a79c7728382b
BLAKE2b-256 10eda154d4ccddba40e581cec54d48ea57db20f536882305544c9c7e0328b1fc

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