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.110.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.110.1-cp313-cp313-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.110.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.110.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.110.1-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.110.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.110.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.110.1-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.110.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.110.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.110.1-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.110.1-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.110.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.110.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.110.1-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.110.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.110.1.tar.gz
Algorithm Hash digest
SHA256 a893e588a734fb67850c55e47ec01dabc5ea67a1f300e58c2d9c8b35af3f1a0f
MD5 9fc25c41a79569012b3c41ba2c52d8c1
BLAKE2b-256 679ecf61044f1d09cee56fdd6a67df4bb56fcd55f225e537b2bbfd94b9316d30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0b247c403320e53bd65f4c1c5f1f5efb5e9fe0d67aae152afd2d107c7c06e7fe
MD5 e116fd0af6a86e4462ccdf0b8fc8a2ff
BLAKE2b-256 bafc416af3aba1f4beae46bf3b58029622fd3395c96fd7fd5ac90c71efad0a8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 faeacb8f1c091c0c7dd33215c5bcede2d8a6f0aafbb7a2a7788769466ad0c949
MD5 81c0b31e1c461cb4db80c9b867bc16f4
BLAKE2b-256 4e41920f36bc6397c69407d07b5c147dc4dc0bcaf3722d1c0d80dac117b2e91d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cedcc532724e29969c2cf5537fdfa532671c0c9ac3f2252bd83b1ae14b35f804
MD5 e8218391d8ec17a0891570f4338ec30d
BLAKE2b-256 1f705a6c4aea2dc326e038ca11f2d57b5fdd8b1226d6c04514dcf466fbbe2dff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 147d2faefa2afed6bc6129ed680d63733d52dec9522c820664dcbefc8f327334
MD5 a41ee4b6e1d1ba044ddbd8e22ca33b48
BLAKE2b-256 35bae519a86eb8738bfa2cd0e9f109b1ba227eb62d8fad52e63516c354701458

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 acd43f0e929c3098047f4be32a781b25fe37be8f0add2815f2515197bea7f5a6
MD5 07633af8e9a008a6dc78855bb9fab25c
BLAKE2b-256 b276535204831618698092c4f01acbe2c543cd92cf34e3633f8aa3385f20d841

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f170b0135c08cfd3e50207efd36f26c2f59f38f2a8cc26ad5e68725887820bd9
MD5 d7315ea2cd3920ad0c523f5cd571aba1
BLAKE2b-256 0bcca0dd68d698bfed87c89023134c6221da251e5cec2a6f3dbc64091b82d4e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90f26b7b29dffae7d9599baf58f694231e7c0f56b28ebecd2904bd8d453bd77c
MD5 f9d4177db502901dae812b72d5f2c558
BLAKE2b-256 5b575d2a5d887a1ca775ffc9cd43ee5e1c1138f5806a000de095ee063b8bc7ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a717cbd66de9f5d81956ef876844275d08dba4a150db25ab21efa674a8e43427
MD5 11918467ab95bb0650c89c7eb06a7813
BLAKE2b-256 5ec5a6860693863525aab5760ce30d2fb8373cbcad5a53c699c862bab131ea1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cc38fd3e3f0429ddba02282ce16a7c6b12ea98cd9c630cd66e4af9e721033cb
MD5 49e8766a34e01e30b6a6247f4f573ec5
BLAKE2b-256 043d6626c96f4d571985eb943aaf829d7eb265d0d286bc36c76541bb00838a50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9cd856d623ef676329fb016b0e30c215a6c808f3f33d043e18016b8783b3008f
MD5 5429ae2bee9dbb38f85f7bbe17278126
BLAKE2b-256 e0293d57e0635ad2c2081e6357ba11d2c3209b4fb8d26ff9c43f83a9dc6ef24b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7cc56715f37bbdd043691d447b69b2c277e92cc0f6e53a6b42d0267f6adf63b6
MD5 55e55549d81cdf38c6af9de71071a265
BLAKE2b-256 3b48893afcd571ba72aa638c23c84b7d65d7b731c6635a2fb09b9022aadd3e1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52d1ea889a098cbc830156b4a6a4fcad4a2a3ce20a981d83b041787fde49e485
MD5 43583efd0d1d03c88800da613dc24762
BLAKE2b-256 a24486a35381342b28aaba83c47107dc4d52366e415498012f6ac30a75a8ae9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a15504b2c35b90d7522783f9450112cd3f57e71c736b69ec20d2c33adb248d1a
MD5 858d98e8a7b3620f084c5462b621c602
BLAKE2b-256 cceff003fbdbaa11dcc5faec47e779ec6d49a1316ed9b5f03974ae3a0cf9b8aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5dcfca41e938c136f043b062674a7452281344b6d31f754621472141acd78894
MD5 bfe33c1ee52677d4a8d090c72b1642bd
BLAKE2b-256 71ec947b1a09c414c20ec22bcf884e27d23873a807f7fe9cb96b49f0acf499e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d3ed15e10692e0e405678e3339b58ac922d3ada9d0901b542d74d21948010ab8
MD5 85311f5ad5a80bdd898a98d18ad85d78
BLAKE2b-256 796bb8f2b3cd5675b029f1811b1edc0094cc171ac638965a1fea529c89db745f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 457daa984253cf4972d453f321b0444ce6172e0f50afc65a3adc4d0b8a6db182
MD5 b6d5313e70cb3ea7004a548c138565d9
BLAKE2b-256 5b6caa1593bedc496d65114d36f45dfeb896e1270451ba75d8ba9b6c44db0ecd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2269daa91c0331e1a9b0539853a0abdd23f9cead9e1bebc1dc32eab092b06ac4
MD5 d8cdd1656f81cdc8366e31a2d0900e7e
BLAKE2b-256 b4cfc0f247718dd259661b743ce5b917917c66deb915cc728660dcfd0c108595

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b977282670cc38a817017fb194cbf19a1490b3774392c59bd968fc2cfb764424
MD5 52879987b35d0076e4270ad9749d6399
BLAKE2b-256 af51af6717817d8be5171982343a1a6cef90555be72a3edaa7cc8a0a99c38b24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5820b27f1cb32afe4adea2f37a0084dd385e056115d06d9106c7d533948fe0ed
MD5 73e8e9c4439dbcdf4faab354622ae1c9
BLAKE2b-256 00ad5d1a15755f9e179878411ed0e5d4ad5fb091d5664916ebe859d8754ab81f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0c73437e78d6e95d89bca85f60f56be4014aa8b395d00b1e57c7607ba2a5d4e1
MD5 de14e2510d7ec8587cb151d6f8a52e15
BLAKE2b-256 eed6bb9c5dcfec422901ddd2ca8fca856ab987c0fe47287b36a7aabfcc4a15ff

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