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.110.0.tar.gz (1.3 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.110.0-cp313-cp313-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.110.0-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.110.0-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.110.0-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.110.0-cp313-cp313-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.110.0-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.110.0-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.110.0-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.110.0-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.110.0-cp312-cp312-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.110.0-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.110.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.110.0-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.110.0-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.110.0-cp311-cp311-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.110.0-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.110.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.110.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.110.0-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.110.0-cp310-cp310-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.110.0.tar.gz
Algorithm Hash digest
SHA256 1b4b0eef29e76f0704a3abb55170315d18cfe975a8993a43e0a3155b8bb1f2be
MD5 3d5efb590279a2b7205f6ad4cef1b8f4
BLAKE2b-256 286375830ba9224b831bb12cf297b6fb9b5d379c546a159b358c6493e4a2204f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c9b5878f5d82a18fac53166e00fffa30f563672516a929f0e1837f8890611286
MD5 37d74f6b8e42bef32e838b74da944b83
BLAKE2b-256 9cce279d33a9545699e6b6e3d76eefc98c60fb549b9992bf286ea092d10c6a44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 27c1a965aff15ed5465fc6845743f7296bf79ace6f6da78bf3509f2383cd5a49
MD5 c83f80848e219ec15fa6c6fa42ad3cce
BLAKE2b-256 d8d8ae3c56d484915711e014237ce0bb2e34c28408754a2498f10835834e417d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e43e335ce55e6703dc83cf7a83ce48ac0b17d0d74e76eaf717c4128a45d084d
MD5 877c191b84042a6b4c101e067a8127f8
BLAKE2b-256 5a8353f720e2338e4611e8e991251efe75701cb4a7725486112a5fc74ccc4eb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f931c8c279a941a02ca5edbea70b7d41c74143c8528d2c143cf3fc8cc60bd6a3
MD5 05e44eb250b6b14cb5c4d980223ced04
BLAKE2b-256 004405fe80aac2b4fa70db1e887f076ad31df961c35c5dfa103606b559e2ac01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 be5e90f707100e5011a063f5f8fae37a33efd924b41741ca1c2e2107ca6926cd
MD5 a4375b371448887c8ce5b250f24d2bda
BLAKE2b-256 449371dcf47c922352fe070ae5f3268710dee70de5978847a13e508024e426d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6d9e001d9dc4c36c05f928bba8f69953dd4bad1c503a1ab6d9374d0246fcd59c
MD5 564a029d020e5927bffb187b361ee9b9
BLAKE2b-256 dac90d274c09560bf71bbc88c251577be28486f0ce5cc1ef5788dbe7b4bdcb76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08e64c249e8f2237b661ef03a059918a05cf6501a658282b2735fc0b7361efa0
MD5 c9243ca82f9b11d869994780eab31f1f
BLAKE2b-256 ea87a0a3c61b69e870d6298c826cb180de0771379713494eb32b5ec5253d35fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 09afe8a04e19c60201f98a0b71297fda136d10b8ef966a2e3c3121e762a27a18
MD5 d64194887b1b1332eeec9ed64eac4a8e
BLAKE2b-256 f79e1b53b8f0e39a3ca3d1eeab6014c143b58b4f1ebd5e213703ba6f12bbde47

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8a68ae3bb0b7e99f5af99e7962716b33af1117a2d3b76f2b644bedb74cc76b32
MD5 d1b6be71127ae59da2092a37ee084077
BLAKE2b-256 f3d4b1b42ec6179eca1234e0d023cf90b53f3484412978f66e2c16104229ed38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 192617606a1229a3e175a11a90eaeebb7e4e0d25125adf8c50885bfc78a79d8a
MD5 f3e83dcd85658f7df22d37d863ed6c0d
BLAKE2b-256 79f98c07a6be616d8d502b54e514e07dd0526e3d719090800c5cc1afa106200d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2079e47925caf40b411c87539bab1f353bd50cc0d20b5da7b1969f7d467d5cc4
MD5 957131547b96e1efe21edf94cdc6c19e
BLAKE2b-256 09971a0001572aa0fcf17439ea408bf1f6a163a96a6c6a711e3797b288df7207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ebcd0f640e6aad4ca286bf2c13c8b254d8eb6a7126eec6703db8b395f72205e
MD5 771dc03522d3a3ee2515378ce53ca074
BLAKE2b-256 a4f110ee9ee4e750102274a62c0a56a2e7d6cc30f67ec9a7208e653bc0f02009

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1adfb01d8cc922f2a7a8840a27aa64a54220e4a7ac993f7f0622eaf38c861228
MD5 d1ca40fb3c9dff0f80ed59d195ca9da3
BLAKE2b-256 f7d24df4621ef73f84ad8833ce7a53f790ecbe132909ee312b39d6ec90ed9f57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c0b689c4f8de3ba0baa7c5bd20d3c6461443ac40627ca2b27fed84ae4aba753
MD5 9eab8194321d6dea2382616672f35de4
BLAKE2b-256 7eb39d51818d946a4fcea7dcabfa45f46045d23f15b8b10877e73b8793ed25b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 aca4dae54ab5819b6de54b30c72ce6c2f4978f1140b0b19b4cdb441510611599
MD5 f6fea2ac0043d03a762decf195024d7b
BLAKE2b-256 6ad703e7ce6a34a99aabd3324ebdb47fa1527cc50c32becd56107403625e92ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.110.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6db63f06a126087276ca5be2153fca17544105be383f8a847f188428975ea17d
MD5 1ee4fd822e72dfb3bf740f8885a94e05
BLAKE2b-256 d97321a92f93069855cf0feec892234fe73ebdbeaea6e6a9a0b02b39e8c44764

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 551d0144210b59dd003dd8621e0011ad30b13ae9a2e0ecd8bacc5ad604d2842c
MD5 2be34b30930531857532d9cbf71c1cbf
BLAKE2b-256 97f184f791b80df32ec00cdec63c70c10750f7e3e543a6648d47fbbbe77aab4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 956e2bc4be6b994b217f785dbe4c13c9c7097e439902298f5f7de0bcd8eaccb1
MD5 38a57b722d63b31f74cd5cc6755e2a33
BLAKE2b-256 219bd003935168ef271a9d7968b0c34a112a86633d2b4173fdbdcf720e762443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c05d2c525b37b89d7af0048b55d5b1f171cc54d9330b2ab22b15639e544c8319
MD5 fb5994060d3a8d645f58bb87f26fc652
BLAKE2b-256 43e3c5c77e6a7333bced3de9c338abd6f7a56264498b781deaf7e57fa3656986

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c74007c2b229590c4c33f47d7adefb103134690a213859de7b9efafa2c6a57b9
MD5 ec5b84a8d7b7895ea8568fbceb8407ad
BLAKE2b-256 4aca40f3dd231ceca479eb91d1e05d81e7189281dd3c117d475fd9e3f7e3ae54

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