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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.15-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.15.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.15.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.15.tar.gz
Algorithm Hash digest
SHA256 cb6eb9bb3d003b331cb72bbf9df297c344bb944d560d8c13509529e5a1f09988
MD5 0dcedf681b70726c28fa1aef1653f58c
BLAKE2b-256 08df4a9d0c13b335ba4da755a997572e72101d35d738b22b2537ee442ce5217b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.15-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.15-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6216667e43684b235f87d99e2490c5cae7209ec7e04268f063582b3de85b6c2f
MD5 3714862a4500006c86ebbcaf0567ced2
BLAKE2b-256 a7002ce7c11a0bb640de8c99ef31d954e1f5efa5e66609606de96ad1f15e1913

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 07336fa1be5a41693292ee3a242fd8a0d49ffbe63dc14df6c11f6fdd3015327e
MD5 be46810f96b51c5f6ee003a3a0d38b05
BLAKE2b-256 dd0661b2edc2e1048e82cbe1a1f5f653b93c3c7891eaec68334c81608decc80f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 65d13ee9068749a18ef74efd64ec61de0699e73545b5da8e18aed62e490c3bba
MD5 747a6953236b2f17806c0f9a473fe3f1
BLAKE2b-256 f117148897b7c318733a269e629df90338637bc2ec98d014542a1a4377ac96da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e162ba8c408e10c5e0969ed5ec64b3bdef3113a45d49aa1f48bad0242c54054b
MD5 7c9a5547a6054126598174045992dd92
BLAKE2b-256 7d8d67f475006df397ec519e4193027381864f3f0b7d53c797ce6e069d5073a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5b5549f83be613ef721b933f8db32dbb5c35c16e04eb7ec01a4a4a8715a5d5ab
MD5 b1719cfb91274ddc1fcf8ee140e4f8c0
BLAKE2b-256 28a8b6fea91c97d71c2c88c1977030e7e1684d136171b0eff8dda766fb1452ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.15-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.15-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07d1599c2066ce681ce8d8374339f109311f89423028415f31070b251e179c15
MD5 feb86eccab95f712cba7b74722d028f4
BLAKE2b-256 f026b5ab904d060f91a336b0b0e9c0dfa6d939d7265fdcec9a350a428882434a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9f2c7541ca6922fe26aea1281d56b3b34174ad7ac6e17859fe71744cea2bd9fd
MD5 4ce676d2d35831278d378ab1cc9087c0
BLAKE2b-256 0f8d77e08904a7346f4e7edc14b0fb8425ddee33082b3240d380a8313ecc2b25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dc61d51596417d5fa439f9a74c793d7785a5d683d393262936af2394170dca08
MD5 485d218ab5bbada01c7267ac4f476447
BLAKE2b-256 c6b1541b5c11e2b3b040cb1d0e83d4a457da756d0d30cff191a4b6ced86ba4c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e69fcb1002336011e4c5157c304a1ef85cdf00f215fd1be857f38b1464e66a4d
MD5 03db9aa61d11a4d81d37c72da8993cf2
BLAKE2b-256 a05dc3a00c0123c9e96aa3018f4ade541eafcb44d334e9297d9a2d1a45a822c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ea02b9fee0c87dc9cc95aa6eb39d5f5d449849828ee3b16d210d0be38f2e585e
MD5 67a29a3c21b02544d0ae68731b75b31a
BLAKE2b-256 dff1ee78f7641942cca6f410ec33ab9be9d7411908b8907eeca4de28ff0a6621

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.15-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.15-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cc5134deffa3aefdd12d469474ee9c35aeaacc6c0f5c14de6431653fd712c0a2
MD5 d33ba766c6b0a2ff2158f8aed4aad5a3
BLAKE2b-256 7e98bb01b82de7cecce40540aa9abcc405a5270bc7c37c481cdcdbaf732b7e97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c68621b032459d00fbeb2a46b254f3dfc8264af73f0ed8e27ca5667aff7cb4c
MD5 904a1668002aafb9acfa7dcd06d9b641
BLAKE2b-256 0693378d2a5aefd1cdd2f265c58f8003aff1a7cb2601794efaa61154e1e727f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4ac3f5bae80a8e58f6c6b68682b64642d3467cd0a7c0f08bf6d7db69fdd1bb75
MD5 5a716c0875fbcbdfe3a3343acd1fd8a2
BLAKE2b-256 266a2728d9085454bc594a21bb5c55de7f563724f9e88580f5f9574fe358868b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 360251b0ca1e2fc7c9884ec7156ab9257a5eb07d6bf3486a7055459f32f0c0db
MD5 f87af0ade6c59d18fe4a6ed70dcf9b2d
BLAKE2b-256 6985c73007aa15e90b48257c1f7225b119cf63f26facb53097ecd44b07b68f65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a7a25ee50ece88c6a966a947eafde762a33e05a3b15f19c2817d60aa78df31a9
MD5 aa033e587865f60fafbda09528c301ef
BLAKE2b-256 702f16d29cb0f1ae2b41b36311cbc1ed1df90693e5560fcda33d7117b92977bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.15-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.15-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1938425b1851886fa1bb01401bdc10a94d35c7f69119a42b9688de2a367c90f3
MD5 d325855253e7ff05ec6b15aa0da817d5
BLAKE2b-256 48a2d5edd89f2885581abf1d528b3d7a822b0cc82176194f7ef2b443f5b198a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d7c12cfef80512043323fb4d05c62ce69723678acc4f61bb1d390c4d813fa88
MD5 cf8e25a8636618dbbf5c735c65173163
BLAKE2b-256 782ae90fa8dca5013b04ad4b5c87b6260d5429b9086c83c741e4fd0c8959cf52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d092979d2099e22b5da5501cf28448b7a2ef795c1e32d494ca72bff49e988c9a
MD5 f0f115f5e44c724d5a3a75402a37dbc5
BLAKE2b-256 99d83a4287ebfb572432b52c9f7ee909d718a56e12964c6d0f34345394d7dfa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 116e7b77f58a38ab3207f627be6d21ff74f979f026aba4e2691ce3313b21b6a4
MD5 20f5ca4f7ab16b25b4ba408389655f33
BLAKE2b-256 da439e1ba3746b060e2f1ff5cd49d2488c11b39c9846f4a4083ea6e2ec0f52be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.15-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f8bb74601ab69ab064466a7621cf80256846cd0bc2d2d6fadc9838b5209784da
MD5 8dd5d4356364a5c941d46f035b781793
BLAKE2b-256 0333ebd2a438ba2036f7fbb199e13963f948a3747ae1cc90c901bf3987e5f6e2

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