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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.113.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ec5ec7405282476965464e07cb84c17da7ba0e4483991853e1c651865692377e
MD5 f70c97765ab13b6f66945a0c597e9905
BLAKE2b-256 39681b1c3ec108e069626890aeec37a5b41fa4bc77be54cc6ebc11d4b7ebe525

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.1-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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 951c11962f98e6a67f513ba3d0a01f67935911dac104964e2118b00633b5497a
MD5 8d24ebe5ac90a60229f0366778cd4fc4
BLAKE2b-256 4f4904c010203a35406dcf12e8fdd965d07c0fe66803e60612e85565538ff6ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c4d1e94fa5993f93b075c3671129b388c30f10c5fe624d6e8ea4d668e8587b4
MD5 cb1f19db81252b6e67ff2d62700cbded
BLAKE2b-256 b3709de5eafac90646321232d5f7c7a5cc92fef50a04e118f72957a18c02aff8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c404ce5d444214d59c222039ad7aecf52ddd623857bd07f974bf07b8f9ce11e7
MD5 a1d9e38e23956fbc08ea319a01c202ca
BLAKE2b-256 b37a77c979b43c4b8daafd9d101e565550866a4de1f30ad6aa38bbd832622645

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6289c107d962a4874df2c53b10488baabe85d80f2b8f51c3082c40028c82f10e
MD5 75fe5bed9c42bec1db7e1e1b8e950514
BLAKE2b-256 090a0dba86a495eaedb75ff5223b0ca257bf4c4420d4328120b848f183043679

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c05591d0f6ecf29787ae55ae1ba3c8799d284e694b9f31a63c7d0ab830407bd5
MD5 8da9e98cb53b91edab0b33f2e15b390c
BLAKE2b-256 a3680b307da4a5af50cefe0d0a89bc39cb2005448e9c2401982141b9c72562fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.1-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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 11f450a1e98ca830c48f1ddb5a9865ae6d0018d12b8dc9d970b690a7ac9c1176
MD5 abeabf9fd8a505b11ef2f8f5cf4cbf05
BLAKE2b-256 d6d3e170718206b8f70b560a9d5bb561a4828d018deb33b38c26981f671953c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 adedefaee69a5788707b78c230ac2107e2f98370b0a0e0d81bff88b9b6251e2e
MD5 85d692d598756859a44c1965bf6e625f
BLAKE2b-256 053a495aa902b424c30521f467e773af169a29518a8398421f589c12a7f73ea8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 98207bb19bc52e38b50096cb50764afc5b587520805a97ac07f6e7d04c63e6bf
MD5 75ca69461a5158b785506d8a66a1e225
BLAKE2b-256 61bb8d6d5a50057ffa5a49b9a06d13f7621f102e3f119a8dccca1aee8eeab667

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b0ca5a0d8158c752c910464996b1ca0c9a4de130eb352d3a55d783c7cf27c907
MD5 77b4537bd795632d9e3b0fe6e9a08413
BLAKE2b-256 cc2fae5fdeea54aa50e3430ed5fb01ca796e338fb20abac8d05a36ef29267678

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8c0cdb1afbd4781ff8d14264672a766f5695218183bafe4926a3a3cfd60c5e88
MD5 4575f8759c17b411ca27037faa48da8e
BLAKE2b-256 1ae20dda6861be1414bc047d630c5f6461897f2646418d9db7abd8c04bd60951

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f8f37a3b7cf317736cd8699790cb7de466b564a8868707ffd83a05c19a90ec80
MD5 410bb648f4ce0c376c3ddc8fe2918608
BLAKE2b-256 aa00826b589befc72487aa0252ca4c98914a4a6c154b4e41d4267fea613efe83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6b4de8dbdfe5a7e0c824639a1d31ae787bf5f50287764e9abbeba0495b02a6ce
MD5 1d30eb72d0224993caa4d5e6d381c701
BLAKE2b-256 d01e8080ad0401d3b6da217b6bf529793487685510cba6b6987f1c0ae27d5536

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3336eb69c630631d426b1b0258a2eca8c4ce00276a168446b542a1dda68b342a
MD5 71e60faf99bc564ab2c84c9106c1836c
BLAKE2b-256 b8b2a0edb503f301782603905ab61476a1bdea3f6fabf339dc7d9b81c42e9d88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fc143c407ec83e18cf475a3908fbff93bc1fbaee1f47b9a3db8d35009cab4f8
MD5 e4a2626add1319e0ee9ce730cb71a577
BLAKE2b-256 a1b903010a784112cc07c16321c71946143169668b9b569eeda8cd2be95ebe5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a052b9a11f09e7f934ff551e80bd4e2c06b0f311bb9b8a86acc3788d73a21697
MD5 94f3bbe6136bae171ecd5bd5c3383bed
BLAKE2b-256 83d1a90b4572a03d072a6277edd5963f9725c95dd8beb37ebd4e301c397be30f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.1-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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 67a3b41a1aaa4d50f6aabc52a0c16dae36cb04a5340bfa8c30c6cedd8e96c2fa
MD5 d57533464bef8cedba3640885e92d3aa
BLAKE2b-256 483ddacb14c8c72584bd0911ad7e4b94c6b2325e356861ffdaf836ebf3e5cb71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f3a7f7fed85af89e428c5e12c9d24bfc7511b667cb08f9fd4a622eae27e7c3a1
MD5 e43b53051315119fa1dedbdfad5de2e0
BLAKE2b-256 242b7a6a75e7f63d3305e651fa3c1c1f5458a05e70c903b88957836f5aded0ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 270b2fb33ed0be90d99ea38c346305c4acc9c8c1c94a2580dfa2c1ed39190462
MD5 22fc94ee8299db7ab772b16820d47c50
BLAKE2b-256 e6c3d062cf1ddcf1d2c33691ff9c4c30fc57645a5d73f6367f8effb42f37af35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f0a5b26f9ddad210db58e2cc46b7a8d1dff9abcb69775dcd24bef5c920fe552
MD5 3bdf03363d82f354f78e38e4036323f0
BLAKE2b-256 7b5c134000362196cc1850c5d22963949f2cb6d819bca64bed57d51685042224

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 87660cc3f9bdcf4cf8ff83e721ebef00624e0e99168b65dc4a1905ada3a4b607
MD5 aceb304d539ebcd8436b892868b78823
BLAKE2b-256 019f7d19de0f0c6d3796ae71f8a506bcd726fc7de7e7a8e1f2d80148a1212a89

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