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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.13-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.123.13-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.123.13-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.123.13-cp312-cp312-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.13-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.123.13-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.123.13-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.123.13-cp311-cp311-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.13-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.123.13-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.123.13-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.123.13-cp310-cp310-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.13-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.123.13-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.123.13-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.13-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.123.13.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.13.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.123.13.tar.gz
Algorithm Hash digest
SHA256 33eaf94c00b63bb34e57ad9169d10deed5df0354b6b2a100ed0f3e9faac4a2e9
MD5 4d690a8caecc78abbb5bf4fc5da80ab4
BLAKE2b-256 0f853a6bd022b9217e02c120f536a0346c0c48c32086e28baade2a01ec48c87b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.13-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 bc5e1a022d51f176632ac08296a601200e3426dfec6a2088d66ace7672d919cc
MD5 6c7168a3c9337e35a32458c5815e1ffe
BLAKE2b-256 bf73a97e95dfc5464da30f5ded111b9b36632ee6020ebf719f02612942b9e732

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac7b7f13ac1653cef1248ffb64bb0a1dab31b37b696291745133d7204c732ce5
MD5 c74adcaa0f35bdcb456d1f47f528e255
BLAKE2b-256 2f4ba3f37330c7167adb2df040d55cc7dfc5020b4125ffad3b36101c79922d8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 780473f6cf1e152f5432df3f1bd590036bfae1631d29818e1dbb4421aeccdc95
MD5 369af97fe5b06a235882be5a2590d164
BLAKE2b-256 dfd6d7a430c971b1f329e6addf371f1cf87058264117313ce2dd942e88d54b01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8dc073e17ba76c0efc39b81e34de6b4cc3827df100f71591eca7727ece87a04d
MD5 1a70f537537053f969b10b9e5d8121a0
BLAKE2b-256 f08b2e9128656ffec3df00d6d5e21394a2125654ac30066baaadba5b391a8f26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d4e4b2007e711bfe6fbcef0c03e4798f35008b3a1b5f9fde105c7174ce5998bd
MD5 8e552d75b667e0855e626edb8547018f
BLAKE2b-256 ad072ed1a4708c12c5626603d4431a11f5337791f56c78391b7bf726ec11a038

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.13-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c3ed697a74ef32a9782ef74fc2e337dee69ec1e745e6172f59ce0a42a38025a
MD5 aa0705e416b59330d683ce6cac9c80c2
BLAKE2b-256 288026153091251b41a631eec60df4ffe6f1ac0aeb941fdad253813bc7133b8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ea0c208aa43d2b0f796b6a523aeb236a1f82405cdf527a60fb70b124309b5858
MD5 3f5fd21933d656872d4bef182d659a8a
BLAKE2b-256 0e0d0e8394e00ef883df132e1548b043d238ba545151645b6c211966d735f31f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cc169135032a201aec6616a62e2341040df80ef3d108172621c3b868b3cdd8e4
MD5 5484e19a5ca80c7f45da1c5ad75bdb22
BLAKE2b-256 9f3653c486dcf7be6e413ae313aa8f347c0546d8ed08f9324342942b0446fed8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c315bc0d7a2b6352624a0f6314a926cda583889505ad072681847b19c2978778
MD5 77462357acd8f95fee9d41b60a8b004b
BLAKE2b-256 76e93e4e85c34011fa3fef661e8812492e0fecd4d2928da8abed9f1e95c85572

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f7ef78302ea83a066ee78a0e94f6d2685ec04873a474a417418bcb845045fa74
MD5 67f37e690e61d90a9be8f1794dd97b93
BLAKE2b-256 69ab096a5dd2809e716ba2870da259f849314eb2ecebd1320aefee3fe41ccd98

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.13-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.13-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d0ea5d8d749d7457d00f10b4a5f7d2e20e8cbf0e9a9165de312fb16234dae5b3
MD5 014feb26316ef7d607a0f3aff0f8a41b
BLAKE2b-256 eac9f3d893683b35bdb6a5d896997bc26921f73befff6991588270aa6a95d694

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 21e18e65bb4b17643d39b2dfb0c7a7202b7a78557c027de6a5a55101b62fb0e8
MD5 b14edf6f5426f78d2a0cbfba3c213cf4
BLAKE2b-256 11a4c2f0abcc4c1bd1a8774d31f37d9fa97fa9f26f3069555cdf21be940957d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6092b32f6c0212872f8adceae61ff7501076b4621c9f5dfc3ddaf6e408b6826b
MD5 09ce1cce6f703fcc23c1dd8fd4292b8c
BLAKE2b-256 90949385da9bc0b0a92bd04088fb30721617f25f90981d143e2774f884c0cb65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1aedbb7157398030f26107dd36c2f716b589fcc17081ba407f628c1a89a84e4
MD5 18038235f10b57e3fc966aac4022c05e
BLAKE2b-256 fa0f68bc4ebd71fdf4e8e80959b6adc70baa97f2387aa6286d11d55fc13d647c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4dc880d90020f9e540715be3415a3408a88e296cd55de6d21c4e9726315f25d3
MD5 61815082918de24e29d90d60ffb00110
BLAKE2b-256 198480aab7bd6513d285282c68f907034128c9c140916b632523f2cdf555acf9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.13-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.13-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 572f11cce6b327bc4eec63e3094bd7fc872ff4cb8c98801b4120a8ef1f6215d4
MD5 450d946c5ac29536787a3b57451e2c75
BLAKE2b-256 9073bcf474d7f34c81d5d257ed4d1dea3c1efc473730d91cd368bdc0c6f05e32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d16148554de8afb58b5eb2065a836f5f3e1696e40bd90f6b1473937d9c357d56
MD5 f964c3561d38f20e64204b4a80269754
BLAKE2b-256 ef6082d3e6327e755c74104e872448261f5aa96f2725a2abdf1ecfbe9da40bf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b89f384ff83a6fea2dadcb6e98f6751412325a16e75915f04eef45d6bc8cc338
MD5 c48c820228a0a72fb8ec294f4d122876
BLAKE2b-256 b558aa804f942602e132f10f94baab396ebdae0ff34226c46e6846b5648f690c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 398b6b0f88b802e6805706266e13feedd354c129c4863aaaaca17525d8b329fb
MD5 5986076e927cec3047ce08833a198704
BLAKE2b-256 dc8080ee5f51fdfbb0033717dcdae6b628d5905160877a80ff040cf2a29fd86d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.13-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1ecdc34e855246386e7e7c370f63090556e3b1228661ed6c98c86d8482195e90
MD5 20f0fe68e7889c135576d5919229bacf
BLAKE2b-256 a2db358a27fcbfd3f4d0bd7dbb9955bf3a594c1b1e83784cfe94d2ea9d58f812

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