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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-0.1.0.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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a6293e61670b81782f198a4b7810e0d687bb24779046a9348e8acbf39a45d3c3
MD5 d4342ca09fa48c77fb4f9e51fe4ec746
BLAKE2b-256 c6fd0f0b5227e966e0d0fa33c30a0da5b55597a6f3b56611d241fbeeeb5b64fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-0.1.0-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-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ed961922568d73eef17558b1c664f00467ab33a55e6645d5614293335396489b
MD5 76e1167b4d656564e84bb2aa3f03324e
BLAKE2b-256 b76036442788367c5c125b156d008bc9a0b5c5d7e9dce20a5f629d512ff0f064

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 009bdd2b129014aed10d0eeeb28653a5f98429fcbf4e7c80067437a2f54d7996
MD5 93f6e9a5416ff8104eb80d1f3566e28e
BLAKE2b-256 bdfd962cf3ec08dc8cea1a0247385192843edfd3a4232ecfff8409742cf1587b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e670bba35e742fd5f22173f2473997347e9d17ad5a6abe6e4692e2254e76ed16
MD5 f1d9bda026da1130c67bd62ee8a7cece
BLAKE2b-256 991b5eaa0d27d759ee440cc5fe9602d31204532aea1af959b2a9f329128c4e45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca8eb6cb53568bdc6f85d93e49c400bed6d182c8b9cfd41f6e2cf14822a9a659
MD5 3e4908135a59ed5c61f0bd3773bc55d3
BLAKE2b-256 df7b72dea4607e0829e43faf8ab01bc0bfa29b71cd439f05f2328ff6ab184929

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1ca06eef9b6cabf23623d8956590f0e8c324d5706fde51a9c2c830453866618e
MD5 151dbe642fb0e3404c92217de4ad08c4
BLAKE2b-256 1841d658042c99a211ec598d8533c3c7d8a3c3e724dbb691aab6ea2b613cf7c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-0.1.0-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-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 de4519b7243e08bcd00d41fbd5c3ffee19e86adf17df334b1fe0aa8e9599f506
MD5 e8e777a38274494732718b9efd5233ba
BLAKE2b-256 bd2455d271defb6b996d6e5605d8ac333f16be45c005ce87f014f04739991e02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b1ac4efce9216ce573ef78837107fd4e185541e485ff8e13dfd86df895ac23f0
MD5 09915b27612d7d850e77cf760c1b499d
BLAKE2b-256 01875dbac0a70bd02b3a728e53fd3f739feef08130d617adb67d7c4429167bda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d3af2f4285631fd2ef47dd1504bf460d0244130219d2ed5216a4c8791d0f7691
MD5 1a714bca3178eaf7a034684db55693d4
BLAKE2b-256 85a96a56deeacc73a958039d8b8cd9f31440476a1b6ddcb4d6d380046070647c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a6928c9d89b8beef9e1406ce9a1943796650ebe1c928a3af1402cda534eff81
MD5 78128389292f028fb3f26cd58b89d76b
BLAKE2b-256 8ea93dca6ea949f8c43b200514ea83b881ddfac40800b0b19b45da1c7c7ee266

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b341e6121d7307eb41308a1b3d4cccb407b43d98b9d07d63726604790979ac14
MD5 c3ce75447f1d8fceafe4d185305431ca
BLAKE2b-256 bef2ee691ef5c8035abb8531c221b8ce2c0a9a22eaf51960cfb20f0b6e59ade5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-0.1.0-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-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 93cd4325dc76f6f2519a39be871b55f082c08052651405db4585b37365010ae3
MD5 c10ec1954956eeeab8e6a0572aacd526
BLAKE2b-256 0b82ae799f56e7405628d82c080c3a9db932ff6840be9ce372e10ce69bc43488

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0280af777dff449ed910cf9314772fd2a03b70005eae252bda80b05fa0dbf69c
MD5 4f6a13440d3e0d097f1853ad9c65a1ae
BLAKE2b-256 735b9f4202b9a992f197eb82f00fd6f1ce9c938f87846c057a33919174f0c1c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bdc336d67f35d7e680b364a29c6c9561ed41913636ceaecdc6ea6da62242d87a
MD5 55460ca6aedd27cb5a1120614577f107
BLAKE2b-256 1ee0bfe4926f04f844db0bb6f369941bd0451ddc7d96cc7138b7583935c8f2ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a6561259b2a9ee6e6d9ed5a65fb31c1d0c035e6638272a0eff9c010dfa0ca4c
MD5 053bb52da6d5860521dda5c3e97a3070
BLAKE2b-256 01e27ca44b1fbc3e5531fda3f4275754c662974d9414bebf008ca59e9cf6e668

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 73af87e514132740837372135a4dc990bbfd96b607b32c2fbb583482f4f4e41a
MD5 6ec77ea37e662cf8d7133fce2b5af408
BLAKE2b-256 99109871b6fd045287d11218393214a12817c347c35b73b547eec17fb914c6a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-0.1.0-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-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a9754ac78c8037bbf081c8fb4f8d929c099f6b490733a2beb4c5f7712b19ec11
MD5 2a7424e3d4e61e97562068e7251cba04
BLAKE2b-256 8256486cc6d261e5c84af43bde04f5ba4b50ff6b6c9906457767c7183dbbb3df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21e37c2d8163be8073ee5855763d52a762cc950b3e03206cc38bd887dd97b08b
MD5 e251c62502e18a4fb389f8646b9c5368
BLAKE2b-256 efefa48d15096cad1b840cbd79f1be4b8c296bb45466b418b741c6c04ac8d7ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c03425d3b956d769a7cf6aa817d1b6c23e99e708548def1f02208f28fb7f8a56
MD5 2ad5112e9fc4b636150be87b855a97c0
BLAKE2b-256 9b3f4ecb8215e3c84400e06b0467744952452fb7097f6c7aa690cb6a0724a1b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8aa08226c40853ad84384de50604a30c0ae2e7f9b38d018476fa7805695273fd
MD5 1c35c7bd2e79158c98d86344c50c2cc1
BLAKE2b-256 d43e03851d25e7260666c7ad1ff5cc2690d7634bbfbdc0d35f4d38d8fde20afc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-0.1.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4b69c6f6e2824aaaecf8fe2917818a1a906e4aa7a8c3f9792fd727905c0a55b4
MD5 0ec68215b2ed7ddd12abec98abab285b
BLAKE2b-256 c9859490490dd1c98802e7a7df4be452c0d1ae1994c4781570c1a0547c9c6de3

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