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.114.4.tar.gz (1.4 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.114.4-cp313-cp313-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.114.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.114.4-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.114.4-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.114.4-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.114.4-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.114.4-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

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

File hashes

Hashes for chalkpy-2.114.4.tar.gz
Algorithm Hash digest
SHA256 5509255e6ca55af5c0716441ef51d3e9731b12fdb3161cb0d2153062229d5e02
MD5 664b8e6e15fbedf0ec3a6c21169352f8
BLAKE2b-256 76e08e7335abc6a266c72f7c03e1df77f06029798bb73810a05af629daf4a93b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.4-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-2.114.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a2d472ff5fd53aab18f21bd38b63518caaac105b1da75b86e5179a9aaa00a42a
MD5 686e75a82c2205e24e85431d37a30577
BLAKE2b-256 66a3e22b39e7e0155f6f6e30a83130107599161fced65827a372b77ba1c629bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c929911123aea412847c1222cbe47563bf7d58ee19595af9157625ded15c80b
MD5 0276870bd3e01b334ad1d70b08074d41
BLAKE2b-256 1ae1370434767fb534a1100df53303a90209065b9f9bffe9af1db3958b1a59fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 632bb8ca3e44e9213ec8ccf84b2cc9e3550ead63a0224a4a1478d609d66ce8e2
MD5 e145a133bcd3dd816f3605345ade1752
BLAKE2b-256 5ac333c2998a630bbd96c8e6aac0851d954ffab00ab8e069e86ee4de6968a904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1f7950a481b7194b5d0e61ecf5f4ca93264d1e89f6102176d7197c83db5d408
MD5 7d397420006318361e881e759c96fc5c
BLAKE2b-256 4931978bb35bfa988bfe9c2ee37502fed69d60b4a136210531622cceff0abaf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7d4bbca6221836dadeda44e7ff5097527ca7310ca62c8f7c980b60347cacd041
MD5 803ba798a680dda70b4bd6602d1f52ce
BLAKE2b-256 b926a814d552c751c08682428c6f8f35a6835d8bfca106fd8682576cf6d0f31c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.4-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-2.114.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7c24041c395e96d81de783c97c84c620f4d594d1ffb92e8a758841991a7f07e4
MD5 3a27f2622dc7619f9800b570385ca3be
BLAKE2b-256 bb3b70352dbcb5575f5b60e2721ef8e8bda4c9616c848e131d5166d4cde091cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6196d22c41c658cd39418611c9946636c0f53832cb3b71cc138555e882297c3e
MD5 29274da6c05a697ff8c509a5eb205b01
BLAKE2b-256 0eb23d3ccb33335eadc657787681a76f7c61128cfd54c317f7e5f74be5fba806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ddd7bb5eab2e375153e27cbbb93f4872e61da0d95e57aab973add45a1a374753
MD5 497f3f70dab7b656bb977e9d973d39e4
BLAKE2b-256 d1568e8d3ef28397be57c6cf39bc08b719c2c11d697355ede17128467659535f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9aa4cdc33f101a0112ff3541e6d7f778ae12cbaf064131664801ac02128ccdb
MD5 0a44b7aba701157b74d2bd6ecc1ee69d
BLAKE2b-256 3bc770812ec5fea6aa27b82fba1e6b8197b5f6a6933a98cf90c0fd2b0cef2994

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f34738feffc23bcfcd02fd8352a08734d9c5f71132700bbdbb2c72d4518f5b74
MD5 d420352cb89e9cef6577dad8e01b5620
BLAKE2b-256 0d827980b3e70a4caf82baf0bfa2e56593c6dd62435a85e8ebf308704ddd8ba5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.4-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-2.114.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 060b7da081f1cda6d8a5c3c3afe075c5f9c1c7860ee1fba4b95acfffc6f63a36
MD5 38543a37227461ac86bf864c2012e888
BLAKE2b-256 b2d745609e6f74e791eab68b698360df22161fc854a9f8bb9b5a3954d10482f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ab700dca719b68312abb58164d00353f2341c0cf17e0f9f510a164dcb6343866
MD5 b1d49d004d143110226d47fa12263556
BLAKE2b-256 8c348eabb2ea79164128a56db9316494b9211e9fc8046280ad5c754006c64884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 911677f62ca9cfd68b45f92987e55ac12e8731362036f16f60ea2d4f1049a8a3
MD5 aa2c7c99f50cd6ec15659fbc25e5e043
BLAKE2b-256 2d55dd8974a22c4f64264fc40564d40a6a6755c023e6e5dfc3af7e29e239ff6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d1dab4b3237887d153797b33ee26f57e66dca123113fee3c27f7d649a12ee27f
MD5 ea04a9de92b3a073f82fb88f8d13f432
BLAKE2b-256 e5a99cb44fe7df6b72a7491329b1cc474b5ac3fe8c0e7e11ac74c6fefdacd691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fc928d608824f24c9374ed9543d065008376ff3305d4e1b6cb25955f79fb3b50
MD5 6a1c704392dcf9cc95ab915e8943f604
BLAKE2b-256 fbde9adefa15fdc2c57791f6ba31aa1b714493b5190959f7afe185c220b63782

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.4-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-2.114.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8463bfc5f14c69f9050346f098a4cf25e071a1488dc834c0c1844cc6615e11e9
MD5 2a6556d3c45502bd85e30e7482372977
BLAKE2b-256 f89128ad2003391651f1cd3ea8bd8f1efb6f13e732a7c9d18515aca1c9a346b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 79f1f73168468ab7bd7dbbbe9fd0d60bd68ff3012f49fc12494b527215ff5af1
MD5 d515cb00e8af3c9ddcd2a793bac47e89
BLAKE2b-256 a5458c2e961fe7357e0b1fac415102fcef4bad24b5faacc0ee7fa317c58cb6c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f6955c8885f961be20dd46ba66cda7a25d63238da430710ade463c7f0152e02b
MD5 ee5aea1042e906109926bd740ad1bb93
BLAKE2b-256 37f7cd94aedc993f8e61638c48372b989800f05a2b607ee2d51f7da490c4c0ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0611eb8f1f1d910e15ee84415b7170c5292be154beaace126d8ff135197bbd8
MD5 62505c39a8f7da326d1790face67ee23
BLAKE2b-256 162d28569b248e7b486ff696acd8780d062671b54a91b2871f2416410c121b91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2e4083368b2d8c94ebdf5141d4fdfd5637b4e7314b7538abf64760e67cff843f
MD5 a4db25f8475ea75a098b0aa29cbde176
BLAKE2b-256 6f260c951649bd1b72e5e46dfa78c5df7688449edf0669003a9a3777a4051d73

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