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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.123.15.tar.gz
  • Upload date:
  • Size: 1.7 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.15.tar.gz
Algorithm Hash digest
SHA256 85d966544701bb8725f93c086cc9e591e5aed94e8df0b392277ef941088990ae
MD5 51ea38f0495a5e1b57ea71f1133e0b18
BLAKE2b-256 3bc38f62e0b2ff1ce262ded2c1b666540478977da020820b9bcdccb7d1f569ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.15-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.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 288b0b041b6d637c1ee86aa2012799aaaa6776d94ced75a90900b6b4a4dfda2b
MD5 ed561eb612bb91b5015207d0d0a05929
BLAKE2b-256 71afc1aad198ce887618446a4a2805a06a0ad5e4c976db6994400c850fab1a19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fcc971ac8a4bb445de86cfdec90394d4c9d276efdc05b416fd4e234ca2eeed68
MD5 901e32f260c86aff536075d119d47c33
BLAKE2b-256 03a433e37d649582ea72474a4cb64c2cc2f68c537f5e72c8ae0e0ba58f26dfbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 03318264ca974e51df1f42d4a6f6533056da322e82fd437c6b91398fa483113a
MD5 57facbea40704b64ccd29b1e7c47e80c
BLAKE2b-256 b200bfd56fa12f7849cb2856658b3a05c6564d9c7fc9255740bc0395bc5c0f70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c8d7eb3950a16247cf441eb258faa37262aa14e84294ddc6f71f3528f1eba6e2
MD5 74f973979db723f9805b50925e89abf3
BLAKE2b-256 e6d03f298cc8fa1d06e7d8246cef17054d63de76da2f6950e7fe62a73544575d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 296474c976c22d1a0939721a24b0acdaeec807b5072f6376fdbb4936a077d905
MD5 96bb5e95d00a30581df346b43bf5d543
BLAKE2b-256 f1452d9859cad8424d3ccf5789618f27632fddddbefbcb5781661f17ce68a76a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.15-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.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 96c3d450812650189e907ae3532305b966ab1bad0ded28b29c335ac939b315a2
MD5 c5dc72aa7390c7864827ea0cdddf57e3
BLAKE2b-256 d9edd2768e73682cc26a8e82511431b8c88a1a792f266b53c7fb16cefc7f62e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6c1761adda607a627daea08c5ad9a55235050f92796453367835e0b1094d97f1
MD5 950b49e7013898d629ab6276a1b2a86a
BLAKE2b-256 d9c6ba9fe58fb57a0e6f1a8d2609647a126a4d391e8f4fba338982c32dacbcb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 882f895d6585add9881447b9f1de4d60de9ee2a6be27ca620160571a42995f81
MD5 38b2fe08626fc817e65a3fb64a5d5917
BLAKE2b-256 a9fad6fe579cc2fe2fa55b692d5627cbfed6b6cfaa145def03f583c2305d7cf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c63f21754a1bcdce94a11f5d7d9b5385837ed44dfeabdd7324320a5f491c734
MD5 a4cc4db5bda26e0b01732e4c08c343a0
BLAKE2b-256 280f62d725a881187cc47322a38fa1abc8dd3a3e29796f5e55646c11070bd60c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 726c4d9c63401cfd75cfae5169a76267aaa32850418bd2132c7cf82b0ef04fc0
MD5 5dbe32b1fe13328273a970f0d9cd86e4
BLAKE2b-256 3c7b0f9257f6c2c600b066a2b27a7339ee1d589f33fdb42f8cf88a5e3e8a16cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.15-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.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 75302a803933d2bdc88ae617d40ba4b89c2b37ad2fa1e88d661529cabc875b92
MD5 a496c6b58180d4f844dc8491a9352848
BLAKE2b-256 36de00e2b61af947551b6d208744653011582ceef2511eed06ad576b5dcdbcce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7406b3bacbaf49974e60b33d1d96edd7cf3499162ae4b4ee1162b65efe4ee135
MD5 87421215840692d1caf72b4f295cc17d
BLAKE2b-256 14b90c09b3384ee41458f8e4860934df3e69fe4e99956cf887562a6cdd273e31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 479622eb8e9effd61defe60bec60b19f5b73673dfd04dc57338d73b4ca27a4c4
MD5 14b77d133149922a10add43b9143b2e4
BLAKE2b-256 b44476da45244d49205cb92ac3f2f767bac756819b5edf7387ef05eb4a289947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dc46ac29bd90d85a0f8fd4e87fbff98d96d76a7decac2800e8cc9178f707ab10
MD5 2fb640567ed6b6bf64962c226af591de
BLAKE2b-256 e2d7e1a3a06603ada6d85b94b870b172306f0f053dcbd5cf9f144d1abc7a5378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c4e59fa6c9cbfe31173c117e82070b4e2b4557baa95df2322e2336b7ccdcdc95
MD5 506867f0f4bd5bfd9b39a0548dc085f6
BLAKE2b-256 7e40d23a71274c8873b690916719b1a70ef8017868f5db4db858b6b54ac61276

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.15-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.15-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 470ea6345c5c7cbdd06fe80b34010c5799679c10b210e620e2c8d251469d96c9
MD5 e971892b374979cb5a98bfe204657978
BLAKE2b-256 d07dba88c4df9bcbc10bb99f2794ffb9f50aa6bb0da9548211ea04e8e03d2305

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d2ed366ef4cf02349be38a9deb34e03c5cb790a89481b4f15d783d486ea8cce2
MD5 f955de7e7ff438985b292292eb2b2088
BLAKE2b-256 aeabd12995e50a16ba58aa3119189f0d7852c8dd41909f77593abae0d886f776

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 26d45eac54c054df30e2e7c1052d17be6bd2247d4266277da93efef957984b47
MD5 579e9a67a29f8422c4aaa2cda8bbb5d1
BLAKE2b-256 74cf7e8106ef54e918661a97936eb4a9b2d85502db3d04e92038b0a309e5ef0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5534b2be8dca7bb2e303055b340e7aaad07662b34b6e76c050e62762ffcd0dd9
MD5 250a72c2081a8d9f51f2c0ff11bb2ea7
BLAKE2b-256 43fcd78259dc8c6eab18b9e274a974f148eafbe25b44ff0c079f5117bbf87ec7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.15-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fca674959c6f1dd794da678677e3878e21e1a4f1c6d21cfe99c7d98fd7baaf70
MD5 a283bbd389601a6da64e4313e3ebd650
BLAKE2b-256 01d28d3f1fe986dfaadac5d40d1f70fa8d5dc5fc4efc9b85321cc789ffcfb978

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