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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.115.6-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.115.6-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.115.6-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.115.6-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.115.6.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.115.6.tar.gz
Algorithm Hash digest
SHA256 d115529b29b974b3847edfef9a058ec3ee3504a57ea198be00baba581f843754
MD5 3beb2324dc42b9d947cdad8ffc4a5e71
BLAKE2b-256 be8cbb6bcf958b3cd6b9caeecc7dca7cf1d7709480bdd6795884615a97e3c4a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.6-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.115.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 55cc83fc52d5493ec349a6f1a0b3cad4adb4d4cba62897aa39117d9a561f15bf
MD5 81e5132e0fe5df3f6d91d821996ddf7b
BLAKE2b-256 e8ce9a92b6df4f283fd99e1569b6526074904fdb46d4c5e68e712979af25f8bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 682874db846eb68ed4a23ed6c435d481ae96f4334b3e2df884a6b4a19ce49b5a
MD5 a8464a26d11411181b48ed5df9d60614
BLAKE2b-256 2cfc0ca16c8fd2e96270af58409f1a8202d7b37a70ad3fa0ef3f356cf6967b0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fece4a2acbe8a5d261cb8c4a531625e46061b2bf9dc85438203e8c0c8f8c1ba5
MD5 3abc95e052c1613f0301ee61c5ae7bbc
BLAKE2b-256 1937a1393d5cadba05d5b63ef5334103e94bc0d459e83b8fd23a671c809bb994

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6dfcbbc8941b0c1f24c39e7dbb038a0ccb657a38f05b60e0ecfcad9c34e217b3
MD5 4bc3071b7b3ae07d44018c8558f3802b
BLAKE2b-256 2ebe6f1b424601024655a311e850fe7d631cd7e8b1e174e0fce80bfa742597bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 917db3d1cdb734851dffd46e38e3580433cdb07917c684c7dc9d24b5b714fee1
MD5 613e3643a3f343b118b00f947fc98e3a
BLAKE2b-256 8ab43e94b9a1b8125b500b8a2e4aac1654877532bec4c89c7a44de3d444221c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.6-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.115.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 510a42717f81b5707442671109d7674f76aaa4ab251d039e3774e1cd7522e90a
MD5 b064214d4f69673f638e72e9552d6a7f
BLAKE2b-256 6ed7a402f36f8189172eb9c78a00db3574ea9a54ba333faabe1ea0148506a738

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0c27ced6a65193e04f8b5f73397d3d69b5ec9079d40869e16ffa70aa89c0f10e
MD5 173fa6014a4cbb17227d9bc329b81fbd
BLAKE2b-256 1eb15e037c3eeec2c4970a4b083d700a9d398b4e986ea8565576cd8e3058f8fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ea1028ccb122df087115b8b8576dc64e66c9cd2c0ec66dd396531d7c2fa3e823
MD5 e392fedd01c101297efcb371a19f740b
BLAKE2b-256 71d44c49f355468db750c4cf3f3e14d89e4e70fd4ca6349e8b7d716dc8a8dede

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e34dbe9b77b7d4132ac14e51db8b0531e6aa3afab1c1492104c679b2ab2d667f
MD5 907370a691d9c3054192d2b8180c0c36
BLAKE2b-256 84d18d1c4e6c5e405da55e4ed0dc65fceffcb9befa41a13ef6bfcb085745d8dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c2cebaf104f671887b923593d0b2fdd2d2d3e55c054ed271533d25355e470ae7
MD5 ac779d322c378fd87ad6ae0cd859d66e
BLAKE2b-256 6c75ed7f02b7ecbf76c78876ee8b8dd8603aa0c1da1d1a1e8016a71c9a3dced1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.6-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.115.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 25fe195ffbd4e062e55e5ddff4c98d046cb9d431fc8671af1541d671c8f78421
MD5 bf60b012f25b8094d1a057119c61275f
BLAKE2b-256 9ef9f81dd5472eda7e7a9a9e1f7f1cf8a8661243b32e3f452dd15123bdc670e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d9e01d79a1852e56c9d85c4865a9ae66e51b7f278bcd15484c551ee850299e6
MD5 f439c51c3c46c70d5a4ea301c1f89ae3
BLAKE2b-256 459920f0bf7ade7715f7d692e50f4377f0ee0d2a364edb29762f0595014bb6a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 351bd9830357362ad8d8cc6747356a3b745bf0f3e0005e90badc0a4e36a0bbde
MD5 096d0470d8f4f3a933bc07cc8031feab
BLAKE2b-256 bd5b48e708b65e368f78bb9974371b8bd4d625166b3319ab59ad0a15ecbc1def

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32e823852fee2910487325d07f6400052262acbe3699a3e606e2ef837241bf2d
MD5 2a0f6d074e2b9bb1b2d893b531fe943c
BLAKE2b-256 1619ee88c17942f4b5e8127a7f8f6ba774205a38c865fc1b9ffea3effc804e41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 292bd1e1d6fa636dc8311a48d7f2c3b2703b6849fa74db66b3b5a4a99dbcf139
MD5 0959e4ad054e71d6b84adea7e36c91cf
BLAKE2b-256 4d4f7dbee52d64845fc1313359650787d21035813e42645753e5b83fddc0546f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.6-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.115.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f56a405aeed106720e22b8218027b4f1388ef32daae38b4ef1dab8dbc8f7ee5a
MD5 ebff675aad12e76bde9b82df0c472a0d
BLAKE2b-256 edf64d27250c4e5bba9f89a01326e4b1e07d9b33b32664098cc40bb5135bbd9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2bc9635ff380d76343e0cd04086833e97a237d53ef9d4fc727320228733ce23c
MD5 91d054b3b688101c91339bf945b47016
BLAKE2b-256 057cb3970828d791f8d1ab1d0dc737b685e7e148bac9d38978ac22e11588fc33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 36dfc2a5e1485f1ebe3f22a7fcf67e21eda0c17e0c8b8c1ee42cea5f2dc67795
MD5 08398891d4895746df4a2423af9697ed
BLAKE2b-256 fd6a0eedbc380767cef4473e9354e81f732b32a27e8d58555f891342306e1281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a5faebc742417bbd56cdcddd8c9f84aa6a4230b8ebf98a17700f495e7c69527
MD5 e560d01359f5f2b270d6364279683b06
BLAKE2b-256 ffd2594c05bd27ad8b6a0e9ab1418d5140bff40aa56e9f00046f048fe96872f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.6-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 33c9c3e479db4b22a6ecf71b55d3a6c9d2cf7343fe227a23fb5ae1b9e0145f74
MD5 3224df7054c09d5fd8f34f812273343f
BLAKE2b-256 1968159d96ad678511ac6a9c05582751658ce722943222257e747859f781fbdb

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