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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.11-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.123.11-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.123.11-cp312-cp312-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.11-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.123.11-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.123.11-cp311-cp311-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.11-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.123.11-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.123.11-cp310-cp310-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.11-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.123.11-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.11-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.123.11.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.11.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.123.11.tar.gz
Algorithm Hash digest
SHA256 00216d94968abec2dfcf3fcebe0483bc4aa8c397e85ea1913c45965629086492
MD5 14bcd0e1b129587df8d1f56cbddfa9bc
BLAKE2b-256 4684e3723a0f07e65fa86583a27ddfa3bda80de41ac46792cc916e6a72dab7df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1b569fa5e3fc2731403bd795548b28e32179a116c9b1c1eb7081599f47526463
MD5 94420de45ee41d399afd8543cf1d2704
BLAKE2b-256 45f3a4da29a9a15dda94c882fd1140b8c2e8748a9f674ee89f6f8661ae89ee7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d540003ff1654a9c99c531af2b513e43a3ad15b20ee27e125aa718032d26fb2c
MD5 e059c19e6bfc0eb9f1d90bc5e1699bb2
BLAKE2b-256 b8b1cd27719035e1f42b729e8437b27ac3a0dc8b56d3296efddec5745579b82a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 53a66507cd37ee20fcb894c69233865388cbf8dc538e7ab62625fd6111773891
MD5 00ee9f91c4729aa5e51c119be593d3af
BLAKE2b-256 ab2caea974bd9b68ecab02fbeb2c0ad9a191e24a1e3d0c23d2a4f7ca8f0bdbca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f82e1691352bd86e33de93c3d536242d43a1164c2206c1044f4601828c534c3
MD5 d2f7d3f9bf941ac01388b0f7f69626b4
BLAKE2b-256 7ae316adc96f22a84c5eb5b81fbedeb607be34c86698a85b0d36f4bafecccab0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ad58e77db82610ca3f8775eaf651add0f12868d196ad7c0117fbcdbcc7529579
MD5 642586a8006f1b8296b6f58cef221a47
BLAKE2b-256 5d3c70a8f4add61a6446edd11de7e3ea8312366f78744f76e19f53d709c69000

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 294e74327cd9cd70324266746ad84d2fc9e941a19de20083029be93f8e4d7ab2
MD5 c82c1a95c186559a78da048d5dacebde
BLAKE2b-256 e3798fd81aa8c955404d53ef1ca106c4fcf41123d2ee7eeb3d47ce9d7526f04c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0c8f8a4d96c7cf07d11cd5f4ff9c0e6ccf2da654d082e5974e065d071d060fa0
MD5 144a2afefde7d821036ea0bd65d890e4
BLAKE2b-256 5849a687120eac184db0800c9913d2acc20ddecab297821e0d51709154ac8287

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 413aa1dfe5235bd5db5302ded153174d0785087e8a3627f8a0df698f3aeabbe3
MD5 ed1139c682f11c00580854d33a3937c9
BLAKE2b-256 66d9bc5a2c5a3ee62721631c546fe844c99c9f482539d584348deff21689ba2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ceea2a96997fb952dbfa11f3ee72fae22314bcce39b30753470294759084649d
MD5 2575b78e40adfc1c679d0421ae378e5d
BLAKE2b-256 8322bae9a13c02e9a247eb3ab1b81c8ddcfb4a10ddb4e89e236fd7288af0a280

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cf9f1ca4ccd46426ef43d329ea7d1ce1c284c3f627b2860d4d73b0bfc82ca326
MD5 8e034ad86fef44a89c3c097c765e737b
BLAKE2b-256 92d2c6a1d8f2a3643a93379fd0d3b586fa1994fa4fe0cbe7eae70fd4424574e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.11-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 abc7e59a0fc09dee0d95fb6eba31c4fd2a3dd8ac110f19f98bb6fa8ac5a238db
MD5 24ff9e5c12ced34c0d8a4adbd0642f0e
BLAKE2b-256 a7fe0885ece43b5ccf78cb1f188ddda5b1f520492797d048f4024ee0812ebe05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b27074c4cfbd5af0a7f347228cab3775a48778d75f83419707d6ef96a459a5d
MD5 946bdfd1eecf352235dc5549533e1d31
BLAKE2b-256 f12c0d57d37422975c5862e08bcde3584d865d0bed28491a0ec15227c579af35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1dc3a30a96555f23af34f5b36090969a6f77c97aa93ff569cbd703f27bcb1b7a
MD5 3e7354a8a42ecd6a2d0fe0de798354ed
BLAKE2b-256 49d7d100b2021636e1a6166e16dc078170528fd813cf62876d1e501447b3dcc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 62ae65040d9440d5ed215e398b1d877907960a3f3f3d9e600a8f2db2c4ccab83
MD5 c1c1f7b8a68cfd9ef088e489eac729a9
BLAKE2b-256 59cc2d1f20711510d0d4deaad9a31ecbaba05d58ab4e00d60f91e75afce8e810

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 88ae7a95b4ae2766ea9f8408662dd6a957ea66d88b83d0f9344cf6799e486a71
MD5 bb82967c7175f55f58b204c40b2c21ab
BLAKE2b-256 7837ad9d3068c133afa590ddc8779015dce6369d8a324ab59d567e06b7a02116

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.11-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.11-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c9308c6770270bfd431d0bfa09f83e9af9fc1b5b6ca6056c22729bc2d7868f6c
MD5 d9d1e3521231246bb0809e4f04aefe9e
BLAKE2b-256 7c4ce0109118ea5ab68993d1acad1e2573877cd45bf63be456e841d26b5a4d7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c4bb3e91de24add460990a6e2d01371fab94b7f63dc3d003cea07bbcbdefa0c
MD5 7a93d3a63dcb1d4ea1fb675a9e19047c
BLAKE2b-256 018715d6e333c643cbcb65c2e4792934d993d512ef156ecd511d3443b753cf88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8d358272a4d8146923a370a953a931f6ca41ba014844bc54de740643ad0211d8
MD5 26b9f6135d61858f750b61ba04ca154f
BLAKE2b-256 17fdb9c9bdbda33b92bb2c6dd324030014f1cfa6eba29ca9fbb4a8ba1743ab0d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5040983e0e0a6df5db1e103fb1a9537e70737e296a2785b7909e1d87cd5f7dc0
MD5 5f2e2fda4a02d791aff1320ce3b720c9
BLAKE2b-256 9ef94aa934849388293cd85dc3097ff60247fe373f92e47080f4375f44e41a6a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.11-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 841f58f3d04320055a23fcdfe537f98d14008d0808690d23a71f7fa1b8c94fe0
MD5 02f90cddd452b415f39995aced8a49ac
BLAKE2b-256 85674740989c805c8f07410010e6a54d80a4a5651542b411d7b29276b5f356f2

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