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.113.16.tar.gz (1.4 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.113.16-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.16-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.113.16-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.113.16-cp313-cp313-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.16-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.113.16-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.113.16-cp312-cp312-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.16-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.113.16-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.113.16-cp311-cp311-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.16-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.113.16-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.16-cp310-cp310-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.113.16.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.113.16.tar.gz
Algorithm Hash digest
SHA256 53e4523911a7a407d6198a4265be420b416d4ec4c281caa1c14cfcaad75696ab
MD5 b18b26a86e4654f8865f74b06bc0aa38
BLAKE2b-256 c673efc5a9f6e8488596215131c1a708d34ef59b8eb50715d71fb023499f68e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.16-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.113.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6e63ca4fb41d5eeaa895a1758489ad0b0951f86e96d09e5ec3857637dd131f8d
MD5 7aee08bc8d6475e4253a61d42e97bb19
BLAKE2b-256 7b86490e8bea8bc4e80ce589cc885f0dd5b8aa64470c7a5a89bdfeff3fc7f799

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 07d7fcd9657748397304d187e272115d5d62f74654e1916f9cae72ee5199d4a8
MD5 35c8c652665a2e63070d5f3ec2401fff
BLAKE2b-256 9c2546a110a19c616cea1a70cb343468bc3ff6a0132a30993a1f965327297562

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1fd11543442289783f2373be1dd133f07ec0ff04453a17a41e44d617ab125dde
MD5 f81577c8abd6b607d51ef7eb1a34dc18
BLAKE2b-256 31cb34e443440b95a4ff12d0ece4f26b2d4928d054f928f95b0037694c93cc8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a0c47e489346b1d90d32ff4499c682afe4bbd4abcb25e5860c54baef4b8762f
MD5 64ff7e0ce1b358c855ec1df0b66652f6
BLAKE2b-256 b89f71886cda4315aede78c8aae3464bf62dca862d35e7a990296300595de4bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ec266f506a9614ab46e9e59fc9868f0b46ce7ab1c3121deb7135f88b6f7bfc66
MD5 bd479c3a990dd0367e00d5465c4cc4c8
BLAKE2b-256 9e5d2556abb226145f92baadb4d38a18426c1be73b9aae0973feae4e0ad9ac3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.16-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.113.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 91b8a9c1615a70a2d9f396ac81308fb0f43baf0a4832814a64477ab7be2d1f8f
MD5 7697fd46c0825763cfc672ad9f236329
BLAKE2b-256 a1f2c88d46329406bcf47bc87bf05e1c22a4bf7504a532e0fc733398b00b2a46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 74e819256443cf8b3522c7acdc0019bfb53d3968115c94f6152d82124094963d
MD5 8cd036c6020ba8f75322ea84b224a6dd
BLAKE2b-256 50aef3f91a8560d935fa28fea45966336c108bc959dacb430e51ce8755dd59e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8590e0868fcaa8fda2d69ebebae48439ff7167a2a4aa2712f6d91e2f82c7df56
MD5 143e5d47deca5f1e9e3b2be03e3b513c
BLAKE2b-256 8c208bf3f964acf8ddb286c5cf143e106a5aa579c042dec661bf190654568928

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0479a3e6f838fc746987b07a7042f7107c186f0cdc7f1f9b6381b1d03803ecc
MD5 e7d1695a68ce74ac78db2f9661f98344
BLAKE2b-256 d7b6238dc4f7924d1da896b933a3eee5c6d40b0c88eb563a0f8778ac4c626e46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e857f149f69a83a2608a7b0e0b14aec86221b57ab2f271de25bbad0948d04949
MD5 7a4e4ef2a4d2eb7596d744ed43725f10
BLAKE2b-256 7f3fb36f55db987d1da9b47e5ec94f5db051ae11108392e898815edf742e32f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.16-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.113.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fe644ab89d8620a9572dcff98147e8042bbd4769921f12688a8615abb14866ca
MD5 9a6627274ba48e25498775e17e2cd027
BLAKE2b-256 a116122da7581db5f69aa116216b8379130c1da523b842482b6bad222b7e2ead

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c36fae703ab00adc08ce6aaeff80152ce2e061509afab4d1852f363a26894d3
MD5 ef207af8be6b6d11a851692ef7ab593b
BLAKE2b-256 e4c3f1e7440bee6cca6dbe404fd6a60c9d77a43916291370b4cf94dd146062fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4fc511258bce7ae4412bccaa0a4f2225093ef3e5a4f4cbb2f15c0507f51125ab
MD5 28ef8ebb871199acc6063d419f24365b
BLAKE2b-256 5e1811cb85bfbbceb100ae56f47d5e251c89b1d8a34a360e86e405adc3d615fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f44673d7ec96979f1958f13ca3fd7e6095a29d50994823ecc1a3e8fd602e47c6
MD5 d61a32da3425408e36642fa2164d6f00
BLAKE2b-256 22937a33852e4ac0a0dd7f0af513513710e981c893cccc75bee35675c6333cfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a1b618c1ac5deec774e32629bb99046659fc4b861c9b890a5ea8012c6ab233af
MD5 babd9446eaa87cae3aaf0fb58a17caa5
BLAKE2b-256 24bd48d3f95093f44d38ee96f288d8c73de6de6c11fabe92a1dc371507a47a37

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.16-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.113.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7fd99b9e7f008577ca9ac098ae9b4f36629b5fdabbe9ae10819eb8ad6481808c
MD5 4feca40ab0e20acc88b4b9fb2d525a35
BLAKE2b-256 b4c09a332133b44c7e175d93f2db5a5deb288c5f4b07946c9d4e525d5d0cd2cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9685ab7c3bc4cfdf730598baa11658664f754c67878ea399eb6c92a1101954a4
MD5 fd23cde5b0e7d41f91c1e8b634f1955d
BLAKE2b-256 fb70a848272de58d5a3803fd8cbc622c5cebaf622cca6b2d89bedc3ffee5d870

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4b2bf6d1266176d0fc835697c9fc172350f162b4e1680152819578ad9fed0451
MD5 769c881f42c7875804634334556dc21b
BLAKE2b-256 c192f2567ed067354456716e59e6c11e87eca0a16ad55203605f928d73ffaa24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d4eacfd67c372d6ca7cc9a355f00e8f28d07038c33eccaf7fc7037ccf328748
MD5 d9adc0dbd913aa9192044a1f6c8141a6
BLAKE2b-256 72a9d3cb31c12ba483afb47d4115214b3bd81e61256f0a8aae5969f06c49c15c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.16-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0db60d254e45d5184f73db2a9d70eaf5ed2872f6d2e181636e113a09db1ea0aa
MD5 30ec8d9fba7fe0fcda9197a4f6c0b6fd
BLAKE2b-256 a9e12eb0e3c3c9005c1677034b0fd3d438acc60e59707b1b668d9a85191e8260

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