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.123.5.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-2.123.5-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.5-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.123.5-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.123.5-cp313-cp313-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.123.5-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.5-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.123.5-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.123.5-cp312-cp312-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.123.5-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.123.5-cp311-cp311-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.123.5-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.5-cp310-cp310-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.123.5.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-2.123.5.tar.gz
Algorithm Hash digest
SHA256 2b091cbd1d75b029b2584ac3aca996481f08a14701a8e1226642f55f2cf12012
MD5 d0261088b9ae63c6db447057ca1470ac
BLAKE2b-256 0dfaa4dac1e3591b31e75deaa595db493e4d30c199fa27374cb1c8758a3ececd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b59c68fe8569e8ab8a7ae5a42204ddda100c95eb46aa9ef2ece42b8f62fa3bff
MD5 220d124a870f512864cb945342899d5a
BLAKE2b-256 94f795020eedec5217a782c5f294ccee3470782ff3fa1a3f910c6307c8ff5332

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08f5b0bad96c9e54067b5678c829214e3061b920751c0fece36a198c4b6ca419
MD5 fb4f765ff5df2087d34467a7a177246c
BLAKE2b-256 3037fa41dfd5c16d81a3f800be54bf6c0b3c2fd3c153702ee27159f894e3ddfb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 031b215a9ed84820d87fa94a79e6c428b92239157c7cba620f6286397063ade1
MD5 46295e3d6e0365bb14393c417739aa06
BLAKE2b-256 a79caea094c077b5852aae8db306e065da212054642fd1310d8523104ecf63b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90f623cf96ce3f4248717cca30ec7de4f81b2f263750e9f4a72529c9bfed3412
MD5 0bf3537ccdc72ac047b719080e213dce
BLAKE2b-256 2f3fc71bba4ec5afd848dd3788f72dbee7784c1792f90d4e0049b10d85eaa990

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2a0e50bd9866c63c7f32dc11b797222b840bbb8ddc7ecae7fa6487e5df58c37b
MD5 a7acc25ebf020ca916ad0ac320719677
BLAKE2b-256 6977101e07adc2490f506a7cc32af65aa6f6397f78cde9417502c53618093fbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.123.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 523c04e34c05fd6ab19aa846d18485f24ea28a380575d041b4e5e34593e52533
MD5 ac7281178b9aa3019ce98bf20a23bb82
BLAKE2b-256 23f8a166c7c84844cfd412a8aff1adaefac31d0328a6e86a7ebe3de2033a32b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 332fc710c94b05f745537b031c8b77d9e05e9112240f798b0772c15e3cb68928
MD5 63519a4db8e161bad0bae61e059e8ae9
BLAKE2b-256 a6fb1e2c755df05fb77ae4cda05b0e7131da04a0466f544be4c8e510f7d713b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 49b00c4b8f46bc8b479c4e8a3e41b9a88d704a77f8538ff8b4ea838bc91f78c3
MD5 865eb87ee9ae6516c1313bb7997c003b
BLAKE2b-256 9fe470b4bccaa01a9c1020f0154254039e34ef1b832d9c1dd9f8995ff42ebda3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9734b791b0695aabadd96c1c5ba0c968ceb17256103ced706293f9ab22f15542
MD5 b0e0cb80e165b5bf9dd586853a4e9db9
BLAKE2b-256 32a23cad9f06da51f6f57c392abe917ac666a7879ce334707bd0d184aa499456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4ed3765653d802e5e2b19667d56d1ee33b54b67d832ab15afe50eb611147db63
MD5 36be24643b7e63ff4ac770f6dcce1453
BLAKE2b-256 47ad714f74ce8b9457c03a7d82295130297365026a67b69facfa684d688f13f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.5-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.123.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4deaf61cf0ff63662f0cc5deffdcae002cf5ee745d359e9763ba34d37869b94a
MD5 5421544496cfd7df3b8b52ff45b5512a
BLAKE2b-256 68b76a2a8f3a6fb99bae03b71c36d787d18e0c04bd6cf98543f0956e0675ded4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3a31390a36f53eefba45a70b1c3dc4a33f0c3bee66c9ca4d0f80324d7f1598a
MD5 6982330bbe6392e6fbddbfe082ea5f8c
BLAKE2b-256 2cc184cd52712bdb2c1a8fe7971b7e5c8be71513f74b485610f89d9d565c2c5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ab6687645e1ffab08bbb4269dc9dd12e27eec1897f2eebee091219daab112bff
MD5 a8b7e699af703cab178fa2ff2cd9e979
BLAKE2b-256 bd6049ef08dfeb7aed38dd0efd2c07ec1a7945aae5ff4710f8a9dffb71994f42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a1d1cdd2fb40b81c00ea9039a58930b54e01eeef3971e51350c927833c7d955
MD5 a2d977f7a388bf49fe906b22344859c7
BLAKE2b-256 01f38acc7005149189a616e88ca4377f53a518dcbcfbcc9cda62503e2e92a945

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 51aeaade17d7064514a1e91d18991288a48c44a97148ae121a71c2b37220249c
MD5 f83f8526dacca48b6d14c163fd956f4f
BLAKE2b-256 e49a3eddc4af37eddd89f12614c52732abd619a2b58aee14dde4292d589700d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.5-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.123.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1ed8f2e94a7726ef868ff941e2aae473038fc5f2979a8d917ebc421008b952ca
MD5 98de26c402e5534aaed330518567d546
BLAKE2b-256 075ee12719346f1fabfd9e578d7afde30b9fa46a33741760f99ea510458da06a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18464121eac866179a5843c80f01b547c5fd499bde6ac1dcc332a1f42fcdfe17
MD5 ef432c7d421493482dc17d2d9ba816e8
BLAKE2b-256 a46c5edd9b0038410d8b73b92be601505192fcb00e0667f841651948cb3201b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 42c99c388a40f82013bce4791b060afad252f956309458babe4dfd252dd4163c
MD5 c564ce9fd9784fc337088eeefbaf6e5a
BLAKE2b-256 98aa887f63926a9cfca5a0aa2c7e47a3751a344fe668de914fc12e2354eb9158

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c97db54549052969b45d50df927235af9d8e19ea993414d5cbc206dc2e40196
MD5 5ee9dbe0544384486cc2ce2e7ba7ee71
BLAKE2b-256 e4a63908abe39ec0a13257383f22726f237f58a3fa5cb2de0a29ed778c208586

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 96dc491157d3e43a787961e98ee4198e69e46b9773b1caa967ab210d30bcd935
MD5 bcb3a874de4bc869d4159db905f8f886
BLAKE2b-256 e0cde8ecb190896e427f0a137bee319964955332f5653f82e605fa7cd5fcff79

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