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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.118.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.118.2-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.118.2-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.118.2-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.118.2-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.118.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.118.2-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.118.2-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.118.2-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.118.2-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.118.2-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.118.2-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.118.2-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.118.2-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.118.2-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.118.2-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.118.2-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.118.2.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.118.2.tar.gz
Algorithm Hash digest
SHA256 3ec874e902befb8baf9a3da8300f2c0a2414e9c765dc9bb92612dc89adf47182
MD5 529b286eaf3b3387f13ba4f1090fa072
BLAKE2b-256 84298e7bbad7c09c0e1cd5c4b70e04f77d4d9d0edc650acf926c9b5a152ea130

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.118.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f0816d21118fd6def0f89ff383862598126f309da0f6dbcd0930a0040995ac74
MD5 2f3ddd33f1fcf454417c362a24b4c6dc
BLAKE2b-256 f1aabc9800a4b0c0176f1350b65471489d3b0ca027ce7a2899f8329421e365d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ca4ffe25d7dfb297bb0a446670f2ca136b723d0ea107da276ba667f494cac5f
MD5 6b0b17f606b07920633ff6dd1e1dc33a
BLAKE2b-256 6c8602b90dbff572e64b372f7a20dce8ad4bb87110d1a2aba5daeb0beb05d48e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 89bd26f4c95472f32ce4a3faebdaed93ad95b3ab2bc3067c2b3c42f87cd16339
MD5 4ba6622ed3c36453391dc706c0eff8d1
BLAKE2b-256 5736743fdcbf8fb138b86f6aaa7d53179e829b036e9a0564b806624abf9d41e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21aa47443a447635217553d9a6fe5776fab1771ac813cd3e91621d7dab975208
MD5 69f13d48b374a47f86d5e56daaed0353
BLAKE2b-256 9204f988fe4f70f37f74a7ce8040f29eb464ca98d5e69c0db5852f8b036e585e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f570076ebe17996a5b81f093808675832c6af8afc0d6f3829362195540989433
MD5 e6648413aeef84b9a0e88624ca12e279
BLAKE2b-256 42a024dfb6432c4261234d4a7bbe30a3ed3dc546a13fde57c687c5d365e4e1ed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.118.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b7a949ef961ca0566cc94f31707eff8d9d990bec5e84dde739327a32880e46e
MD5 6ca42bc93b92247355d2a83af62ffb37
BLAKE2b-256 51012a61ed0eff83e3339c8277a0aaa8cd16a0f159326af668f9d6117e3f108d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 db3f5882cabdc282e99a601b660600fcddd62907e3529700eea557448f75a2ee
MD5 38daea7344f3ee7fbf3860a867512dd5
BLAKE2b-256 f53b11909007c6bc780e70025a783afd1d4e76ac89af362cbd8ae9bbabc9a9b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dff7a64acb96ef019caf709d70eb79d9c284d55672a442221587a0178753b6a5
MD5 73d85ac82ea59f8867d6c54d746b01dc
BLAKE2b-256 f48df36904b09dcb944b83f3cd89229e8f2c5e9447375dba21efa1e7595dbac4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e9d7d6ba72818fc639e3b6463da37a067cea39bee11092dea9f990db50edc8b
MD5 09076aac59eb106e82886e07e7361f93
BLAKE2b-256 6962aca9c304f961d606aeda8a005959de4e0530769e208fcba188198f942372

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6d58f46b5d720eba391ff2e3ecce16859a06697bf8aadc32bc13fc6f4469bb2b
MD5 d6e68aca5adba071c281e4ed2a60cb1c
BLAKE2b-256 483c32f561287c4c6e2f71f67df6f2924c0d3dd1b9ce2757b96a7d88f80e18bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2451fa6cc1e9c6f7aaaa3f8d6107b318240669796a57b127658e06557f944aa4
MD5 51b44ee91789f5c43cf59515ad0d2c5b
BLAKE2b-256 1d51f8c76612a3085f905d0d9d3ad50ca54c63b7119fd08e2ba932d50da400a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9299c4b86554f3eaebf87656ef24553336292b686d2c60dd55d0bb4a4bb508f
MD5 9f71dbb16058ae0ca742d79f75a76fa8
BLAKE2b-256 d1822ce785984fb0aa1cc3cf554fd967c2a19ce24bea62262c53dd1e4c31285d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2ceb3c8992516323c138873ecce85f0d77d55c58c1b1190a0c7e0f3bea36e6a5
MD5 714d2d4da48ce9f040e0add12952fba4
BLAKE2b-256 ac3caceee834b6b91dafc5c474b844c3f43ff72844e8f45f837b21180a6284af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17b1dfef52f384024c1d05bf6e121030c66cc1d3d14bc1c559f14519618783e9
MD5 77432e9354d207a668585a01847a1cee
BLAKE2b-256 e26f0acd300235cb4006aafd38e390933ee924f687a689a8736f952c230d8436

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 145e240772d242f9e7e71d8d3403a2aa6324ec02a479e8063c03888c390674ed
MD5 bc04eb63b64b78d9c1ca6271fb30c4f6
BLAKE2b-256 79d922bce837b81c5be82ada92abcfc9742284c642c1cc91db38a9fee7766983

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2d2cf9b72f678b775ee8d8cbabec141cb179033b9e6b725f9afdd9e90a1ca544
MD5 31524175717807ece9b9efebf6574181
BLAKE2b-256 f33748633e413fef0fd6726c521e9fcf1937220865958001f4d8581816043bfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a9e0ce7e5845a37eeecab89ca2c3d370b725171c5ac0b3529bdcc3218258bed
MD5 f4ad3e8eb5baf4d33671cb1d43b26906
BLAKE2b-256 9fe541b17bf576f276272834cec7ca9a87a465f774e0629d1fb746aa7a573d72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2a569cbca2f385b5494327117eff70efcf54e312ee59a6028682e7b231eec825
MD5 0c827c6efb3881eda5d3e53be692bbbf
BLAKE2b-256 b2ea5169d2fe6f2c3ef004b583aefaecb8ab03f31b98107f934f4c722a87db88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a16b114401e606f17ea7019850088bae483759f9be27c787c65feb9cdc31f51
MD5 92f1cd47585bfa10c98bcfc082cd0214
BLAKE2b-256 b5352597811e5593aae82102b6368e4ff9128a998bdf6272e90c5d463ddd6705

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 208e2acac60ba7fb26cc6f4b08a55a954001c25ab23bdbc1add824e709995e05
MD5 ef4f11857a7c4f3199799c3d025b62ff
BLAKE2b-256 8e751ede6736808a24bff816c61a974ef882bc25199c0e00591bead717da02eb

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