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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.111.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.111.2-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.111.2-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.111.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.111.2-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.111.2-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.111.2-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.111.2-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.111.2-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.111.2-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.111.2-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.111.2.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.111.2.tar.gz
Algorithm Hash digest
SHA256 300a80a60312e8a4097cc12e590a52d312a80d7463ba70e9eb05271552a70caf
MD5 7c33c2af25174fa41cc5ebafe575bef3
BLAKE2b-256 e7d86fb93f7c45be20b270fc8eddc6398584a3c2bf148a19af45094592d59f5d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 65f914b0d0f59fd16b80a0a080b30652a324ac4aeaf5be9b736c3f17b7e5e648
MD5 ddbee6932a6ffb64336e41e0725068da
BLAKE2b-256 bf98d6475342b23b67fc2a54b522ae00c48cbc7133a0ff0728f3efcb87037d7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 895170d85cd247a335e4e5208735f1ca1adab45faa8d0ebcae05dc473ec50500
MD5 515a4eea98e062e1f3c98871c06af516
BLAKE2b-256 b2f19a2438ebf152a7678fd67517f6b724c210a034feb6ff1fbdd84fec38d0be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 65f99d18cf643f7a5e208e0be1357fd216a5f811195b7eddd2b455ecf27a2889
MD5 5f08826e9463a2393f9070c1cf956a52
BLAKE2b-256 e9276e9d882bfa79b2c8c472c8f47137f12b5bb614a1dfa345000d51fb6b8e67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fbfa75f50e0d8540876586c1ed8904fc4977a0031f35c74e9a0b9a815a371468
MD5 79415579c54ccb65bf8942615acbb59d
BLAKE2b-256 62b82e08f15cc94e4cd31fc3744de1e8e3ebacbaec4dbb48e6c19102a9e235b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5552ad3baa3cf6712284aca8605e7e5570fdbfefea5f6fb4e0382ec5931b4319
MD5 066fde272b3489b769ab08593236e37d
BLAKE2b-256 16d92b93709eabae08c087cb8d2464a7c3f100b8d08868d3f50cab10314c14e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4eb0944ccb00326fde6a6881e579cfff59e550c7d5ec43772b2806f8aef1c217
MD5 f30022cd44456ed9711352011c949498
BLAKE2b-256 4744bd3dee2afdb8a022448c7d9a997a2ef486d4da3fe5e9ed47bde980f5d725

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e013af5f4c0f9334b2dcf1711ca6f1c8a495d561e182a1c80d7fc974de9a9b24
MD5 0abee496d4f2abdeafb5344927086066
BLAKE2b-256 4dfa14a7cf2ac139f86614d17686966dec62ac70367fb80d3d8123ab07a10f30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4e65a64f53eec921e1e432ced02fd2a7619e21265c267779d7c296bf974fc8d2
MD5 00f2767d4cc513256ee7f48f2d20aae7
BLAKE2b-256 a7f3e6eeebce9b1a9b93401da1ef7aeb1512c7bb7a566c9d363c90001e6f9a2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff4f4c602f0927629ac91f7204f3878782f2db67a2fff10b46b132f80b83bb17
MD5 060203f4f1b8b7c787eb4fe9de0f4de5
BLAKE2b-256 66f520e7a39366b56dabf6b7c5d8aa8f216ff1f0147d442a08949d46f3118a14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cdd7ba4985ec8667b953f38e102b7109753683d65ae70f44de29bfecf36e8d7f
MD5 d4093cbb6871d06dd23650ffe5a5defc
BLAKE2b-256 7f38b25fad9155168cfc1649834ee74090d98faf6407375cf9d16a41f3d4add1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4bf94327c5813a8e7bccbddb086944f7fe80a27ae16ad99f5da8c26b3fba8404
MD5 38191003fb1c39a0c09be5bcb58da2de
BLAKE2b-256 20712e61c7ad0e4ea564db1d5a935f448d5b4021875a156adf18483ad9a69dfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a97ea7fd6e97c10c2dd0140530df212d75fe507b2efec105946150f478068c5c
MD5 7c41e613efcd81350f883d09055e56e8
BLAKE2b-256 a354837d21086a53c54098812721a9ea8a86f46f8058c11a808c3cd94f534f3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6cacfba50dd802e70bbd844326b86b6716b4292ab2f2363c528681d3dcf8f08f
MD5 b4afa40aa5b72a5f88220c27de621586
BLAKE2b-256 0f80c91b6dde9727393ce7b636eb4e559d2f1b8358f40004964fc7f26e98fad3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d289ed357b2c3f2bc0191b4e0c56f695d472a2f0b4a3a3e345a19e8fa74e555
MD5 145b891d4cc2d8a6ba074db893597ae8
BLAKE2b-256 d737bb84c3c442ba2537b66b87e711bb91b45f8b3048940b11c45751bc98d43d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f23144362937024bfd00dcb4042a357e9e0bccbaa1a875a87c7d1fb7929d54a2
MD5 19172073489cb240009d531a39c040cf
BLAKE2b-256 6ac9af0c30df09091a8b47ad0de0c21e8260ba88bd94939fb318898494d6add3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aba8f389a847f420f011f18ed8072231b5fe55036a1530e4b3b52be3ae96fb38
MD5 31901b5dd9658c614b3e78bebe6048c8
BLAKE2b-256 c8272898bd7a339bba1939767aff149b19de8b6dd515f541ef798f1e09e7ab5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90575f3990a12ec61c0ab686d98950ff6c3840b25bad04e61fff12f3f27d2154
MD5 5cb610763b466abdddc87aa726f99cf7
BLAKE2b-256 f710e964ce881c7235ffb49db600861c7c1bf33c2e98b977374d3248f40e8dda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 daa2b80446888a7197bfe378d276b640874baedac35ae8203e0061404a78f2c3
MD5 d81d75a68ef7af9ee9ca280dac5cbc90
BLAKE2b-256 0ad596e05c318b096fbed629daabf668fa55820ba391dc5f99732d788dde4d49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 514dd65584e356d6f6c67122e1798b740056271b901ab5b6ae8b28f4c8b115cc
MD5 229babac28d2f4bd44c4a42e7d3603fd
BLAKE2b-256 99ec58a675e12d9720f4fc155b0749f5ff3b8891c0bdef4f1b2c4ccb9f1abf74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c16c4f9494d91b8452486a50767cbb32750a65261f1e0ad1d84c4056c30d9d20
MD5 9cb539fffc85923e4e5f33cf18dbb7b1
BLAKE2b-256 bd728b78e4eeff76ab1635c5635e7f2403505cc3abad6597102bfcbe3bcf5f94

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