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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.112.4-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.112.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.112.4-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.112.4-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.4-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.112.4-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.4-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.112.4-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.112.4.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.112.4.tar.gz
Algorithm Hash digest
SHA256 63beaebde2eb5e19c18a18252c32e7ccc338a672eeea797cae66dfc89d700f17
MD5 249ef2e01cd3ded97f0bec346bf4577f
BLAKE2b-256 05dae5a24625b0fcca9057f308cb2dca19f1ba332e4fa6f89fdecb6c839c111a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.4-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.112.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6abe225c186d6989625a7b443c081d264652debe9325fbd41d6d3753d20bcc1f
MD5 aee2af180ffb5ff675d56938063c2607
BLAKE2b-256 0c90ed090607395e136b586654225dbd84787b5de537d58afa40c8a2b4babaa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6dfdb9e3109b596bf40379522dcfb654779c7e010c879aef9fa62aa8f2c5c079
MD5 ff34239d28b0307ba2f7c1f4ab7256f3
BLAKE2b-256 4d25429ba9301b4fda93d530cef2d73cbfcb6d3729dcd26dd71e2ca2579fe7ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 582e44720644602f62e5a15b620498ff4f8e24e0c38c83ba14e3809632d64919
MD5 e2af450e71356b24bdf36ccecb699494
BLAKE2b-256 8f800e5a98ebf1cdee811d822aebe70bbe1329c9d3c1b90ef521ef0c20d2d167

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12c77c8f05e44d506b5a56096b99abd65fc5ece9e0e4f141ca4b250d12db420d
MD5 23c829279e3bd119f38fe27e7e8b3e62
BLAKE2b-256 df8e9dd5299ecde9ad22d8b5ba4c4cd66fdf1620f07c1095716199daf6fff42d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 414ce1698c982d9e7b1ce5f467128191e65ab484f35849102c2fb1686d5a5f79
MD5 7d0dbf63648d66c6da32443bbd071ef1
BLAKE2b-256 3596c3baffb457b8cabe2c59d9ab858e62a7359b0660807619b153bebc0ba408

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.4-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.112.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ae7e34ac1a825def39ba263d320accbdb6fbaf9b73db6d6837edced8ede182aa
MD5 63f90aad50f3630ae212d6a77ea3eea6
BLAKE2b-256 61693e2c242087193fa53ff6d8d0b942dd625f77588d0494e650c6db93fc5883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72c77bd8aed734962c6a7b99419cc3cd450fbe0e82cea9c9922cce0c11d9a220
MD5 85e8fbdfae4a246b0df910807200763d
BLAKE2b-256 fd23e551e09440d3b0b5419074a5a8a2cfd7c6a83ddff6a101459ac9ee8ee0dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9f831b5430a6cc4b7a2ba352ed86a0ea0de2437df983ef3048da479af4f5d32b
MD5 c9b7db5a29fa07ef36910370a8c7ebb3
BLAKE2b-256 4a6fc8b2b19c1bfea9e2f4184fa77a3145570ba2a1aebf86a438f452a6db6a31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e02dcca695670164b5b1298ee91b28763e4dce6886ca4c6997d50b084475483
MD5 45d638a918228a8ede3a7fd7a179ad29
BLAKE2b-256 e14d6e422a1809ca39be10d32d240f06b419cd1d79cdc13cb684067ac4e9802b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d5fe910c3b40e8c2183c3c26eaa1c0fdcd58c9539d128f513c92abf04722a675
MD5 1315dccdf7eaa69d1b197a8365b93d00
BLAKE2b-256 78572d5592d499c37740808c274e13db9b18247002741a79d5a556cd1cc05069

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.4-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.112.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7814760a464a284c687d42a58df7a29ad4fa1b6c5ede92181a9cbd7504fd8d41
MD5 33c42ea7732731ccd99dcab0b56fdf24
BLAKE2b-256 df3a444179d249746e477f4cc9d43838db43bb719bd4c1a30d38d5f65a25b771

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d998610d6ac4956b01eb0fd66daea64376049c494223cf178966a95fca781ca7
MD5 186c68d5493a9a435939848d3a78c7d5
BLAKE2b-256 fa64d92389d3d7a13b657a9ba9d4736e179ba577aca43385046c074f7cad17b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 84841aa419fae24675b8b49403ab10edf7c29f5dc9ae5d8b06cf5b4bf96d6c40
MD5 c3f398564045da11267a2e7de37800de
BLAKE2b-256 2c06691fd003cbccc0908661ab80b8c15a42538dfdd37cb424700de5836c4b67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24125de3614098642cbe60e37c3bccfadb9cdd5a80e095c1a886d0c83df5e8f6
MD5 e57a459b7453d8f53e5301280f622f16
BLAKE2b-256 6499c38b55bfa1ded31808ca225f02698ce905b77ca64cc0d3c0785f56cd5f36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9c5c01ad367f3732a919c33c8d0044d39ac41dc82f9bb94ea5171cff7e0228ce
MD5 5dc43165e99fc35831f8b758ab2695b3
BLAKE2b-256 8334e39329d0fd1a0b73a4d77cc434da13b8c4304c05e6706308264e7d9d38b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.4-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.112.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a1f3a4745b73e4eb8a63cf448a0026d05f78305d4823fe4cd28f32d17e030a4c
MD5 d425ec469ca4ebdbb7fb0273081f8bd8
BLAKE2b-256 1b572dd369abf3e0385ca9996ef41f1445d2ad1fbdc29299c649a581c5d7dbb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4214083598e57c9a9127358a3897c4858868d90a8ff6ef353b6ef321803c35a9
MD5 1366e77b92386d0cdbf428c333fda151
BLAKE2b-256 8699c23817b3b3d9a3b7b62e182b9345fa28f1df03ad8e2c772cfb3536d60c69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d4886723fdf21609b28f1af0c6373d1dc266aaf45e2cfd6363f14aec66df298a
MD5 738187c10a5b1e82d29ca586bc99c6a0
BLAKE2b-256 c5e4e1aa7f141ae48644710f14b685234cc8754cf0dd31b9d4f936b8d4580b70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4daf6fa295d5f9463a6b192281e68cbb7532444b61f8b41514bf858469320176
MD5 6ec0bb85ef85b18fa8f2b1bc6614b1c5
BLAKE2b-256 44e6100da95f04f1c4d3032c11189c504fca5d46bb905eebcd2baf97835e7216

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2e7225e5dcea760b8a35fc8f90954139a462bfe59f9a7f07296d7174beae9d27
MD5 2ff195f1920e22b028f805a43645e3de
BLAKE2b-256 84145387cbd0b171a9184fd26a124286fc1b9026714ba916ab7905dce2f5f3d4

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