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.125.1.tar.gz (1.7 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.125.1-cp313-cp313-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.125.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.125.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.125.1-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.125.1-cp313-cp313-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.125.1-cp312-cp312-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.125.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.125.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.125.1-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.125.1-cp312-cp312-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.125.1-cp311-cp311-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.125.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.125.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.125.1-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.125.1-cp311-cp311-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.125.1-cp310-cp310-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.125.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.125.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.125.1-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.125.1-cp310-cp310-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.125.1.tar.gz.

File metadata

  • Download URL: chalkpy-2.125.1.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.125.1.tar.gz
Algorithm Hash digest
SHA256 39110f0001aebd8c37025e5df5e99359f723f989246e19ed3cf3c3bbfac77c72
MD5 07e72e5b3bba3a1d92cfeb033e05a9bc
BLAKE2b-256 bf96e62fe10aa2276016ef3ae5608581eed44c812751d50c815f0e4b1633e750

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.125.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.125.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7fdbbc64b3322b6adaead7762140b0314954b61a2ea5f819751e08fe0775115c
MD5 4190ef6e4eef7eac13c9c87976a59016
BLAKE2b-256 098c13b95f408164b774050ab35f473fb990601092560f8032efc8ca29cb1ff2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9aa16d2c8106587f3dc0be1fd2921c816723c47d6b6f8cb7a64cad24fd3d9dcb
MD5 438a9fc5bdda0fd2a853ea72676a5020
BLAKE2b-256 8e3ce7d21130df07a3da26492a3931cb2435f85be674fb6fb004e5d77619a0a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 05d29577ac0ca92d1af605dc07af01f159b20f2ca181589f821cbe2ed6c9cef6
MD5 f5470445beebed169bae28ed4ad91ddd
BLAKE2b-256 6a27ce77bbb618f04db48561b6fde2186a08fd4f940a91d64fec3b0a18173fda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06ba0f40331814ef512063bd75078a6e4db0d5c58b6344bcec673e9dbca5aed5
MD5 6504a0d296920055ee8b4aec2a560465
BLAKE2b-256 3ca9c0d4533b054612ef60d3c16b2e5601e46e714f33f813d903c9f58f5fa8a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 64def3e6334ed3206370f351fa125eed64aa91e1154d390362ec2f971282ea76
MD5 7d6ed8039b54fa1331907a975709a876
BLAKE2b-256 8fbac0e678392d40994c6417829ce173724e5bd23ea2028972898c358bcb0f25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.125.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.125.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 653010fb2d13ec05296158b278e17d0f468b4f8e36a2c014b2c48b4e594658b9
MD5 0a952edd4708b44167d50fa5cd105882
BLAKE2b-256 7efc08a38ef9d43398bddebd3b753fde35388c9a8215ed850dd932cc00a8ac15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f773d239c5865e3d232518da50a302f2f3e68bbc89d74ba398c5c5dd3f11663b
MD5 8beeddeafc0b09be72c06ef82f1b7719
BLAKE2b-256 2f8a9bc348a5bfaf55989ea769b759278006844a6060dab3c547f734c7f0c971

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b9cc86e1b9db84978eb34f575d64ac68094a38fe65feaca2b4d02cf98e79ce67
MD5 d5fdd0a83d3695bf595ba2996f462f2d
BLAKE2b-256 6a88c035a150f4501d51b32a4e1aad23c9b4da07b721e85f0585c854978ba764

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4e09a0123e1da5f855d3f8d4e168cf01e39b61962c6670006b9d52c8eaeac57
MD5 1f7d51b904f9165f7a1193a0347cc6ea
BLAKE2b-256 2b40573db1a34e96bb58b5abf6dd1412b12c19e468e6fe3a289a4b4ee205097d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f8e5b94a07536cfaf6237d36311910e6366576186ee662a7278ba47134d532f5
MD5 fdca8529b34812e9e3e3025659566e35
BLAKE2b-256 54e3b5568f73712a2000041a90537e2e2ca8034a7fb2389191eba098d35f3cda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.125.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.125.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9121e730daa367035527f1e63ed7c6cab0918ea4246ee67cd0ead2e9a9af84af
MD5 8b7703e8449e67a57d18ca8b0effa30e
BLAKE2b-256 6b95cd759b65d82b761dfd45f226cc22746a9d071b7260ae1eb49873850484d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 70bfa6165bbc52c927cfcdc4b31574c74caf4cef35fe6c83e9ed559af48001d9
MD5 0ac0cae14baba539d2112a822ca367e8
BLAKE2b-256 af4760892990b3527c3c4e98c59c7d5fd6a9147e288b0823d65a5ef9938c38a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 34426cd4ba11814205a63135447a2e518f8c8c259986a847c192e1ead11976d5
MD5 477b18ed8a8310c0b82c07c26d7d0fde
BLAKE2b-256 c534cc9132bcde854f7ba01655ead6e5a8435bca00a98a1912b406096f4fc377

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d61ab72c35eb612d645bb47273c1a0d52eeebccac0a6d0f65f42efee1d8b0827
MD5 2aac1834c12eb3213d987aba6721bd50
BLAKE2b-256 13f50f472194de7895c0a654a721e5d05fd4a747e38e1244fc79de9923d3fc3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 696f613e158c6a658356efdc477c76c2d91f858a2e93931ab06e15c3548eae06
MD5 de30d6ea52f0412385cb7b541913f6f2
BLAKE2b-256 6343c357722026225a17a1ec8e0bee83d994f17541460e31edb62c9fd941af2a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.125.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.125.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 063d2a5a4c2abdd1d6c008069e1d362dc62368e333a1ee6eb12daaef2f11b3a1
MD5 39f2f59b299ed4c8fcc1667459b2f935
BLAKE2b-256 c2b5b20b173d9a9897924bb10def342193d921c6b47377b0217fd2e7fcba826a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb81912471dbf1db983b03b68f4eceb2551302ce63beb241c7f1f61d143aaa2d
MD5 6cec1f5023296f3c6020039d24216cc4
BLAKE2b-256 f25b936959cf42586de807252478e6c87bae628d3733f18b478336eb1fcb550c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 001699bd19e6cee522844c685fc467b4cccaf741f4d9b2ce02cd1e44ec99cd11
MD5 20aee61537e76876cbb2e6c3d5fb5443
BLAKE2b-256 35caf2966d9915743961ce6ebbd1ce20dba4672a4bd608b04c152916ac66fcd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a2732bd3bacce9ccd9a0a37644fb99f0bd220870494ebb9d53a4b33af971e3b
MD5 28bcd02445d30caef3fd99115b0041ec
BLAKE2b-256 880ab77f2012959b0998473960256bccf0bfeddb09fee50df29979ecfe3f0c78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.125.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 69b80eafb587f60bcb7b5f3fee0d98ba3af017bd0c088b19b82f076312a0656b
MD5 40e8d2be02a8c06610071d1d991fee33
BLAKE2b-256 71511ecddf520d0d3fadc3977c19a7b75104b8eab57b9ae27de31ebd1043ab4a

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