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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.118.8-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.118.8-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.118.8.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.118.8.tar.gz
Algorithm Hash digest
SHA256 33c8912512a3b58f9c3e8d6da49fa6ee0931731e43ed973a039b4ef0ee442686
MD5 3ea6ec189b8644182a07566a4add7a38
BLAKE2b-256 e4ac154c71247c7254dc8a5e253592cfd11a9a89294fa4e0a346d4d9486cef13

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.8-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.118.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 96315e4120bf91da080c65d76f9cc0b5bf1638055b9ae518924b80c5be2f5cdf
MD5 52c1325a964bc4a6be81ecfb0f29608e
BLAKE2b-256 50624e40950724cd5f579aa4b5fe707ecdfe204e9c2cd1745214d5ebac251147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b0601dde5fd6d72f1ed8ce146832500bbe038210ca0bcd7e1f2e64d9bf741df8
MD5 deded33d70d7c82305bc382f1ec4afe6
BLAKE2b-256 79c0782e0a76463fbc85ffae3bf7d992d3d4ab279b23ce71cdec362ab841df23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1af338f8a1b61cce9bb3de9782635cf372c3c4be19ed26701f0a1d3856f67d5a
MD5 d445d9d2d6637654e94dc3bb2b1d2a9a
BLAKE2b-256 c7e8e2f1f7d656abd5a319697c2956effa1994e4cdc70e00a1f81895575ee4ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28db7562e0552691318286c03d186ca7d72e39b98a4d0935a0f698367acfd53e
MD5 40dce18aeaa1aa73fcab37447706f030
BLAKE2b-256 0051edb116f091dbf53d29782a54d123b9348b9bc15e21fc8911b756ca1bdb45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3409ef58c4b9312584061c3fef0f0677716a31081d65ad5cab8bdff377ba0041
MD5 4800803be859686aaab2ea434e416995
BLAKE2b-256 962cb7f524602fe8e78c90f3ba65b0caffbf734165e691df806692a619a92acd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.8-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.118.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3e1221990ed35be6e1565842ed60b74555b231a7f6a86a3ce8c910edf0f37823
MD5 4f60dedd270a528321f4bddff1451264
BLAKE2b-256 78e9a623279b37d4b2f75cb451f4b60b9e462b5d2166389ecd5a5ef2f6a8c8a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5588ee7d7dbfdd7c24422c79187762f143cec483d98e68d30291206425be8d7a
MD5 db3c9fa3fd86b32d67866381d125a563
BLAKE2b-256 3f00043eba063be5fa0968e36e7e4e1c7e2c47f2f950251c677a9f82dad20db9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9a36eeb5454eab7e6ae89d4251cb6b6091dae4da3d5aae9f51e6821821d8041e
MD5 5717a460c8e56dfa7c52c9c07a426101
BLAKE2b-256 01661a70d665a1659fc4fda974aa230bd2d8c9d5299d370cdcfae1ca61f59a32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 375bcd9db8e392b503869cdf9386f11c8372863cc84331a424c15e0508de19fc
MD5 b21e1b5cb4770ab666076d894d656e50
BLAKE2b-256 5f737496d9343ce68702b523642d20ce87aba9ef6b4751facc3163927840e54b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 799976a182bf2f9a2415583bb85272039b039ab8fcf84b1d9b9e0b153408d1ee
MD5 b8cab50e8471d7d542d3111ff9c351f9
BLAKE2b-256 4cc5e724f8387083536d5842e1c09eb6e7288b2f5704d4e59b6e10e1a9c9b362

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e93c235871ef559a1ff752ecdf95c87105741f36f41734a02d5e3adfa84e715b
MD5 9367bace6faf13449ccdb007d34675c5
BLAKE2b-256 1805352dfdb3b7a455dce27e4bdd814299fe3456fa5f1ed024747e24959973ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9e350da35e3627e1704b35b13c50ad3cfa8ccb8f45954c186e30f0beadebd365
MD5 c6663a0d364825859e0ce6bbad609de0
BLAKE2b-256 14aec856d064777767ab05be824288c99791303fb02d7aa36b0fad7fb90b9d18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bbfdb859db4dec1afcb66a9960457a8ec9b97dfa937751d85b4af6dc983bf66c
MD5 2f70b611e6f54388da4a5cffadc1e84d
BLAKE2b-256 8175a0cfc4621de151c4dfd303dd94ff73b51fe5f09ce01da15b0b9078e664fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ed286e9f886bfabf8c5fae00f20125037f23d8636bfb3d15076f1b7d460ab14
MD5 b04de75ae1aac6e0731bf641e70a301d
BLAKE2b-256 6a900db1310f268f7a677d896e2d3657d1fd328ba355b86a3427e97be24c28cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7b80f48951939f6c39c030b6f26c4dc4db106dc792a619fa8dd622b1f9fb0ab3
MD5 dee7b923d8bf929255c8c0948e6d084d
BLAKE2b-256 b8954f234c304b664fd7a426b27647de7484ab4689d412c20dacbe77115014a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.8-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 41b11621a9f191b9f156f4bc7ae992d2fb4ddeafb25c032e311fbca186cb1c76
MD5 e93bc0a320c7a380ddb7865390d4ddd4
BLAKE2b-256 2078f20a339beb8d6a8d1d7039277d8cf694ab20b4892ec74f9ab10254df8914

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8d8cda940b5b9f7ffa59a7b37a786410ff7acdc7c75620a5b5951aaec76aba7
MD5 970e478cf911f910a0beda0690f9c82d
BLAKE2b-256 9c6ce41c16816dbdbabb694a606d7ddb04ba2430b369cdf1cb631f6f3ae91096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f0b5f2c08ade2c8f0039544dc302241e044919d14c10e2b1e89a89cba0585376
MD5 ce950a9be7198e1b105c5a50c98344cf
BLAKE2b-256 246beb0a1d4bd1a227c239e74b323ecfb68b983de655755df8060dfdd8e13793

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e887e0cfa48ca00efd1a5d7d6abbeae05c4f177af4c722337d72f46a891f8a6b
MD5 a115c69050837a8440b11b1e617fbcd9
BLAKE2b-256 3f5c34b374201efc32c8d6de0630a25f0abdd9c549302065515279c3df5a8fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.8-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 58d56aca27c03c02416cda0d883eb30d2301e39ac4105abb78d9510d497d21b8
MD5 e8d3d247727fea7dc1217917cd5fb558
BLAKE2b-256 9083a53c374f7e40c8f10a3b6a61f5814ca7fa64dae95f9505a474ec2cd24c63

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