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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.17-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.17.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.17.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.17.tar.gz
Algorithm Hash digest
SHA256 71983536c8db6d57591d532e776e3e879cda1c421ef6239e4a091b4b5fefcf24
MD5 960d6f1286a568ce7b14f6c1f22a13fc
BLAKE2b-256 b6ba4d5cfde80162be55956992074b247379b8e3ac2e275d48771038a08ddfae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.17-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.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0970c132a5359c45dc96a5dd3ede830a7892477836877bdee4690c18cad82de0
MD5 caf73ebef357a0510d7beaafde470562
BLAKE2b-256 57da30dc6978a9711d2f53d777abcd7ba87d3fc2b5603fa00718eb0aa3528d7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3bfb2b14163761478ba2896b9e95212b0edc7530e02791b9f7eb683fe02c73fd
MD5 fa4362c1a1566d33b49151070dc5f1fd
BLAKE2b-256 a5e77768fd549b3a042f35c21a43c4dcd1a9a0116181ff124683112398ad28bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 43e7c65b2f54caadc80f56eb6667b42aec21ad94203f23a2cb31974bd114b3da
MD5 dfe467a965580c87c49dadb9eb1f7b96
BLAKE2b-256 fde344a39563b9b42b7eafd3ee08b1a513188d17ca3640fde0f53287d74af219

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e604178da71ec2e3724d3f6e780aca7e6bed93d13d6238de6c7801539a97364d
MD5 8a517047ef8c2e20b1aa74cf7da5e91c
BLAKE2b-256 804313a04f388dc1f2ac3464b41f748dce81654c7564b67ddc6bbd2f35fd6843

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3391df8cd42e7cac0c83df08d177c36e170fee11a300980d5708b1b3526a7cca
MD5 01bfa1901bf2e01b24824483bf9e1ed0
BLAKE2b-256 8ddd7dfec69454235b0423e51d60ff70c7127114e33e107042d718de1592466f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.17-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.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 43d4b6f519e9411e3a62da47d8036d4fd9e40fe8643d0a0cddb759d5dafe50a9
MD5 b2af1c9a60e2c31d478be97b8a4911a0
BLAKE2b-256 0d41103781df4f82e5fea388e86058335641bdbee885b8db0d5b8d31e22c907e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c56cb3faf6220b568869cb281d4cdaeb94519e4c647e266715146cd7c16ec44
MD5 1ed2d567630f3a4d473acdea0c30ae2a
BLAKE2b-256 f0c4d6d8a954d6c793581540b0dd45a85266561afb999f68d97ea794aedcf87f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d5a91bdb5b9e7b5da2e8a489b7bde27e4adfac5737e9e5cf366a33b1b6cffc84
MD5 fd1332d9d3386425202e40933e237d37
BLAKE2b-256 948f01810ba855ea2150188102acde220715d6d4f53d81b1054122687d8105d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 035d18d47b3a337d33ba81a4bf6f6aa759cc876183f7568790b25cf09e17e41d
MD5 01709061ed19629888b9344eae51488c
BLAKE2b-256 eab7acabf178cfc6da9249e99fb0c7a80eae5884ab8fcc00ae6264a20913ded9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 02baa9c77935e2d2ca9e1e988b9ffb20a30be90634cef75636f0bf7df3c879d1
MD5 215662667bfd4f90a71d95b80e4ef096
BLAKE2b-256 e6d22a658f6149cc5e388859915c3b6812fcdb672f3e140d1cebe641e6958a63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.17-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.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8c730d47e3d21ae5cb54b7c20b6b627cb0801331a30e2d5a48d1e5fc9c7d2b2a
MD5 bea9c0ad32b01e0070dea675eca39c35
BLAKE2b-256 1e0e58fc92d3ce2299baf27e932b83ac47b409e00effe939873380ac9f456aa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85c46ab0589894aaf84b346bd70dd247e1b409ddbc27cf3d731d7f72510a79d4
MD5 ffb2a24eab39a0b00f5cd242e18347e9
BLAKE2b-256 ba7391ed7ab0dd4c68aeb2c705757cfa3af22648204df318aacb7864e111f1e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4778f95e3cbb4f0d1bdb6800e8888282ae68f8804504233d5f24a4aebef0c2a0
MD5 fd94b260c61cbcff38ee6ffc13fa5a24
BLAKE2b-256 6e3a051a392540b8d74542625a132ce1280913580ee459e8b9e262b016a99daf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af8f7059132f2e53fb01fc0f8e3a6477c7d4e68a6da0e0aa40e7f8bd0c021503
MD5 73b5f314bfb3e188dd4834109a5d775f
BLAKE2b-256 1a568d04f0951b1393579e22e14051f5877eb3661c924767468c0c4f34c6d58e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 463c8b0e399d887e52d2b924ef21579711f83dac69b549e4eb6a53d8a2a019d6
MD5 fa162bcd56070a1341ba27b75f55eca8
BLAKE2b-256 a8c6334fa7b3e3fbf10ff64c52fdf972a180d93c02e90b3c299a60f1f47e1cbc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.17-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.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ab5874e2e86dd7cb51e16ee392b3d38d67906e5879c580fb05d35e1ef3fbcde6
MD5 6b2d2b35ec77e26c2c2971ffbcb3ce19
BLAKE2b-256 3642315d4d5295fc26f51d3f605e1204d90a6caeb0859a585e4e9bbab0a9ba9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d30322fe1550753d87cdb25b997cae11b20e19e96fd48c1686f37d92edde4ce2
MD5 ac20ba34f19d969249400a7d000947c7
BLAKE2b-256 580beb4d5833128bb9d37c4b5a3c5903828dc86228ec6545b6862f76aff7be23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cdd72b9b5cf204265bd9980eec605d3f3fa2a42323073d9afc5bcbe1bfccdf9b
MD5 e30e8ab013e155897c9aa950f2485362
BLAKE2b-256 0f21f5919e8c94905b79fbb7969eabe8871e8474b5eba40fc1a723ba79863ed2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 454a9c44b84e34aa54248bca86a0ae00626532e1f6528dc5dc05e51c17ef63ad
MD5 8c39cb5e8cc3518ff0c3f81db0dadfda
BLAKE2b-256 724368790de56a24f479b5be8b29e14e26b4a770a5e054e3d197b1d372d71e7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.17-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c135755980567c832d4d94d157fcb439d05c60c08bad3d78a1bd06e88dcad690
MD5 fceaff61e2c25f8d6d223a64ea67c5e0
BLAKE2b-256 5c28427c30a55208cef223683c26c0ddddae7f3f468f425db7daf21c5cd717f3

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