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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.122.3-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.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.122.3-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.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.122.3-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.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.122.3.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.3.tar.gz
Algorithm Hash digest
SHA256 a8b75b183da393a6465ce32f01224fa9f7cba43373091f697e36e27d90b66805
MD5 82d5133906e37d700a07edadd2d0f398
BLAKE2b-256 e97ca8ae035a530dd88f0c3070bd09655e4109ec3d5fcf5f096bfed6904a0090

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.3-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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 78a6e9f22ffdbe95db2a74f8dc5973055058ecda22ef48b978bec665dd4015c7
MD5 84cbbb86fa78f409e8858821b4e6ecc2
BLAKE2b-256 d845ba4361a189aadab17bfedcdf5faff9d12e30808bb6825830ec02004f344c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7506e16b12497baa02aa778e3a4263dfffb72692b835fbd047cfbb728c3299f2
MD5 a9a21477fb1eb69a22a375619877de64
BLAKE2b-256 3d93184499bf68ae5a04fffe3723013edfe10e46693f8538dfb85687e2b4a416

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7829476df53066e6e4aa6b7da802f2297ab8907198e49b9709194a182fd5ccda
MD5 965067d3b13ae1dd4b4e31bfe96f22c6
BLAKE2b-256 1f32314e51a9655208ef081a6dc10b25053c578b31d6c1c03c0916e8ed1904bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 580772df47e5577172719eac66b2928d61ab67262982d1b9891d47f57ee81e64
MD5 4e868ae5e9d380b36f5d460fbc794f3f
BLAKE2b-256 f4e61657d7c45eab5db2139ae475cb72b92d17184b9855cd4be58b1693feb3c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 985683e8691519cb48538ba929df2a2bffbc082d236c8c4163b32aa0b0c0d961
MD5 0bd7de5b8f53acf8fb32661d17611583
BLAKE2b-256 5392bde49088b09a9587696c06a9ad3b19b6638ca08c06955e3a7fc70448d166

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fa6c1373e7a6ab1cb6b3d01a50139453b7589e1a645fbb51624613af9a908285
MD5 6bc76d1c5991049b85b6ee04ee7c7068
BLAKE2b-256 f360d9b33dfdf0dec9a5cca5a6427b6fca98396d70425f20c9e41a953a08b477

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91d618b7b031c203c62982e2513f4ae8c2055881884a0fa017667200fe4f256a
MD5 fef5120ab0a4a5bb67fd4b69c1b997ff
BLAKE2b-256 b23172d9cfacf05eeb3f4f2b159dac7ba85a5e12463a57d05bf27da5f2ca64c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 75fc671b8999119c274d0a6258914f32992a0ed24238733bed43e5aff7f2ac48
MD5 329cc97776da824ebbb17166a9ba4858
BLAKE2b-256 5c8543bf345469a29b0d0b40342a0635674637a2928377a3f2621cb1d8f292bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa5063e7eb1f9f899517135aa40f2802b3c76eec89051466280c45fa628cb07a
MD5 e2973d42eaa33023054663a55a4c1ccd
BLAKE2b-256 70f37980b2e3533bae774b9b54fa3c0ae8f2b954e92920983b09014e4a7dd079

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c3218790a65cf75b029270d601350f1aee811253f86bba29e120c9284b55d8fd
MD5 f1b96ecd1cc8e9dfcc002b48fccaa4b2
BLAKE2b-256 94986b73bf02cebbfd74337527a90f8b2e07d8aea40a740148b191cf6b27266f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2d1caf27830054e9b2b0ebc0cc63bfa8eeedcefc4f381a190b57646b68e8c372
MD5 9c40316d784995c8d855b913ed59a40b
BLAKE2b-256 115f465bd3027c0b0e4322b29bbd5b903f30b95f37a7b42b876c8213d4744997

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8018306e08280d60ec5ac462582f1ef4288774ef2bf32fab6ab3db16919f7f42
MD5 953ee2672cf119b51b2f55092d3c6633
BLAKE2b-256 078759371dbee72085493f556728b5d2d128f28acc06ffdda33ea7c4a6a96615

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 07622c36a21494c1f2132efbfd097c1b5b7991da97e79c3f37a3b6d05cd98df1
MD5 deb9d9af10a52f7d9a97ea63d98296bd
BLAKE2b-256 8efedc8d6f6ddc7ceb31aa5669ab7d80cac1c0158050cf8cce260b1d060d5211

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f4fa920b3f5b5e8685dfa904c7f30d1ab43ae6b1161333dbb938b3880c03576
MD5 287c7525d808b0cc3bf496196dd2bb0e
BLAKE2b-256 1b13f253345fb589839f429e3049bd9821caad8e7c8864371f8039d21f15164a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 82368e72bec937d3bd1d1d313276704ec7961f1a046fbf20e75186f4a9d7e495
MD5 e5484b959bb6bd2b833b37da82eec718
BLAKE2b-256 651ce9f5617c7e8549599ef39030c232f3aa2187d70b0336becde9fedd2fd0b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.122.3-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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b60fa2c37bcc5a40f48a69cfd54fc4e1a26a0a29b90602e69ef4adefe09a3a3d
MD5 f8f58ea01cc92a25b04b2b71952190e5
BLAKE2b-256 c182bae017fd8aa7d1612c99481e1593c210ae54a3afd0a91f93919a69c78adf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 17d4951b184bc3ca25ad22ec23460a22e1978513f1c4ae03657d8f5fb29afd97
MD5 3de4f0a39a176a51d6b343a92c2fc6a2
BLAKE2b-256 ffa427dd78d7155c79cb54aeda3d8fbb4892007c6900d6bf2ccf47a0e595cf4f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e263a9e2ded7a4ffaeaa8902e2ec0687f08004006c662e4c1910d10df80f9a59
MD5 5142ddf842498017e285e5a828374e0c
BLAKE2b-256 2938f42e2fb5b919a5f513e0fc8ea56396ae18017c6ce6a0f2a756d1da561e7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f07604ce24b138ba8242531f44cbb122ee1f680e87b718accb683a6761366ffd
MD5 e94b6997c7eef3dae9e88e5b6189fa79
BLAKE2b-256 b1e57457f9e25820f552854ebf9ad7cc225399e4a50b71d2ae831e9ce0c09085

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.122.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cc18f953bc88d6687ddb591e28f4791029b79c75b07871866231409681ce5558
MD5 240aac863a5cb887c8a197512fffe15a
BLAKE2b-256 e4a38400f71da64ba79badcaa3831db6607b95fb38b0d55d7358946c92413d58

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