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.122.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.122.2-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.122.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.122.2-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.122.2-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.122.2-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.122.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.122.2-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.122.2-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.122.2-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.122.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.122.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.122.2.tar.gz
Algorithm Hash digest
SHA256 23e863c7a1a7acc7544ed0e02c14b023e2e9ce5c179a47e3a28b1bed4e70f049
MD5 38cfd52c8adaf40f4d3913baf3cb5b18
BLAKE2b-256 b82378ae7cad575b99ae28a97142b207592a6b25ec0061acdf77b65ef73490fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.122.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a13643899b6b7ef3a1f8942467eb0fbf32e915067611f5e1f03dee8dc78c1cc9
MD5 9c8f5fcbc46738ee9e9f0885f44dd668
BLAKE2b-256 69a4c1f4acaf90c0ea81fd961bafb6c2f2a393cb0582aed60b4c339f7c04f892

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d582317e69843bef409d869e40ccf868c15ecea66889adce810d341c18da52d2
MD5 688771712e47a6188225aef1097cc4b9
BLAKE2b-256 bb5a2f1d44eb9e11d4ae418d5354ee17c5348074f6c28e6f410d697da14b1aca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 475b0ab96b0a049d67b6ae1a74cd8f3c1bff434aa3d8b894bf04cd2572fd9fb4
MD5 03c74dae182d10b63f0ad244c5ef5f97
BLAKE2b-256 58a21cf13be618efd8d8b2a23471ea1e331389136acfe29a302d4c21621d9ec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 01e0e0f6f22bd97a496c1389e72f385a72232e7da79bded2789b4201f884e3b2
MD5 46260b32865554eb8621ef3727059a31
BLAKE2b-256 fde5f7910fba3081ee45ab23a3fb41b04e407daa101c30a498d5be93bd182ea0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 80beb5742a6c5519e57d54a3f8940f3b0f0975887f6ca213767732de16c8a181
MD5 6d9feefe8c23f1c11f76caa343f167b7
BLAKE2b-256 46e2f5236c974167ee9f325b4e1b9e65dcc9bae4e1fc88fc63ccf5325a488525

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.122.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cf65a3444ef3c510f4f44ef80bac8cb639a8240bbe795d24d5fafa4ab4dd43e7
MD5 163b2699fe62f8902103fcc6b23b473b
BLAKE2b-256 f44a5a6a0f94f5f404b88de787c0ed711e537d53a185772639244f7ee7c7e044

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c7a3a4ec5ec31e69dff73c32551061b20e31a5c8d4cfbc4620c28de24e54869
MD5 12c0c07c819937035017ddc1bea7a982
BLAKE2b-256 e69c65ea69be2fa35670ada81246f7a9821c0028747af8f6c058ef81b350aca1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c43272eb040f10523276bca1cbda3decede4d3c071c620666ec19e4c5c8c5751
MD5 8b881e9fd8cb9a247e42c2c5a70681ec
BLAKE2b-256 aeb4f9bb15b7a27d5d4c0174058180a94cbca9767a5eee376f2f6a25654869e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 094bf74a7c605676d3cb46bc16705edce5dba69b28fba32033333f2baa66cd56
MD5 b192d53018dc71ecf4fb183074c3933d
BLAKE2b-256 2b64b0a380763c890a3d229c619c6dcedeeff182f8d04ff0acbd6fa1433d3d99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9e4ce5bafcd4099812f9615012aa97b301cd9700f57fe7897e2fb0ced56896a0
MD5 07bcc8b0d14b48d1e3807cdb6c4c34c3
BLAKE2b-256 679b802c73e7364968f4fc32708e1d80b3f33b47763dd39dda19a43146dc1b01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.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.122.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4ffeb26cd6590114cfab155c0dbf864f94a00af64721cc74908d5b81e89e0657
MD5 049f6854b1aee5514aa59e7fdb85bd88
BLAKE2b-256 2d588d4b042a8dc9feca896253ec886e072a5d970ffa5f91d1e18f0c44754273

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c1150ae3e6022701af92ae3e614fc588ef34632ebaa0ae37ca161766d5f4666
MD5 bb4b231059ca110e2a0dc647300de2c7
BLAKE2b-256 112261ef0016629366430c52ac02bd7392a0f02f911ab8d1d37382f7ee170038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 21b9070f58242a1a9e0b7db6baa82f40027893b3fdb46e739242cbcfbeec3c4a
MD5 a0d77079b5165bac2955dc779c109c08
BLAKE2b-256 18e953c00fedc5011ac8c5158c942fb9f9eb8d60ff7ed11ff8d1a184c205a884

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 250a3038529f8c56ba9be49b550edb504f61dded8997e4dc165f8c9c425f80ce
MD5 84a8833ef32129a1f20cff97038edfe7
BLAKE2b-256 7a508427415f359646fabbb5a28789f98b198b321885e273fbfb7a55d2bc376d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f329acb13800da83a5737e93dea514b66f4391446a7447822d30d52aea82fe51
MD5 ba777b1d1aeb98704a2eb06f2db03aba
BLAKE2b-256 25b39fed74e08b5c90dd83a28c30d584ac161f39dfc60d5a4323bf5f4ee33033

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.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.122.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 92a2e3e3b78e743b4d1afec301b0f4dc6a2a0cff65821e755a1ce688dd3a9e55
MD5 ef7066189798222a51627e66ebb2d0a7
BLAKE2b-256 e7495be5f8166fd1c0cdb74c37d6cb2ce5da5ff643ff39d9398324b6573e8366

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cff8e03160b8371cded5dc28a690e18c4e2206afe957aa6cc403efd1ce4c276a
MD5 aa26895d7b4e5459de7f0e12b34ed702
BLAKE2b-256 7ae973a42b778649ff5c12f11abd59d4de957388a720e19a22c5c7560862fbdd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2112d0bd181a9b586dd473a4b344e77cbd3dd761a49f787111162c46a91d95f3
MD5 a90d9fcebc26f6f657deb9e3521c23b5
BLAKE2b-256 b65b623015ac14e98878d2f830156b1b5f328a2e84e3cb57d4502bd6e73ae78b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ffa188558de3858de37d22b456cfd528431e996ab8a50ad3a12f384b34531c7
MD5 7ea9894032174f20f8bb201bbc296c77
BLAKE2b-256 9c65bfe4fa5d82f8ad24847b04951976afe18db1c98403a71d69c60c6a657ea5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5e371aa66fdd7f68e6746a87573dd18f124d5608f2096626e3b266ecfdce1482
MD5 0b5cadec801a01918c965e327ddd7f82
BLAKE2b-256 f5bbea60dd7f407df220844116973096f3b81bb74543f96ec721d080e49eec7f

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