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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.5-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.113.5-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.113.5-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.5-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.113.5-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.113.5-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.5-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.113.5-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.113.5-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.5-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.113.5-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.5-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.113.5.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.5.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.113.5.tar.gz
Algorithm Hash digest
SHA256 fa182c431ad8eb01418583fe0f5eec25a4f39b254dfd650f382985d4420ece2e
MD5 e0b352594306c54aa690236cbb97bd0c
BLAKE2b-256 2af117caf5c2df6e7ce408c05b50d45362418a20dcb6bbae0c163929a6a59d8c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ef17c29fc454a5ec4f79251749a0cd704fa719acb264b990179c7f3bccc6f70e
MD5 66d7acb6521b5a89f72f8ba5933d0051
BLAKE2b-256 6b04620671bc31dddef784b7d169a0793168bfcca772e78612aafed4b6c14281

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2baa892c022bee24469881f50b24a2f37683df066c554a3c6986b3a5d839c866
MD5 812e26c6b56d1045f6a5bc06fc7420ab
BLAKE2b-256 520eab34e36f9cab0e8c6fedb65c94cca53de6da387f5c0d6ac5828e15e26e8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7587209eeeb1eedeb4bb5f00e498ff85aed374c2d8100ce92816cb63d8d4ad1c
MD5 db027aa61e54830a36e4a0aed1e1b2d6
BLAKE2b-256 e966417c9d9e0dc5fdc3f89b3a43e6722612b83cf12a7d9d7e1bdb7259401a83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 82220a53abf3c8f4c0d49225c24acb5d214766c9f25f828d82268a7a2b7b14a9
MD5 30e5d40ff22e5df2ea7c00534ae8b1f4
BLAKE2b-256 3fb2f284a5e33208ebe988557f42a2c1c915f2456eee0e90793e5d72ab99b83b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 10d3e83b25c0e6d6a3ccbad76c778b97f8f01fc2b626e45aafcda942c208197d
MD5 de329506039959fda5c55f1b525ffd80
BLAKE2b-256 e80f7ee47f87f68ccb54b18b3be7aa75091f672b936cb8c243ebd1192ee3d72f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 122f9fdec49ce3d6ac32289c19bcf7c018af3bd5e5f373b35a7e4328be9f8beb
MD5 639faf21caa5c0c720304a8d9f9ee2b0
BLAKE2b-256 30504daf63bb514c041fd54e39818a0b26ee77072ed8ee7b75bc0860dbdc0da9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93d03ac44728f15edbcb30091cd40ae428e2baa035f354ba630ae87fa3de2414
MD5 f54dab1bc74ca637532cde25123c04fb
BLAKE2b-256 36353c8ee102bf1479cbf6d5d7a9ff4733abbc4dc5a5b463c093f833c0dc5e58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c1a0ff8223bfb94dc63c3263af2d3d940cb54eb09dc3fd94f84805eb106775b0
MD5 8f3ab027ac02c47c14d069e26bb8b560
BLAKE2b-256 96a52cf5e95642c3328e792c0b239d554fb52f881fd54c5214dc1590a005e888

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5793b3cfc72a231a7bb3d87673c5191c46f867f903f9673646ac80a566f92e47
MD5 f42e271e6e3cad99de18bcaca88b1075
BLAKE2b-256 ac575ce1d849aaf257833588d4f317f20d9cdf07b6d65a102d9e6e1dea438edf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1c5eb25d2fb5542d88287efa83c589b923c0c874d7d43db93b0bed4ec71eaaab
MD5 bef1d636dadff191fe55ee20dae7694f
BLAKE2b-256 19fba6b933f8cd2a1230d31b72d6aaf910b695326276a8e3d03650b6eadd9aee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 29ef8ea9ed38f2968cbe9ba7d8d3a45a271d06165d2e467c6083d8cd5f3ab0ba
MD5 cebee887b36020f4db4388fe75722df9
BLAKE2b-256 06a209fda269c85a6131779e09db5d136f62ed7f1b17850bd1fb2da2e34f0421

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7e637009f262b8947245f4c97597dc9c363ed3d1f699d13d4b30a0906920fb4a
MD5 1ff9b86fed5baf959df620059267c2cb
BLAKE2b-256 b253d9ae53ae904a9f6b0cb8e26d4655679b2b78e720ad046922420625484759

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fba565dc45c478918a6556c06abe49bbb9811eb5527f57b312ef358a702d3e00
MD5 9cc6ad5d36ac82017484a780b2e3acda
BLAKE2b-256 c379c737bf08a4bbe9231def420209efad3d166646aa8e270bf1f654856c9606

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0033c7543c859dda9d41acc3cf05a4383ad5a28ba89fdefadeb78bdec919d1e6
MD5 92a1480db0d2d2be00724754e5c7ef22
BLAKE2b-256 70eea258ce0173d2b2696c31b141b696dd66da29e1f830e280e32de6fb32fc61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b1ec74a69548c4cb5b40e0086c5696f1707d54654eb62db7bd3bea1524c42108
MD5 93941cc04edf1a21fcc7491e04fa4531
BLAKE2b-256 931909f7658b216a5dcfc2475e717e1b36e82b5452f5517264af0242d8a442f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 98f65aa1a7ec9c724eacdb76192f494ba139f516ba82d1c7cd49c0e8f90d952c
MD5 fa45f9a138124a4f20e1bca59310e06d
BLAKE2b-256 29bede4998414f335ffbf08f9ac51987639f228706c4c7f59de44faebaef8e08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0fb997bf3b34507ef8419ab22aca8af9d9101c6df933248dffd77c1691187370
MD5 d9771b91a66b7dc1e901fa718afdaaad
BLAKE2b-256 ec21d5bb379190c89c7aacc90e156b7dc87ef7c9ec293f32d4f95fe95d43f802

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4bb761f1ed46e7ac5832bfc1925fa83fa6f17da40c4f956b999c0cfe25f3a973
MD5 dc74a896631236c279c7574ca5f08e63
BLAKE2b-256 f911fafad833da976c83cf6f27369d9f4fbe03872c43dac5308b9e2e3b2e97a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9ae6b898c6fdac0b5b33855ba74c8cbbafeb7fbb709bcc35b1f61d80da328be
MD5 7ee55c3ba660a070fa399de11c62fcb0
BLAKE2b-256 19666285d2484f27de148d9d4567d186e4902d53fd24cc8d8d2e921b73f7d492

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ab4a81edd726952cf8eeb7b2d1d9da0032e35396b2fd92e6ff194a6f9ce3238f
MD5 7ec36c41b286aa802cb2eb0afb86ddd4
BLAKE2b-256 7ba9c329ce30e5e0d8d009d0f285ee45dc7edb5ac219219861537e43b0be6fa0

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