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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.7-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.123.7-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.7-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.123.7-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.7-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.123.7-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.7-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.123.7-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.123.7.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.7.tar.gz
Algorithm Hash digest
SHA256 260008fe1dfccfcf17351d109634c32526896dc9cff5b7a823e0c70f5e8e0f85
MD5 e651fc6ad739b3d7ef57a9ee6d0e693f
BLAKE2b-256 98bcbcd8b57451e5610d4f6bd74f284c9819ee8dfc1b221b9762521674334472

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.7-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.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0d68e846567151edb940274d2ae70b9a0136897c0f69035e1d9e0066ced5b974
MD5 e109720cb758f6f3d8d6818e6d09e6ac
BLAKE2b-256 76f0ee86e52c26985e2b4d6bdb993dfbf20d1688bbc95031e0322c75fbbd2c25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e473ed03740908332372040aa3492eab170eaaf0bbd1fa080c5a0175a8786cc
MD5 a221a3b903e4d04406f14d13af371bee
BLAKE2b-256 ef90336a2308540433dae69dc2eb0e5aa4fc471179555aeee1c53c99eda77814

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ab12381a4f27636108790813cc97a27104e4e2386f21644616040b11a9e41592
MD5 49e87e6c0eb07e34f745836eba3372b4
BLAKE2b-256 791780ddf4380d36e1de65d2c3158ffcb170c6f1c61d991d851015737f493dae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97e579c23a4f0e86f02ef08ab36dbcfb52c02888dc692fe42bd9d5bb9276e9f8
MD5 a461303b8f4aaf4a7d0fbb3f7ee55546
BLAKE2b-256 0676b9b170b4b7cd56b0e59a76eb833a65ca701750b373c6b75fda9112be1d28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 73f36e3a0f80092dcd8317dff5677e3abe0675d767f2ecf164a3c2ecebe7fc25
MD5 606c18564953429384dd8e0825b7379b
BLAKE2b-256 92acc78e2d47e64ede26d5939e86e0d4bdda3ab77397698955001f6f34730889

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 85fbf19d8cebfc46e4b12edc7ffbc125da859154b82863db32d68ef535167612
MD5 d5f90c383d8d32af6201952841cb4a9f
BLAKE2b-256 541788c5dfabbb843f41d1c2fe581b598feff47a65802fc82a83baf063ae221e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5f674f22955de856eced2380c05503798d6ae5344dec20bd2175167f49cbfec8
MD5 9936218b16befcb1967b6685888d35aa
BLAKE2b-256 95939b3eadbcd476be3a6f444a98fded2cfb6ddf110262ba1da0f865db0ef8a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dfd927528aa144dec3b5f3157a38280a45c9d8a8db605bea55cc07d8e1331044
MD5 9f3e944950b68706a2c206baedd6020c
BLAKE2b-256 03acecb14ed1224c06ffa28907697d806678ba11b055c815454772b167c92ec4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dcd35350f3efc860b64b31a917187ced26b9f5b9dc436064770920b479252464
MD5 04b7951b46cee5ce5d8aeeb6b86d14d5
BLAKE2b-256 db2ecff992e5501ff3c143f83f1ee48675a7428ccc7a8682058832a5815de3ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 056df760c91639aba007639ecad5dea9d2f52dd693dff3a612e4102ed1391cc1
MD5 f9d95d1ebab7497002280cddaecd4b9f
BLAKE2b-256 44a3003c276c74194f114e5dd1e48cfcb63b028086a21ce2c1569383ed01ba17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 426ed54374f777b515d30efe1982ee456b1a6f701cc7dd0f867ba8366ce84032
MD5 ebf1ae3829f1218f498cfb74cbdd303a
BLAKE2b-256 3fefccdd8e818eec80f1ae6f745188461a634826d846017dbd36157fd6702745

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b3a9e885f99b52a193ac779e6aac168eaa44ba8a8e6fbba8591379cadea0e85
MD5 b36409844aa1ea80523eef4519f07d15
BLAKE2b-256 53bd87e4a61cd6d903609a5cca86ee0a564e006e955740cc782c2e71691a8140

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2b59cff38f60f63c5281d0b3d4d13b804f085049a9056d79a99818a9e07c693a
MD5 25a6aee3cbc9b92bac95b110bb56da50
BLAKE2b-256 96e9ccde62b69e86ea4a4f7c4932084ece59eafde0c182c5ec560d9ebd96e589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 387a4f1f48c24e6f8f7d0e5a540130de8a6cc4de9456053096a61628b7ea7b38
MD5 e74d2d74a78c02a46697a46bdb06c522
BLAKE2b-256 74fe5f84ac28cd6abe524190b203968070099c71c883ae8c16923b5d8027fc37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1a367eab2adbc3a355957c12f3fd15ffc3d8a9776708c923bc84302e16cf7bdf
MD5 8b2d85cea2902a175e6c90be878e238f
BLAKE2b-256 3784ada4bf72efdfb183a5479b00f239085073580ad0a4fb7573d7b2a3956bc9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.7-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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0efda4589637c7ac9f4e438462ddf5a9896599037a2c1aca762b49e9c8172a34
MD5 c993d310eb57e0065e8579c15ac5e601
BLAKE2b-256 ceace466dc8fceaadc18d13374124c1405c5ea675778c661a89cfde8eafdc270

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80abb4a6819f957c976ea25177a63836947f3f1ff5cf3a0816cc4a7c52afc240
MD5 29481e63b92d0d469a4b53375ab98be6
BLAKE2b-256 38eac1cb3f1becc14f3a3d4ff343bf60b29cd7ac2bda78cdb9e1dbeea81feac3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 24ae05ce78b00d2a60d2bbc9d018324fcfaf7cb7f4a11e2b7de7bb4d26e9fce8
MD5 c1a4c7a815e072a01e7a59a15da4f3ab
BLAKE2b-256 69b4e3cbec84fbd1589e1613c9cdb2c0fd8e4d7fd6df680fb5295e80dd08c079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5fdf89983c2d77ad4cc504a3ae98b00fa9a547309007bcb8da5b3639c953e190
MD5 aa295da8851a60c75f9632db08f4b5e2
BLAKE2b-256 c0b3347c96b85bad9fdd686398b37837d37c1234c5c7430e26deabe2276d3840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.7-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 49e34fb1cc6b359656bdfa4c2287ef0b31b76daf186220640d19d3cbb6727b2d
MD5 ab7b2eb9fba9c779e085f1083b37aff1
BLAKE2b-256 064b01b1b3b2d9082dd41467d0f11db29dbc5e95bf30b328d5c1b61dab96106e

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