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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.122.1-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.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.122.1-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.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.122.1-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.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.122.1-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.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.122.1-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.1.tar.gz.

File metadata

  • Download URL: chalkpy-2.122.1.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.1.tar.gz
Algorithm Hash digest
SHA256 0b51301973d4ab8b0669f7486aa6046b6aca354e3ed37b60976e27d343fce916
MD5 02a9769527a4b29086a7fa611183ee2c
BLAKE2b-256 ab59fdb60649eb25f55f3d8ea1f65c0e4463c92b4b12a08e8daf280ab6afaa76

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.1-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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ab6469d89a1c4d7653146a78e0e560170ed9e1b25b48e24c05a6a27318910fa4
MD5 a13395b32814731f14d6508b9031d5a5
BLAKE2b-256 2b6f72e7613e965de643882fcbed4c8383b17d2d7a32812b1b83d33eec1abd6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3407c826cbac913827285b31fe6c381dca50a9e22cb7ec1d62b316ae4b89019e
MD5 c5a71f5ed0e0b9b16934d8b9cd9a4c5b
BLAKE2b-256 df19e777410ee6e1dc30d04f3c69b6e1f50ead66c753f44d23238021e9ae7928

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb4c3af4965d9d2ba2e1e83d0cb539afdc6cdc5b9d6ceb6e80dd43cbacb7f448
MD5 33adc599e0b3e87bd35ff59a9683ebd2
BLAKE2b-256 cdd37acd3e1d9610ec9f1fedc1d040fbeb6c928ef8f12a09989176b4e98f1dcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f4780a397bf11c1a2f607a894b230e7c8917c52e7451094eed60e59b3825b3a0
MD5 7d4b1b8e5f3e160419c1c00f90483007
BLAKE2b-256 3eb6d35a1067787d1d0782bc9e4da490beedc18a546ee87910f4972f401fb018

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 081db3590adcd14aea98a1d4972d85e5c6cdfcdc83803fe8a641bd0add67e1e8
MD5 61a6dec8d02bde0a917f9064db091fc1
BLAKE2b-256 c85cf4c92b84e821ade6db3ebdf52aab9431a83c074107585a84648525a4eee6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eb1bf1938922fa0cf7abed67c44af1af6ab6e4823abebb707ddf2a47247237fd
MD5 b05b256ed24c8488c77b99970e699e54
BLAKE2b-256 d478e7a8bb299bb91cfa44f0148519c1fe7b349b54c64826d297af60ddf82f82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e92787d1fc983db49e68a4ceb817661f850e7e943607fcfe7070156f622d4064
MD5 6da2d68f69b9ab1e313be1b6e280d780
BLAKE2b-256 8494e864f4847ebb9ce878e09fd6fc0fcedaa0b5ee52c06d5c30b2adfa41255b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9b97b2746e946b0065255f4f1c23308a8221beb0ac86fd7891c721e4489f04d5
MD5 7065b981910bfeb81242a8556413b7ee
BLAKE2b-256 5e5fc639c8ab6476e2768ae3f958d06f6165bc6e18288bd10bbe5b2a165f7227

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40bd2fef772dccd1a2a11159fd7b3c00d19223b6bea45e883cdb3000e4b441ce
MD5 ba7867e093a2390802b673e8b52300d7
BLAKE2b-256 34401682c4cdceb90e515b55b6329edede53f66fad165ebd961168ac95625ddb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 36b9ba861a68ec47dbbf9a13ccfd0c4eca943a427d9e2ef62ffa8e95982e26c1
MD5 6e00a58ef5c6638ee43dc4780785bd7a
BLAKE2b-256 f3b3f5377c1cce56ae84602b58af29e1dbfdbade00253ee3a7c704f1fb1f0f62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 58f3758a253e99752e4b2d6643b016db7e9374fdce53508c7c408ebaf09752a3
MD5 883720aac87afda26a21c74f19bd67d8
BLAKE2b-256 429779355755a3faca8a052fb3c7ce99abb2acfb586ddbfbf9f042d0ddbe5e92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d117129cec895ac50a921d0a695120305034d19bafd041c1c7d03878b7d713b
MD5 6edfa07695367f376ad55dda3116c697
BLAKE2b-256 75fd51346c7ad1ea2da458f9574ba4c08783e5e94756df891f55a80d5a2889b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 adfe8fc991dd78bf5956d528ad8b57b4ab2d4b46bb3084daceb57c15ad080d02
MD5 694b60f35326590e23b17caa4a0d0ec3
BLAKE2b-256 e84301e72292d24f88b30cd562c2bb68e27f735dae0e92e8b62a300d02fae795

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 022b82a6ac3aca930f0128d79365cd580b4b0f969f70db5dcc0ca8e410c38b10
MD5 9448225653bfa7346c6138e1d43bad9e
BLAKE2b-256 63d8202b0047f7461f976d205f9fedad51684771b99dacf2ee7300751651538f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9623ef9fce557174e52b3ad5018f4f62546319d266efb67bf0ab03ad26e2a0ab
MD5 21da0d1ab2be85a09c7147279cd686af
BLAKE2b-256 4e5cb22d653e616412b3f60d94ba1d81833e135bc5acea365c37a68aae4fe327

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b0cf99eab09bf0249bd90833ea07e47a4180d1e83c057b5b4b3de0e94ca1421f
MD5 e51f0c3d7ff5d40b15753f32e08cdc54
BLAKE2b-256 b40c964479f13d18d744bdb8762076b3068ea6f6c80e2ad8ae1e354f7a8286ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8b6a6b7a995a531e07ed641280d9d953f52f4967f4168f177886550f2ddd1fa
MD5 d2a999a761ebadc17a5aa84e9430e052
BLAKE2b-256 4b5a1cbb106c31e82962c00bb0da28fbc588d93b8bbd4ab265e3703ac2fc2cc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cfa9446c4d1802d6b7ca3f5faf03fc5c4023bee98696e3c04eb773384b334e95
MD5 da85accbb93339eaee5a4c96e7bb9760
BLAKE2b-256 a769c21729fcbe29ca17d7a1838b1befa8bf53e48e9fc8d694bdd11e88fad149

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74a97a74e155cd761d30a690ef09a559fb480390f634e05b7bd7b705cd969ca5
MD5 ae03310ba5b925f0c94f7c0517c1067f
BLAKE2b-256 5e4f72ecf90162cc3a66f208355e07784555e6a982080c02d4cec606d66f49c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d8d1ee0487eafe5e7ab9f21c3821b3c0a77b002df3ff4c76c30a8648cd3cd1b9
MD5 1ebe3a78cfc13a02c9e236c8c2e64c5b
BLAKE2b-256 9ef21e84e65d3d688ea0e4674a9af20724b3dd9e7a156af31cf88d222d641813

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