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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.112.5-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.5-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.112.5-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.5-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.5-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.5-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.5-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.5-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.112.5.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.5.tar.gz
Algorithm Hash digest
SHA256 7783f646a300e00fd71ff516d14aaffcc07d4a674bbde383b36656d129ee1465
MD5 8a001f93b6f5e966f4ed3a9c609d6702
BLAKE2b-256 4f4e443bb0f9965f648734b190e80559494c80a99a0327115c118cf69e3fe260

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.5-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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1bc7a65f9ac6c742a8c8fb1027c8e0a7d08e6efad449170f910cd62e687dd967
MD5 af1b8176cf263cacc0b868ef6ca22512
BLAKE2b-256 068b6d5c63e65d1f80b083018534983102fe8a9e4aba0d7ed1696048c073ba71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b75c25a8e135622c1a0e6e00759a0a45c0c75d166efa86006eaf6fc1cdff03c
MD5 4934c74fa788e0daf6ad217570ad4708
BLAKE2b-256 1047ad0e5145a6e90132ebfc071eb5c7a835ed0cce7137380e5f2e27eb980511

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cbb0b0d94a479e39d2b413256e41de0fcd142f9d0c01e07d898720c6f98f334e
MD5 79c9454d417e5bdebd1e1bd2d416b123
BLAKE2b-256 a5c2471e80b5e0cc02ade00ddf4d61bb3d4ba07aa1ff0ece7ce8bf0629b67850

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92fc41f29f1fc0c28d6bb026e8c1d7ec503f969ba0ca61488ca468fdb01a8e22
MD5 d37d7f9ceee4d6c1134984d38bb24f39
BLAKE2b-256 f7c9da34d7b2be08b7ceade41db14243649b03811caba3bf5192b8da212fbb6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8dfff9a7811b2e9a998995522c8776b3cc34d191b189cb09df25f516a4f97a72
MD5 4f1d8687554e9af6599890abee4c2c70
BLAKE2b-256 48caad6378f134b4ee4d50878908f6b907a3fecb7c5267c56e1053df1683d722

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.5-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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4e249455313322f1f55127552524abab7e5390acc904a3cdadad81b7ad6dfcde
MD5 a9f59386ddc3f2f9fa5f62220b6d1316
BLAKE2b-256 b5e39c860946025745eaf6632402c8b788837a7f15a2bf733d6f1ac09e496015

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b69daf9b36a5e018502eab2410d01d63a7cbccfbf29819695eee6f4d76c567ad
MD5 f37ed8a326e3d4b7b4446e88b18d773b
BLAKE2b-256 cc8db858a66e9444826e147be3614778bf4beacaf4f441316a98d99375ee31d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 47c108cdd3559fda1f680d2ccb15bc1bc77a8e53bb8f0282548a35ee9bde010c
MD5 71ba130b30c1560fc08e04d79ca6fc2f
BLAKE2b-256 4cf5bda961c8d4d4600e5b8e4130742dcf8be0994d86245236bc2a6c8f0ce300

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a574d43f2be8120d7514653a57070caf5b2b00b0bf72e4ed14e91118fe2f36ae
MD5 9973e04ee29023380b2ae353ef123985
BLAKE2b-256 a55e418068afa286b2a3600c88df61ab466c1f354ea3b2442b05cb2a7fd633be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0595b559fe5b6435a810e1d2270bbe0d9ecc6fc702bb872de8178b6f2353a400
MD5 ca0b27e9d9381ff442b56346004a2d79
BLAKE2b-256 f6c352977bc047947779800162f248a31147c8e334fe76c567a72110b4076590

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8ff91846e3a12885411be080bcc5d0793aa08a9d64594a92983997fad5e7ba0f
MD5 d2abf1e9c078fa7f4410687115aa59d5
BLAKE2b-256 78a6d67d80993cd3436de374f917b505d8635bd541b5ce5bfcdff76d170a8bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a4f50de369b2fa5aeeef87670a83f06e47461c845d840c287c6312f8b921d896
MD5 5ad3e0c3c51a79f657c158d90b041440
BLAKE2b-256 25f32aba3f72136f5d93989c35b8b1111174df25ca572502920a1aef1a38cd5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e33057173811169fa8bae17037c5dbcb77cba0ff87d5eb766e16b7ba5344a872
MD5 810ddaefad6ca852c87d7fc2b1cdddef
BLAKE2b-256 791672302349bdd87baad1e66577ee1e6a4c26d42301a235d9bf14b548263f11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa23363c6c99c7a5191d45816c988f115a49b4693d841df2f7f2c0cd2cb030ef
MD5 1d1407d77ee423fdd969ce4b361021de
BLAKE2b-256 b65543f68b9631747af9aa5b91a61425cb84d335c6687f4362ca78f7d7910229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c0c037c7aa1b227e06d5dd93e2f7a886fe30b556a4ac665d1c5d3aa3c2767d88
MD5 2250010e89ed950e656244d02942cf9c
BLAKE2b-256 258ea1cdcd83a1a168c7c9d07197b7fa560a530547b3fd079ab5363882f74f78

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.5-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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a203cee1073aa4caee38ff0ea2172de29f4756d027d1c4ad9a2f280966b398d9
MD5 cb34bad2b68fd08a32491b903617f342
BLAKE2b-256 fb27a376ee3cf724a9d971507997eae3551269b65f0a0e287ed33192f3cf33c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ad902d1445e7a10ff3b2f0e39f245e163b77c40831ea04dcbe19ead6ff6a6db
MD5 684ff8d1c529d80d5e8e6cf68e4872dc
BLAKE2b-256 593ded6c1295deae8f62b3e2d6bfe551e6079ec23790cba1bf1bf11f835895b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 375f70523d170c12065a95d0af6ae924cf3104c3faaceaa3efa6e1ceedea267c
MD5 e2a021a7769559d6bdcadb94897ecfdf
BLAKE2b-256 fcef0ff3dbe9049e9209c8e57b12797d7d879fd2665b1209e68798bc4229d5fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31a77a9385e1ada4ae764cbc8f433e530c9fba4f5f5300e8c7c4d1a6b056368e
MD5 068899212dbf64032ca7a8fbeeb2c88f
BLAKE2b-256 cb2edfe044d92af6522e651ef3911bdaa784c31e9b7512c6f7db15ad98e47197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 30d56f9d899b22b2f85c3894253d42ec06e872bda7faa9ba44f9f0e197e150cc
MD5 4f6e411e6ef145b7e5931d5d9ae8c13c
BLAKE2b-256 c8c8d617e1d97b7ca1867db71cdc250eb12c66ae0ce64409ab2007c9e691cc1b

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