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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.14-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.14-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.14-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.14-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.14-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.14-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.14-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.14-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.14-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.14.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.14.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.14.tar.gz
Algorithm Hash digest
SHA256 01c1c20989d3210e3df3e2a2d23099244b82e5baf9ff53a1281a478bd6f6c635
MD5 e4b4d89fc54fbb5f30cc1827f56c8144
BLAKE2b-256 d23e986d72f76c6936441e366aa69b91e6cd707510ecc8868ee9e018f8728766

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.14-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.14-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d731af84767177ff355ac4058139c193dd2aeccce14e9764c5638ad64d79167f
MD5 42faa6ae664995ea09eecf5e0a7768a3
BLAKE2b-256 bb983df69da26dd75b86cf8832bc9c19e659defd4e2637489d983677932e84ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1fafe4fe123f21ccbec8b07000d3e007f11723c6788baa854cf1314e6a4ab7c3
MD5 74ec454319b85df306c5a2aef72851c2
BLAKE2b-256 b8751192a1cbfb082dd4e6d33d6037ff2ee076ca941d1869984265ed52834c1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9925420ee2706226d0f34800cfae0d0dd281cc05d00af48574068fac89ac2695
MD5 b0366d98129a4a5fd4d5ccfee383b2be
BLAKE2b-256 d197f2f24ddac2af90f5cb973bd450eab6c58652f0fe020963adcc5b51804ec6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d112afda7ee039f6a3fe258003b24c8a583e482f9f0b057bdd33ed509758839
MD5 7f83a805803ccfaa69a9db9f1085ae36
BLAKE2b-256 642d44a8645513180375e0a92322162221d5a9786b3aaf6a5df63080fba1247c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 57ab48e0afc658485a870d408931b0ba2b8d250e2267042493749523689fe49c
MD5 96c06d73d497789d1eeb0f8c3526bd63
BLAKE2b-256 4919df123952b6e2b12e681f61ac488aa1e03b482bef404e981120e19ed8756f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.14-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.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5e78381594018a8daec6eca5fdb1f6f92e7c69052cddb2a4efce60233034f3bf
MD5 73672db76dd5668fc6df0c42654d8f0a
BLAKE2b-256 55bb3da0f1c2cb3233e71c697a197069022dfcc567101ba0a0dac4f2e2c85230

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a3ea1a6eb540aeb14540966af81807e5e604a80a329c6350eab239a61c24aed
MD5 40f2a87296e52425dde697a016ff381c
BLAKE2b-256 95c2afc76c7962df54ecfa11555855b59000850498a68e8339d7aee55dc46b33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a6d44f90944337c720c284cd03499476ad89eb394bc774acf81b7ae5201f7c96
MD5 192ee1a294885d19cf4130270e8531be
BLAKE2b-256 bb3e35e568d5b69ddc47eb4b371193f2d2fb555c273a3798439da306420f522f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c755722f303065d6cfe3b5f9f592db542f515708f610c2ef61bdef85b23880dd
MD5 56a0d8b65fa3a3335c37a8e7f4863392
BLAKE2b-256 10f67e7560f86eb9bb8f8182e486d236127601ee61ac4927f487b52688e9f81d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 10b80332389bc9ca3b699d2765b939bc46cb92f9269c111855cf882b67377b01
MD5 465f9a2f55047d68a0112c1ec7166557
BLAKE2b-256 e86520a10a901424a54315fea4d262ab514e5fdb27b2620b7fe56c23fac5172b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.14-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.14-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6044acf73910d888e672875210053a5dbe8bb2dc4261855cf932e830aa6b66c7
MD5 849855f26bbd5950bccdce5d8083a412
BLAKE2b-256 29083413fd05ff68f6dab4293661bd084320f0f58dac05c868926e8a4c50cc79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37b757f1a52bfba6068d1bb5fcfb830181549a51f478a9963717e716282233de
MD5 3ece02782141ccdc77be1e8355735151
BLAKE2b-256 62dea389b88bd23ed47501457469850a43e88119005955c94a1c56e4785ea300

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 078a3f94edd13c0dd6e5ab386aa98822311ed33acc2f6707ceefe6072909e4dc
MD5 7e5fddd9353c7f09ef034190340acc62
BLAKE2b-256 38df4005c46cd9d93328cf0978fa0addabbae8cfd6587597a4f3b3cdd012e4d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a0aa8292642e691a9aa0a1b0516f29e0ac8bd208d946e9a6dfa511093dded95
MD5 f29c94fe51fd26fb57015baaf6a1cba7
BLAKE2b-256 29f61ef5ec62f5f96f86d73b69b9ddee5e075f1deee1ea8d896891f249271915

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 db5ae3059e9f76c7dc3f3b1bb7df4c7fbe647351562d3edf26a32d47a4c205b2
MD5 a2f431a5f513dba33677bc873558dc01
BLAKE2b-256 3d3f425bd63deb178c33c333b69543e8fdb623ba8673b3e7a1d5eea210d2f9e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.14-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.14-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 06e8a42ed3e1af6e2ecea6bad83cc85bcb29dc724512c269502a3a1ddd8f4653
MD5 d199dc6b554fcc4bc81e02f2dcfba01d
BLAKE2b-256 4f0a086a5a7022fb3afc30bbfee7082dec8ca9af4e166b77e5d2c7d3e89a6513

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c28aac001c1e0b13c08a3c13dbd94dc5e443d3cd2b260fda3186c16499c21c2d
MD5 cd05b9c83f5c3ee0582e0800567e5f13
BLAKE2b-256 9ee8f059b20d0286ad2b4426957acf9d68d736c9c937f1091b96d497a91f0fee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cee09c7bda347052727b9dc1fb55eaf380555267212d8319e9073fb5f05ec5e0
MD5 f32773f320c26791f51a5edb380520f1
BLAKE2b-256 a258336db8d85c2cef92a254b53151accc6230caeb80d4f7f3e72ff41d802759

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 62c4342c33e70117ddaddaba9f8fd83a0a1bd54413474ed088dfdeb77ac6d7da
MD5 8f52694aa842b190c1a3eb7c88952597
BLAKE2b-256 6ffd823fc63c741c18dfd8abe6616fa266303b463199d328e9c63652bb2dd029

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.14-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f0e8a3a5f5c486a8b3b389611599dd1984440e86f7cff89d1cd16d651875f6b8
MD5 55e47fb3c9a27e08dadfed48a8ff3096
BLAKE2b-256 922c72370d6260ef4f75a2db5577b86208aeee02e6606ef88ab9299c9a0bcc81

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