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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.20-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.113.20-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.113.20-cp313-cp313-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.113.20-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.20-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.113.20-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.113.20-cp312-cp312-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.113.20-cp311-cp311-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.20-cp310-cp310-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.113.20.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.113.20.tar.gz
Algorithm Hash digest
SHA256 9f54cc0d967ad21fee888da636f671d85668b13e1d11d755d804b350243f04a3
MD5 d640f2777ee9b11b844f1d291e987fac
BLAKE2b-256 4818c41d1d78cfcfe8a07856c6454689b8d120dbcac9370b9311cff0e8491d30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.20-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.20-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9b159959c54e02e8d91ba27956cb56bb4ef908434e6d3e2ce7cb0d3eb0fc6f28
MD5 a7a24bb541a09baacaad51fe45411bee
BLAKE2b-256 de42af7aa31fb4c3d6cd9f8d28ecc6f49b1867b0408a87945d5c1b99ef473c29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 359c4c424d2bf73de6ec065caf05c401d24e856c8914078a354955eff7749407
MD5 138b04302bbccb99f0da616e315f7f4a
BLAKE2b-256 78702638b944be78497551ef6fa29af1bc1dd139090243fbedc3df1ff23cce1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 412938c96a966bb9dde58b7f5ce23b2c2b477cc2b97b7ad2c2ec1b55ee72f8bf
MD5 4060d90fbf874c8f0f67a550d951c06a
BLAKE2b-256 3b186465d72d7d2492df0346ed5ff0e1dfb3d0e8dc2bd53f8b03aa4b5a28faa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f6fdc423566e3872b5b9e404877d8696b7cd8d955ef072c9747c934b31d29c7
MD5 bc655b1aa4e0ce919e945622e13f908c
BLAKE2b-256 f2dc5ec26a651165f44cac6dcdd5aa770b83191d7819f2a4ae3511e9d98d49ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6cf8aaaa2c8e9e4736ea021d5999bbeabacb08e6a10fe5861fdb7d5b09020131
MD5 c12f05bd2e353e3b0aa26536c9d2c502
BLAKE2b-256 57f0b8e03fb19fa56b1479d98e7ed48dda58cfc6957189e3c33114233a6aab79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.20-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.20-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 84bede62621fdf724227c5535c8d465872742418e589f8815ac933a9e31412ad
MD5 166d4a504bca0f79f36233973f033cc3
BLAKE2b-256 ee2f4d655cfe812d29c1d264442334b904c3a15534e44864bdeb9e0348eef932

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d0370e0c8ffec3811b45f41cca0c7b1b45772371d5ea9383a2b952bbc9c31707
MD5 c2cd5a492693f7cb3c6e34b7e0b97dc1
BLAKE2b-256 b32819e84962e1033d0d81e3a4f309cc35cd90574f09267fdb0d720ffeb047c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 22047fb6a6e58b638f2fa5b9f81309b70091cd5d66516106a02c08ecea2450e7
MD5 a6ebcb7adca3c5ce577e7aebb1cd6e2e
BLAKE2b-256 0ddc88ec80fded28f612e187ee08d14d93e1fc513842c5e7ff50c6fe8f2cf81d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a5f43fad7a16abf88a6470733bdc682fe0526a507cb9e96ff4f144cfc2e7539
MD5 40d0fd4ed8c2084cf94a7dd424e60f18
BLAKE2b-256 661b312ec4584dfcb40f39560aec768a2f31562df4207411cadf32e33c756988

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ac05f341c78c1d011babd4fbccea2525cc1cff95aa3366f1e49c26b37aaae715
MD5 b75325fcc1d3128f63e596ea8da30982
BLAKE2b-256 4507d122ddaf304e790e4355070a86ef970f4b0d6c8a73e161c99fcd53b3f515

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.20-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.113.20-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dcefb7c75338a282110ba43592342fe4b73a5c80f36a7ae06078d653b005c8d7
MD5 548fe208d44bf5a18bfdec36c23c726a
BLAKE2b-256 08771939737efaedbaef4aca17deb61bb0b684425ef0c3557e78fa8a9a636121

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 00c036822c3309f077869027c160c7f747cb4551e4249bd5f02b8885f5a2e8e9
MD5 46798bde5aee3469f38d3b979b2551c5
BLAKE2b-256 97282b7a7d0527df47789896e9fc263047a70dda8e024d1e5701e589aa52f401

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7961c586744b3393c78f22ab38c2108aa75bc78998910f58e67838d9bf51481a
MD5 713872920335e87852dde5af265f62d2
BLAKE2b-256 b283209b60686f6843d7e25e9469a805c950f86914db15a76e40f73b06205294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d11ab315f8cfb9a3772d18cad0d4b37b4863c4bf603cc0487fdbf4724d4bcc6c
MD5 5bbe66df14916673aa9ad007e8b53163
BLAKE2b-256 39132b8fe0989ce4f2834571e2bff2a503a2fde11d94348c63a616f16e4ca543

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6b2add798fd904b1e573e06e712171016d63595442da8be258bdeaa4daf54e00
MD5 b45af37f70f36be901cad8375374faee
BLAKE2b-256 d20cb9fa1be3dd6f3269717834a0aa66b3479fa9e5ea52376498a41a30bce632

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.20-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.113.20-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e0e8eb30bf3f61c7b2ee5b49a093f25021122ff871ab6a1fa2f799a286dce99f
MD5 06a7eb254a789ea3a1746425ecb878de
BLAKE2b-256 b1b9a943c0e088076a630077e1d19f9335bff488d43bcd6da10e448affc7a952

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ddd844ac86f6792e460dcb54a47609d4739ac63b4f976bd0e80f1c4ee679065
MD5 f6217e63ea6768a013ff7c8727692e0a
BLAKE2b-256 b929e987a1e7766f9358172ee10206bd9437dde216dd855f4a8e44135068c8a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d81f0ce8b0d8ec50ae11eebe4bbdb0f308bc3e244512e7742d5dc912cd3a39a2
MD5 4ac92cd5a7752641e9144ca097b35b02
BLAKE2b-256 ffc52c573f0fa4c9f0c19b9a757ccee3202bdd667d4647ae217fc8aede9ffa71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ba1ce86c5a8b38e51c71ee9a0a8712a830fb57a68c95ce3b29dd00b4e54db336
MD5 c9c1310e6cc54a0f90e42ecf172f31aa
BLAKE2b-256 c67788ab78efb05f1eb0244150441a8c56b3737d18cc6f30994bc336afa79b7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.20-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 64dfdd779661ef0a943979489df4402526faa45bbced122e9b2e661d78bacb7e
MD5 807ab0b422a001e654c8589871e7872e
BLAKE2b-256 da4bbd4a6249be5e3ae55635e111d585df30f6494ac12f0ad62c27efb9d1b103

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