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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.122.0-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.122.0.tar.gz.

File metadata

  • Download URL: chalkpy-2.122.0.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.122.0.tar.gz
Algorithm Hash digest
SHA256 1e2fdc0114464643c3ba896d059944a360b199f46510478b163f78aae22147d9
MD5 f79fedfc8993552871c291bf9c428a73
BLAKE2b-256 66ef6fe2bf3cecd11fc963e960b70ec7793bf598375e48eeb4f36e60dd75ea56

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.0-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.122.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4bfeee2146101f955272b3bf50734b1aa185e37a46523ce0eb328d36c5cbed5b
MD5 78263fdafdd9e8c4e6ab21f8aa16b5a1
BLAKE2b-256 f7cf0bb0c2fbdc488e14ba23348e165f08511210bf8323cf06882594a61bd1be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a55eb532b384dacc90fb0b690242cd73255ca20826eb6f03c11595a539aab7d
MD5 19c56bcd1c6bdecd0e1dbbb6d07d2384
BLAKE2b-256 4a3f6792088315a63ca7a693498de9ac53457bfa403ab294f403fdc09e2bbde3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 09961b07f527e6cfed1e2aeed11bc02a42342a37b2e619a838a8475b7ce7c706
MD5 fbe46c74afebee77338c25ac1c7e57ca
BLAKE2b-256 e648579256eae64ab9f6085d21555144959946b849a64c2821d65721ccd0dc27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 251a1829bd096148e72ba59feca3be6132a58e91dcfecb2c186d829476ddaee8
MD5 73dc080590a695431ef4deca90ac0c3a
BLAKE2b-256 50f1e4d3cd16dbd7f01664f570b432b4752cc57d3cafd9ad46845ffef42224b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 092f403465b31040ca975d7064d9ff5c6818b4af6534606ba171f6e5859bc2f9
MD5 28b38b0e5fb1f8396ba7af659edac6dd
BLAKE2b-256 69306ad5ace0ef414ca0deb9e0689fd83b3a553db0cbf8312c04d0a62e803cb7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.0-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.122.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1f95ef81b03e28b07aa6e8d3cced3a5657e8d91a1f86a7b2cfe9374d35661cd1
MD5 074e10a542588f22e712cabd16483289
BLAKE2b-256 bd835d386217bcf60ac15a19382df70dddf83093ef5e0934580386acb41ebd95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d82bccc082b5fd7ed6e76dbd081d07a7d08c232d36562b50fe309f542ee945df
MD5 f767911162db603c73cc6b1fc3f6754f
BLAKE2b-256 e58d4799163c7993dd9581e9780804c1fb465bf89a8adb21f2d7e00a70318262

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9fe9619e9be887076b4fdbd21948ea7bbe863f415187cdf0bafd7fde975e20bb
MD5 792d0a390e13f76ab251cac3179999fb
BLAKE2b-256 db4515f889cf7450d87ebaae2c3326330470283b702f996c91f0c0d3641899c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad12341f1703005c5640b42352b1a82612acd52d917c2024e382c1984e7641e9
MD5 e605d0501da93717ab248c09702a4461
BLAKE2b-256 ba285647e4633a736789bac6ec7d3ed21c0c598d017692cc673917a018bbaa8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2c128b12cbf060c17bee5fc697e68faa2767ae481436fbc9ab45783066ab7b79
MD5 ffc8ef2654f3ff3aa29d5513077ba67b
BLAKE2b-256 6fef874a5f68cfd95c05886e4e08a8dca8f254399e7d3afd980e78204b5fb3e0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.0-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.122.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3cf18b73af3e48cfde70baf04804613f6df631223cc7246c000998fcc7af7df4
MD5 e8ef9cf6631147a5931bf8c711b0d5ba
BLAKE2b-256 801099e432f2a45ace5e98e267a69aaf88a32bd5ebfc4c77d7f5dfe761bdc118

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 40735938f2cc0330be73031e7e630a0d84ad449e1b7f2b25e030327979e6c805
MD5 f91cad3ef69e7f23c155cd303df5fc4d
BLAKE2b-256 9320acc20121e1400a0e766c229fe1ee70def09635b2608ae89f9bee6140f322

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 91ca795b280d4a50a8b7a85600cac9f3370302726c9e9ba830beb40f631dc8f3
MD5 e9d61726bbb135a688de802301521066
BLAKE2b-256 2d3577152016c26b50a99cd36f6b050b315dded76beeb508fd2d2f3fbb91f774

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e6f3fd946c1e52d6ca899646c6ccb2b1f5f95b84d86152ff3848110aaaffde2
MD5 f57085c970c67fe083d49e2610d08547
BLAKE2b-256 420a25f17d3bc7b4c4d940c14ad18f2abf2d4aef7ef45ec0a0cb2a5a81b2cba2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a7f2333cf021fa38dac5672c8afa31fb377c69d7fb0643b59fe7b46ef06727dd
MD5 7fa20e27eed31e3d36acd4c760b127c1
BLAKE2b-256 ee5d62dc9a1918923a3881d5890e153fdbf278bdcbe2d0134ddfc0b8e18ea1e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.0-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.122.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4fd9570cd5fdf8e41cbcde4eef16338205743df8e8f65169a7c79285408b9aba
MD5 561ad425ed6f13ff52f3d04a1056d05c
BLAKE2b-256 fff1f711a879796a1299db666df936eb0108470c52d442997ca2c74190ea62bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e36a028d733fcb7c6a03d27527d195ba448b02754eb4e9be88d4ab6e6248650
MD5 658c0db274a819034702e62915486cdb
BLAKE2b-256 e2602126229cb97429a143c07ca6ed09de8ef1ced5ae609f43e3fe3f4a72deda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2b7ca14e6afc82a541d68f1388ad031cf9883ba6aca09d526eebe8a32d481ec3
MD5 cebfee80741b7c22bc11517c199b9a09
BLAKE2b-256 27700de0b1764c119a7a595e643e84156714b0fdec1499c9c7fa3abeb39a5537

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53c40cac2c6e4b0ed02ece33559b70d29b42ca8085bc030b55e3e5d2bcfc93dd
MD5 bb913ec2ef59e0e488dab8a0e314df59
BLAKE2b-256 79c09f560ab4dd4acf6c0128dd20da3578569f4862608cf423bdd538ec84ec0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 39b6d54d2c4946cad337390aa18107126a15622e9a18d0d08c1feac9d475484c
MD5 1f2384863c7e778dd01840a30f5e1f28
BLAKE2b-256 76ed9ee82613b0fda5199e9aff7d67fe1f183ba726fe742860f35e352bd58f81

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