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.18.tar.gz (1.4 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.18-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.18-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.18-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.113.18-cp313-cp313-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.18-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.18-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.113.18-cp312-cp312-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.113.18-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.18-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.113.18-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.113.18-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.113.18-cp311-cp311-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.113.18-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.18-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.113.18-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.113.18-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.18-cp310-cp310-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.113.18.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.18.tar.gz
  • Upload date:
  • Size: 1.4 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.18.tar.gz
Algorithm Hash digest
SHA256 5f038f6be286ed672b9a52d3e77951be950c150954ce21b764364d666b2d7cc2
MD5 1f74d3e66d66f2acb7046b5e28db8899
BLAKE2b-256 08947ec38b7ee510b78b1442ea9d25c32b7dd92c55cedefcd23c4f6b6cd265ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.18-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.18-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8ac4ece083959ab80872f0f0ecb41cbb7688c546c514e9b5fc185d06f9929fc8
MD5 38c99546e0258cec1f9233e45fe812e9
BLAKE2b-256 6480f99db99f3dcf96b56ee77de6ff2a7be9896eca904ad2cca8cd2c90615356

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 707390631fb8a6e89acb31bbc9058fbccb8fedcb03a35497fdc8513f4a125542
MD5 c05f5abed40e0fefe8361543061ad8d0
BLAKE2b-256 b6fbe99b8ec8bf095963f249f007247589f720024406f7a24f12216b90cc22bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f9b26ec30ba938c5a4075b02502cfcd38ed763202e36e15d5e236336a608d4d1
MD5 3868d33859f7ebdc9a53345a1a769f85
BLAKE2b-256 4e688b0682903b435d5a327f1c355062a51b68ea1c667519fd1909196f1750c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb0b423c4e428598915eb990bd6fa011faefe055184a681ae8dda680adb10526
MD5 1c2761a39e1e72b87c527c9287bfef0d
BLAKE2b-256 0726da3ffaaab7d3912f9eca76b325a562ada91008b595e186fe38f975c2dae7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5dca028a12a1ce8b215114c1011d8bf385112376e63dec14c81b0c85dc74acb0
MD5 9512a0daae8e0043b6ce162c1c63eeb2
BLAKE2b-256 620ae88316f427394d80af3305f28abaf7ffc9a712bab42f5530b87170e57706

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.18-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.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b35f8cb82299ab0068cb57b83068c905cb29b3bd8aa03a729af5b516adc39e84
MD5 0444d8fd323c112daa5ca57c8e7638c4
BLAKE2b-256 029c9cb1bef9672b0bc98b2ad35ad8a894a7556040a7bb4d395265e53279172e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b301fade3f8f7e751f7008719a00e15e52e935e915d693f7ccb1227c5fa80ba
MD5 6c8f711ecffb7cbec923a80e7ebbff8c
BLAKE2b-256 b398553263cb173668d15d4a18cfde633e8ffb17e3d7e6c488a8ed054f9c46f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3633821275ca81b6be0a9e849808f24806c102c20e38cdee6900b97a04761d47
MD5 e18f7fb165a7c0a5710c92ab5b131fb3
BLAKE2b-256 39431e097996994c8a341d0f7c04a3e79053674330fca678e55a1e702fa6d839

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c8d47af5fbc5c73d89e52a76643b369a3e184f7a4e9e6c6aa3342d2c73df4ad1
MD5 d2599c4d0cb0321d128c5e0e359b1153
BLAKE2b-256 b6672f29ab56c3f232086bcc6806e502b718ccba4acb3feb251cc514b50c7086

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 46d1e051ab3740f7b0926965ae83bc57afff12d85d52f999a406b617af75832f
MD5 20b79380ca6cfbe75104f76a1a79e6e2
BLAKE2b-256 be5357c12f5b2047f0951d3129d72e196d1258fb88627cb02fbf47f6e16bb3cc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.18-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f2eeb22e975ff4a0d4549a5c19a8b5ddb089dbfd9d33496b32fcab56d23824a8
MD5 dc208a145891e40a97e907a41e6d4cce
BLAKE2b-256 10b81c23f8e3cc46967f8f406c2d4891f7497aab90106579dee02f8e74030b24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ba9fbe9a0b8fbb8cf04fdfbf384610a0a67340f72d61261ae9812e3ff400e04f
MD5 5478f15a16039d8ef72b93b515d9d18f
BLAKE2b-256 29fadc2fe0f45ff3e55469ca37ef1fab80f93e7e0ce6abbd2c9503b5cdd5cc3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 69d314f19e07fac0ec942155bcd2922034cffb8375db555015b8bbd74ac4da30
MD5 3e7ee60e7d2f6370644cfeef1e1f18f8
BLAKE2b-256 b8cf8601900684d56eb52219315f98a09029054e96956c7da8b1998797caaf35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 361d1d2e7230c52739da01a38a43d52f06c465c4e92c83a2b9c1fa90442aa801
MD5 579a63855924dd449876c39f1972841d
BLAKE2b-256 17f8a6237b5b7adc1b0cc3b0dff58c265b920451f9160a788b4f8e6f3dd5b114

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e490d9dd21c44498e8981ac74dbd4df4efb7d03fbc2960f08e543b9847cb2677
MD5 5b724bbff4773859990b7431bfc47165
BLAKE2b-256 d73ebc8c9ad015549c64bbb97d2e84ba443fa6dd2b30b7ae88e5b010facf1660

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.18-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 49bd7d17252be2160e37c02f3ef55ed900dc85fc2336412417deb8ea8fed38cb
MD5 b92a5115525da03201023ddd6c2e2f4b
BLAKE2b-256 8a2a5dbad986c2f30bc1196fae0284fb10b2b6e90936933c4ce7a79e5a242b3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f024e55cb222ff7396470aa1872180d5fc597c9ea8f0942985421ed7f1ad50d7
MD5 7e49ab4ed4f19d4ed4a6a7921e0344f4
BLAKE2b-256 d2044adc9b7353c7b9d857d6ef03156d222c21d99189221ac630c45602e55cb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9a4ff44c2fb6f3d80fe0d1bc260985f270c160fef0a2ee8c35322b7bd5bf1f88
MD5 c79b71a3e76b346b950e262438601211
BLAKE2b-256 11f66c00c8fe76d2f28a7113fedc1fde1f7ab3f84b12d4d7fffa76c796a0f944

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 329f35f2412665e928145ff9c9ac15d1a01668c05189921fe1a710a58e09dc23
MD5 c92975bbe289c7d80298142169f14265
BLAKE2b-256 7ada3c0fe9967abf48e4d1a162e456febadb268c89ed32269b5b73b63920890f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.18-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 072df6524b07023dad7f0e78d6500ce74aba53a6c1418f95bea1fa0fc84d43c1
MD5 8717602132861cc96607c209c0a517c3
BLAKE2b-256 54aa2e8764e05b3a694d5c02e75669ebff8e9ffa544cfabba226535b0d3c3257

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