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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.114.5-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.114.5-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.114.5-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.114.5-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.114.5-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.114.5-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.114.5-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.5-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.114.5-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.114.5-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.5-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.114.5-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.114.5.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.5.tar.gz
Algorithm Hash digest
SHA256 c5ef76071e6f2029598f7faa92f51aeac4f4c118d5873c6e820344b4ab69ace0
MD5 3697ea94eb23845fd54df0c32a2fc5a3
BLAKE2b-256 8df8ce40dda6529e9f80ba8ab151f614637a180e4edbdcdf25ea597ff8827baf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.5-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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8048f371cc2b94ce9a29e14963cc9832b6b827701919cd0804a0d8e06cc90a5d
MD5 19597f19e680ac79c1968d64e1934917
BLAKE2b-256 159f589c397fda41b6e85e3ccae505f8eab9144676076ee67057a091e25776fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 326267ff9f47ddce3f71f216631ce6e412b7837032f4b5472398adf9c6ddcefb
MD5 38e06894a7160149273978a3a8486106
BLAKE2b-256 81b7c79cf9bce00a36bfc2c870b33676d27a42f75b30fce7ec847c444f7fe040

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c3cee66c4a98b8fb10ed939807c0dcb897b51cc0702ea46fe0519e7cf29031fe
MD5 a9db67a029841e31f82ae1a36ac2e2cc
BLAKE2b-256 b7b2c40e1cc89658feac619db8fa88abdbe27dc3df78182036754293aa08da04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f9c0902feab9181ed2ce4b2c4fce7c3599814391db8cbc5d96804871ce45fd0
MD5 490186c62b3e4e1674ba9020e8ff7491
BLAKE2b-256 85e1ffcdb1a38f151b364ec5d5d6987d30a80ea5c4165c435342c86367cf3e37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 81a7836cf57ea65b03c4e7caefec685708a2e971f2019543d0c604bfaaf14619
MD5 ff661a2660e4e107c222c57213be7289
BLAKE2b-256 eede4183f5f80f4d7db8b4a6c2002053de13a2cf7307b98e2408ecc6a17ecd87

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.5-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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9e5e7254c5568d74bd392129693cda0545a3d34ac696a04d9bb09627b85e1922
MD5 185584e6b6150a436ee0f0d9823bb02a
BLAKE2b-256 057023556585ee82eaad9a77351db3a062f92bd24be1b60fa1f15e177b4bc154

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9d0f2e10b54fb2da4c9621f5bcd04a2a37fb9730eb679e96b7ef37674ccf4699
MD5 1d5cffa035439e9cdfea1c8cd47497db
BLAKE2b-256 d7bfa58c88245a2c3fc0550f6f37cc67ecdb2791a05da5d0ba30c0679ffaf710

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 050788bdd834cd33b8cb6817108a97b00914ebaf29b808a25a3b786111d481d4
MD5 f653f923f94c49182214d24445308e0d
BLAKE2b-256 8ec1a45b1ed2a0ec973b79fcaebf0dafecdbbbf51f82705851eec60c95a0b4ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 15d290932e6f18776fc5bae4af80c30cedc9ec57707e7d9ae7b8a8cf8e2cc1d5
MD5 a2a7e2c0c63daef693233bc63249ecac
BLAKE2b-256 4473bcf9c7b02623b15e80fd804f8b0b0ac3d299861a4099b70f2a7d4ba68769

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 eb158e003c65f815134340409d48abc705684b892ab1b5b969ee8ca0c28d246b
MD5 11eb736534d1ecb72372fbc1af71e6d8
BLAKE2b-256 566a044388769c5da33080e0b417136a41c712865dcd5de9d510bbbad4c1189c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 73d5efa43a8ecbd840ada1bdb29d0d61f3be06395cb212ac4557571e84bd2400
MD5 d947dd081781ed7f1add3bb9a2efdc21
BLAKE2b-256 98bb0bcfa2af3d5f99b0f11a91d144af1c7c4c94511bc02f22091e0f08c7ae00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b14113d923eb4f995ecac89f6b9f79fb22a74cfc861f65d7fc2281be39efd311
MD5 bdd649061041ed724a695d7d9e83ade4
BLAKE2b-256 bfba9c826e19792e02adf87eb1954e073d6968f827ec96e81ec0622dce04c1d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 019300c020dc53fd8653a66695cf74cc9ba1f04c59691db599be7ff2a8c60714
MD5 1d7d93d4514d63cf845377ae15743dc3
BLAKE2b-256 8e93df45991276807200fd9b46314cdc15bce5dcd626509e85891cbc66bbb1df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea7efc87b162f84008813d3c205e64b48c520a02dfbad6885b7640694b301ad3
MD5 d4d192a5aed3f88f2f673059cbded2de
BLAKE2b-256 024b8231d019162ea88ae18ae6f2bbcb352de83c09285a7f9424b2e097ed7714

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2f122cab3fdd1801f9cf7c49a996836d1a9141c57d1008116d415e199f778217
MD5 7b508808343ce779c9ca67b5d2054593
BLAKE2b-256 8554c29fb81aae14710d012f2cf8b4a23b6708a2b2fa5f53b8ac7e6af33f3abc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.5-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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 acfd350585bc18e4a08f396b16b571a71a2ed0d64b455b174d7d8ffcf769f260
MD5 57f37fc75660bdac8049b93c7bb98aa5
BLAKE2b-256 ae884c46dc9f377227ef7565bf4dc5741b9e6e2f9c2e5bd55f1c5aeef7d67a60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5749bf4cf993d2908fe5816d26d1f57ec02ed6f5a2b1441604fa22daad6d68a
MD5 8955d4e75ebfec329ea542f4314368e9
BLAKE2b-256 9847777b441945fca703395626a957f7b656ad6b843805801bf63e6b1bd5cd9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0b5c79de887a197d9128b079620f82c5247bf79b8cfa23541b0f132a8feb6c02
MD5 50cc09c636c92343398ed9dff9b9eacf
BLAKE2b-256 90785a9ac3467651287ef02ca96e4daae93b3532501d77a13342a2e7bb0e72fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59339e3615d19baa38a682c5d7206649766a7b26ba45cd3f930079a654f5204f
MD5 d8c27cb8c2637615ddd933076f76c272
BLAKE2b-256 62fb7b524c2d1db1e0bd51ad08fffbdeaea1f315b30d834d7cf9d3e477e6951d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 46006e626d7c23bbc0b37035d2852dec069ae05241c5909f229486fddd48e3f7
MD5 4db528bf0543491dace2731320761b87
BLAKE2b-256 cd5c8ab6f954e0787d2c8f8f82fbefadb5b17d8db112cd2d29d34e7e57cba230

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