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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.114.0-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.114.0-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.114.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.114.0-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.114.0-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.114.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.114.0-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.114.0-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.114.0.tar.gz.

File metadata

  • Download URL: chalkpy-2.114.0.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.114.0.tar.gz
Algorithm Hash digest
SHA256 7b95b4b4390945ff112270d336911e433f79d7d5db1a49de6fe7adebaa5f6ef5
MD5 e52bcc56d460cb7027449b42a65c6490
BLAKE2b-256 3e9793dbac2b7e831084517b43fc249128bdafe7db394901eeb30fcb0dbdf6c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2e2f0917b06d2957d95050c77043fe7d41ec918a91249b720d7db72a48c555ff
MD5 1039323f6849a631206d52a2a972d365
BLAKE2b-256 f6c0509293f6163b5e6223f13b38c79c7b277b110081822ac36fdf2b0a12bc50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a3bb6f439c970f919086044a19dedd26676e099b2b6711d334d4d9342773ede8
MD5 bd0537367b0087e6804bc3347ad89cf6
BLAKE2b-256 b02ed0395876580b680fd450f9ce191440fc3492bf87717823d02ce4d18493c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4d278afb84fadc3a4a9b97d564612e90c4dd1d441695ad385195f29e915572b9
MD5 f30d86f255a97c86f1e34fcfdb75ff95
BLAKE2b-256 4e282c0d362e2b51317630bd5fba88e9c13f68c08448391be73e5bd915e6ec29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f52c166842a10853561348d9cf3e1d786d03a2726b49e6291129dd18ed314ee1
MD5 f9f7ce046a79e421ab61d78d1ad268d1
BLAKE2b-256 77d990988052441811b068cbdf5aaa86db1a46c4e06cf0dc2301c7e7b059c3d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ba3d785dff7dc8ce3d121f16ade1e02482028dacff3b380b7fe3e1a9f2a97200
MD5 d3db40689521b557e6103bbce52d1bbc
BLAKE2b-256 de22faefc07ab3234ecc1899ee760f6f3c1d52955e2b29c2d8d3bc843f82930e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d8932ea7ae09ef6fd79031c264ab1036ae7e81e0400667866f94b7ccf0834ad7
MD5 48070c058ab2c85ec477e65adec77b31
BLAKE2b-256 4605cf6e2cef098b4849a22a01c7e9347990d7d23e6399c8d2331d5d620c5aba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 768b215d922cd20bd086e6af544dc74cae8e5cd007167287455671d792841f9e
MD5 e954385476751fe6f7d260e26d943273
BLAKE2b-256 608c84ca7ac8437170763171327a49c2fad6d22a59b61647255b9df1f2fc6b4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 699e5443f748cf1a51e861255e3608dfdd0cf96699d798b13b1d84c0030dfd09
MD5 eff0048fe3d946af952110ada4dcc9a9
BLAKE2b-256 1b5fbb0b2db4c64edb979a38c2f7a44f5d31f49a2e876bee404579a966369d9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e514dc408baab18eff5ffae5e3dd6f4111fd6e02fac8989a429a63803f1c21b
MD5 6b1074231d11a0c337804735426ecc58
BLAKE2b-256 e61e6864fc1ac8647a22db6d31446d4d73178e0b8d6491e40db3c49a23ce6ec6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 07ac8378481641cf63902afc7bd7b9d4d6c0a9bb3af13cf68c2f659172a1dd30
MD5 5004b8465cd46e40b8c402c662a3f478
BLAKE2b-256 5fb9d5b57d41a2a3b3771376b0b2c133e143442865ae72035b5614616cb0be3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 44502f5236b2b9beb717190ab776893ab8d3f7e735aaeb51039e3aff62d02135
MD5 b8f97646cfd774f66a7e083b1f69a7bb
BLAKE2b-256 7a8d4e1721d1fae924c1abeacbf59b9b44b7490962e969a5cb95a60edd95676d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3cf26b819891f7eb5ac0e0e9cbc40f124aa06df5d11468291ff0edbfc609f84
MD5 5e8c05de0ed0f7e4c32d1cc0a9e243bd
BLAKE2b-256 97a85986720148c946d7201852924d4f700b594daf88d6f41c221ae118d60b99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6b70a7525f2411551e97e3c9be422177519dca2b2e81cb33aae235a71fe59534
MD5 18636effbbbc9e91a8a3a6d6c62d5ed8
BLAKE2b-256 cee9c84beeab300f96d6bf67629cf3341474e1de849134f0f91ca40aeee5c225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b7efebc8904dc81bb806f05e0038a1c88be41d4dd0c3049ba74b87bf249520f
MD5 b48b25730c88744cb76a446991a99e99
BLAKE2b-256 670afdf732f82a91ec1390a9749517c67379c8a74663cec5929a7e4a38bb518a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d102d8399412f5c9f8e9b9f0733f49dd0800cdf1e4071fc6312cdf2caf96662b
MD5 b3f65cf4f435aa2bbb218b3a838f0e6b
BLAKE2b-256 cb344a66fa73880bbfa8c39f1f718ad009d6bc0d2add8f09cfe985b4cd5e2960

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fe303aa7feca66ce9169b1ed9adae566ceb3a2c022c65e773304b79a1c960dd0
MD5 da1bd0865164544d68a319edbdcd82d3
BLAKE2b-256 91023ad9acada9ef28b6fb95dd0e166715c72deb2cb5ff904108a56116213a76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 499ee6cd152c4d3d7fe1df857f15b96b5a43adde091aa6b6a83a4a7143231217
MD5 62ec1225da96aa3dbacc24317f90287f
BLAKE2b-256 4124319c0c7f1cf8004e7dade31b642a2186e2deb0eced6c71aebd8524dfbb37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 092353d4f5259c56c196c1907b8be0c43b9445e6a3206ae3306cc7733771a422
MD5 422bf0873fa3249ace1cf3865c878263
BLAKE2b-256 ae30473daf61f7ea45a9993c1ac9b0fa41345267ee99f3409381ea2fbaa4e3ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 adf25fa7a86840dd2a211cc3bbb22f49f8b6a4595676596e7e44c321a94c587c
MD5 5418c54b4935545fdd4b2e72337e214d
BLAKE2b-256 32f3b6d9ab448026211d70f778baf2267d742cb8dff1dc9bf939ffce7d3c8cb8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 919fd7a23fb8f84d3addbc34e7c2149e10420cef3b809c509546e94cc98f96b5
MD5 5b2f3ae01d03ff5c5fc13c638021200c
BLAKE2b-256 66518ef8c7fc2414e1181409773701bd2b6b04334c2a96afb2d2b176aa9a79f8

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