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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.118.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.118.5-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.118.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.118.5-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.118.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.118.5-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.118.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.118.5-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.118.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.118.5.tar.gz
Algorithm Hash digest
SHA256 eecd55838490b03149184cf341561b9e447fca43e60a9ffb4720e4a16b1d1ce3
MD5 67204a1fcd280fafec6257b4a283ebfe
BLAKE2b-256 bbe213579d771b7012b52e2448661ec6b5a2ac40ecb2d3aeb5c0b91492653092

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.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.118.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 af7161234f55f3986be1328fecc0eafc111e3e0d833f535b516fb7f73a061ed5
MD5 0d84fa7646891c6a6fadb2da36232c34
BLAKE2b-256 33ce83748046a0218ca03d2a6ac929657c14f2b640965cb579af944f2db2e16c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb6e8418abbdac90fdb3af77c0ce69cbdd27d4d20e16e70c067b7133e09cf55d
MD5 cda5ea038811c1eedb95560cd4086d95
BLAKE2b-256 ef56fb62a37ecdd4e347b5e44d565d4bef873647557e3df4c39df19a3e842805

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2fcf6a4f773d3b309da314ef019237d324df71d204d40ddcf296533424bd6043
MD5 3cccfe6f7c4b99944b7a3f92352fda27
BLAKE2b-256 9ae6eb2aab32fd6e806ca16a4eff3af96cbb6a7e0a7fb5809890ab2092a8f9ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aecf4f952421691d1e03f6412d14d3147517d1c4cfdf55b456923b18aeb1423d
MD5 a7b2dd8d2cb41dfda52d6d75006259de
BLAKE2b-256 0163fe3690f2cad4a0ac267b9fa4b507f79362d9d613aa1c59c4a3b36bf6ed7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2b936215278ab6bd594ddb804dc9ddce848ed16ad4113cc8466e7d8429343c38
MD5 ade7d8f9c35cb9ec76a9360b1a83b858
BLAKE2b-256 68cc71d4a4ba61a30569fd51a10a43d26cc94046248edbfb519b2e38570eeaa7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.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.118.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 576364fa747339a56ff77af054dc553b8cbbeb6d42ae9668002868251eb2f9e0
MD5 13a9aa131f6740152d575465f7828505
BLAKE2b-256 6511191ea6fc6a03bf581191d916c3f4569e8ea373bec5cea0845443ca1081b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 40d9b9a963d6c97c55eb11dfc0a9b56010bc122ff21a498b587e74ac9a44d946
MD5 6484c97737ed6346c1af09ca6c3e74e7
BLAKE2b-256 c87a261af3e805b089456c83cf206ef914a4375f397e245f7cefa22194dbc739

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 823eb42859306ed8c52424124c19af7eeb0b0b299851a421053d436e4a85c039
MD5 7329e19ac4d4aa38442be2a9500c2b0c
BLAKE2b-256 1b15ae6650e3ccd9ff256163f692c7fd981203dbaa4d5013f2cf1eff90d06945

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72fa9a04e5538f6b46b7de8392f9843a95b72c0729d4c9277a614cd2e6c4f19c
MD5 b3506a72fd890110c12407ce30fea5c2
BLAKE2b-256 2d48134af547772f26146eda0c774bde970693419b94718a037a91e2594feeca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bdb3c2f3c9156c799036acaa57065bf79f93a1c7311d1d7ed89e43cc6d1c1c5a
MD5 70fe9548550b9acf52e75e3af74cbc60
BLAKE2b-256 237c6751a0db252ed62880c0120a593c12153ee9a89fba2f7be36275bfd9f482

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e0f458efe3ef7599b38af2959ec122ae153267943ba89e921bfe52f3145b6aa2
MD5 6f882636e2cb9aaf55ebff47455f8a3f
BLAKE2b-256 8b9a5e6e9539fb2d6888925fa2d3874a6b3ba5b69d5ae256a96626a119d0487b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 73cead912b5e7b2b5a628e4a11ff675190d7ed83626412973b1cc6f4a695c4a7
MD5 b2224d4180b54498b00ff03685de6e93
BLAKE2b-256 3ee5174bc4a7d7c200d9bfb5ab41ef1731354fe3f539ab52c5d3f5d1399bb78c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 129228c0bf73bcbebcdac32831a3125dcb970b905099db5c16f27c93e621fd1f
MD5 b78e758db7c53515282bc79416ac9979
BLAKE2b-256 fa6afc24a89b5b4a59ac55b6d147bc27e122e0971cd304df201175131ca34ca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 148118b9acbd518d1d438be63b8021ce9eabf27d67290f42a480a37bc3bdd97e
MD5 043eec370f274e5c214103cccf48283b
BLAKE2b-256 279a30e6220f92f13e89657ff563691dc7a632d27bfee3f496375bbe857f6f5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 69c17932ae838227dcd80086b4a229771514450642ef5a09bcb165564c03cf0f
MD5 103c54e39d417aea7640edb05426cfb1
BLAKE2b-256 057d2fea622b0708fb97cfc0794ea1de12ef15e53123058298c05e6afeb7325d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.5-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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 faf2d6b8c618fe5a368b73e25023289db3ab22990f1ea0ffbfd8109c810f88d2
MD5 46423bf32bdbc9ff217b52ef531e7158
BLAKE2b-256 827c425592cc39e2ba79d1dcb9fa35eb7db8e00053c51bcc04d5f4241fdc9c24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edb45bf3f6aa4023315b67a33102885c7483473cf904d7841ebfc07b43f1d561
MD5 dee547078a2dca55698af3089cd6df95
BLAKE2b-256 212932fc724aeaf57d28946f16f5f130992b4444acca3bb28a9987722ea68961

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 300175bc3699a0e62a12173357cc7b81ced6025667ec3fab12182528d49544ee
MD5 4dd103557d70cf23680637dee575cf6d
BLAKE2b-256 051ee911859f5800b89ea2afbdadb0f03b97e098eadc65a9c48a74adb8f279f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1d9eeec31af3e5b449c31ed83a98014296ed6f18707a03a579fced61b9df392e
MD5 c99e765e0ae7925e45d3be074b8a313f
BLAKE2b-256 16fd3c57a640e3df9ef89b6e22d403220226ba60522c9d5c2fc21a605cc85f34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6d00607e58a3ff54b8acccb52e6be5e83275130f066811d78d8c0240cfbe1aee
MD5 83d13b966e154456317c50c571fcb48b
BLAKE2b-256 9455440d03e49eb21e3f7c818cdf364f1d808c4abbd633f39fcb970ed3fba7f2

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