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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.14-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.14.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.14.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.14.tar.gz
Algorithm Hash digest
SHA256 8861accf6140888415bfb7eab41b1de3b0cebc7df91fd82ad635d4921058aab8
MD5 ee6f6081a367abcf7f895d1e87876b6f
BLAKE2b-256 3b82d72f1e3564ceac7ff32ff7fc2b3033d84100fb183218c87987aaaccded12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.14-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.14-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 99bc9f233eae3e225a080db9a9fd377543a35099e478bf9b2c348ae138697c1f
MD5 420ca82bc5f9b8a786c5d46d7501a149
BLAKE2b-256 67ef83b6854bd1ec6499ba00a756493822792bb8a38bbef80d3bde1ea85d56d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edbebafd3ae0a7da24de1391463769e7a94cf66db25812975e5a589d328c58f6
MD5 8dcfdc565044d4f32b3bf2106dbdc629
BLAKE2b-256 139152c13213bc917085b6866378d590ffa0329591a54b411bc0f2f03c4bef2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d35fbe0b7eb0da5d347ec5a71df623a7992e2e71de0a6f3c3ebc20e49b135cc2
MD5 4a76ebfbfe1961a9ee4c0586ee3fb0bd
BLAKE2b-256 3718203271a16198b4af2c9d95c490bf7cbb679339ddcf0e05d378a1a9ed22d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3009ab0e74c0c3cb7ee8b6e3082f63ae6f789475a5e41d29792c6fa72b6b666
MD5 228eff812aa43c09ea73426b65b72e98
BLAKE2b-256 3d189df1f40a4f65ec78ccc13d41a0faf1b673089bc66c2bedf07299f5a7b68e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6d5057a07c520a7bb7380b892b361fd6271a8ea014ba94c8143bff349f8fab10
MD5 11141c24eb1e280a40b0355585ae5d19
BLAKE2b-256 ccbc5bb469cab1ddbed0a0adeda6509f45190ff0eec2a5af62b79b83f03184bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.14-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.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 37e23e7a79dbf281b55f67c67c47ac18c4bdf5c78995324cfd15827f97a3e2f7
MD5 088beea726f223142209d1476e004d64
BLAKE2b-256 8acdfa45858b697140047267738ecc47832fea4c1bb05459f1760a0276d32d6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 567cb428cd21fe111b0c64201a49c5854df1938d0c95490a7b6e30157b8c5981
MD5 a91dd8ad99a79fda36217fb749804374
BLAKE2b-256 e8a2adae67aa3416704eb32a43a851acd32438954937a72e42d3c731800bbdb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e7a9c58c467529ebac340c7efd072d8e99cfdafcc8408333b1c32cb9c96f2164
MD5 6adf42d89630de84eccca6e5de204d1a
BLAKE2b-256 326f2e26871e9e400da50cc797cfed0d7faf0485b9c04190e7eb5d496d42b714

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a33da8f69ae2c99c1ef8ab41bf7a3a072059541df55e135274ab01f616fb96c
MD5 1ac5d509e1feb6051cd451882796e2de
BLAKE2b-256 1546376862910bc10893a427140b99957768bcdd6a76389660f48f6978cfd79c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d3684d6769e3e14050eb805a006fadc9bc41acab4df7dac2326e89bc7b608510
MD5 363263fb1a2a2bb5ef9b029d4ccad320
BLAKE2b-256 bc15e422a44d1a29160e4d0ebf591053417ecbdc50709a8f2934a0d641024075

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.14-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.14-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f5ebf5716cb55e410da2878062382a94276b3e4f49805c73bdd7d65b6dcbc682
MD5 007f1d0dda5948051e73051e95bb86a6
BLAKE2b-256 9981c1b269538266614f19950fd325f7a9000312dc29655b7c50774c49e9034c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9115f4c324c9e55341024c8f2232b2834ce456c3abd33f2aeafc5fbf99742b0
MD5 c7ab1f729533cea70270135780b908d8
BLAKE2b-256 84a542405b04e56e79ae106b934f85cb6c13d807cda02c48cc1e0a96345552c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cbd6e5fe351346823988982bb8cce6afa9c833e4e1db56a6094873e5f1dd9a56
MD5 d7653826a9ae0150b8cce917da097667
BLAKE2b-256 6db8b86088967c92faba3d104e1b46327ec8d20d52474fa25b2627c3e97e7bb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74cfb3d22a7ca64a13aee46f727272f966276efbdbff2d4e45287783ca61e756
MD5 54941df970effecfd28baf9b779378a3
BLAKE2b-256 4116b4ff58a4e3418aa356e9b9af70376e748d6914d61eece6012fa04288fd29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 805b06e4b4caa46a1663a675025fa5b7a3dfeb017273a008f61b181f448f111d
MD5 c03c0c0d7f4be36edfceeb9f882a7cfe
BLAKE2b-256 f62831e4c784959e0f4ae9a4dc33f59b419ddf06db849c3da7a050ab9041e49e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.14-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.14-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5c1e614872cf2c4be9d56255b0d1a80c329b75f1ebad17d6293aa44e1c333f59
MD5 b347e5ccd2cf369bdc9d0066826401eb
BLAKE2b-256 6b61324b56490bdf06bd32ed0dc5a887fef5f4ec4508216c2cce77c3f9838092

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 59f175a3124452ab58c9a415460dba6fda1460a333b440d5022cddf1c5964fb8
MD5 e201f9892f869ec0aef018aec588d1a8
BLAKE2b-256 2e83fd5dc4ef6c6ac0799bfa16ec3e02d6ad2dacabd8079c678ff23f7cacb806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 165a907c37af00e8a1605df2cc13dd67e0ac0c354559e65c1a7f8958917c4c30
MD5 ccd2121dc844b72e31dd277a7a90262d
BLAKE2b-256 e06566a203144102a5265841169212936941e413035a65e8c3224a2b0d422e06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a799fa7210381a0f47c158441f0cb03edc2b28dfe833703613d1d5d454227d84
MD5 e16ff491d92f5a0287c0e147f89bd96a
BLAKE2b-256 8a2828b667057d072d0f211cd4874701ed9c162873d6dcc4606317057bcf0e89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.14-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 84e616b48d1816666879b0b87dd4a7976a511c601144617a7802da8c2b7407df
MD5 c76c0cfd819b3468da4484ee9ef1df5a
BLAKE2b-256 7497e23f5e1c16328e05e6ca436d2c69226fffa15e4ccfd1ab92235376156b4b

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