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.22.tar.gz (1.7 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.22-cp313-cp313-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.123.22-cp313-cp313-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.123.22-cp312-cp312-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.123.22-cp311-cp311-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.22-cp310-cp310-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.123.22.tar.gz
  • Upload date:
  • Size: 1.7 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.22.tar.gz
Algorithm Hash digest
SHA256 fd3b2d3f29284533cfaca1de903e3ef00c496bb18e77dcea8ec9741fd35464e2
MD5 2852ec0da70ff4566e28fc60d2addadc
BLAKE2b-256 762460957ddb8a83420a60405222821c3cfbc3b7b02bca3c6f5a12a451edf1b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.22-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.22-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dd7021ba20a4270c8a77c2c7cf90ffe6bd3a2d2ce1f1681cb3e7f42ced9c0674
MD5 89592668230a7b172737b203a19a8694
BLAKE2b-256 2094a31621bd9ae6fef2be5b6858008499cc339819706a3eb41c1011692dc54c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 83f3f52aa3edfe7efd0231ffcf0ade591cb78242cb92c8e6ae3c95a7e972a5e8
MD5 ffb7610da3f8393c3390067dafe08f16
BLAKE2b-256 a3cebe02d28000f21800d7263c73ff311b298e3268d2865a6fa99c5010480976

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5dd9806b366115ae175a5112bd33ceb49cf933d62f0232ca8797b86bfdc2509f
MD5 b60f8cb18c5b750da831a31a8913f22d
BLAKE2b-256 e911560b19aad1306c3d5ef9b78cf4a796489dbd85f6d98a631bbf45c79d7562

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d08651d96a1007b6b106ced231bd2cacb936882d8f2d3ddf564579b5b2dc00d8
MD5 fd97ddbddd3b32b53b663a358a02be77
BLAKE2b-256 1425f66e5e22f8858bc70420557c378e23de56a3c2b448774251f0b8c44401fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f0852e794a5b3ec303d7e7d8d594d5578a646adc501a002884f13ff07c2e82fb
MD5 8e858fae918e80b128a35df345291b2d
BLAKE2b-256 536534d8362d6e640389fae8e163a031b6db22a11f5fd477ba4ac0f657e465aa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.22-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.22-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 aaa34ef198ede89ee43bef27417ea4d4b069e596a46ed96235d898f1c50137df
MD5 0b5df325fe5c7866e7ed628f61dc4af6
BLAKE2b-256 7f3d08853666b84edcf5ac50b3dd0dafeb8d1edae8f4e56239b45d848aee823e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 08222dd203836469cbd8fbb480c2aacccdbe2a2268daa9701180f76f91a4c19c
MD5 33050b17eccafbaa384ec577792771f3
BLAKE2b-256 37ee540e548396964f137f8b6405946bbdb0c5d791726a75e30e9b8b8039e858

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 716f947a22c3c486c98deac8609e2e069a98aec0190c5effdcd011009c1bf9e6
MD5 99e1eed7195cdfbe7312883a5368a907
BLAKE2b-256 ae4f8f9628763856145e2c8329c07331d3c4ef04e9fbcb5c266b11fb45eac194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c42510a028c3ee57767f81c23e83e7b670be48f62cfb76c900c6de22642b149c
MD5 d6ffebb5dbedfd99609aa024326e4194
BLAKE2b-256 185d9863835bc15f9ad49bacd32ceb31fcda347c35c304cd32c4ca7f10390674

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 02ddcbff3d6a4c9e40da4db4705e6cc074e84a8b52bcb9a0b378be4daebe92e6
MD5 863b501e80b44cc0d399d470b266f033
BLAKE2b-256 8e1c5626bbbf83598a3eefd3679160d378c1e03b4709ac0652693f961d074f6d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.22-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.22-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bfd0ff5f78ff438376eadb02fa7fbf18eb901d053ad7b0a64edbf6086fe858d0
MD5 83b0cfca197d07e2502ab8b50be744fa
BLAKE2b-256 e4a2bef2ee7567dd8670727233b774c80c6361caca6488617f15c281070dfdb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3f4afae1fa59d06cfd02c2dced9573511bd7af31267f18728495530cbe2f645
MD5 32948699936f838ab9a56b62eef5bf1a
BLAKE2b-256 2ffde85cbcc9e0080af6d291a25d572cb82db02b1447ea886d19ee608f64169a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 15e4cfa7bb6c7e756689687099993cced3cf7e0a935789f65bb4a4ac408505bd
MD5 602cf39f473ff0723830d0a89d4fc344
BLAKE2b-256 4cdad318795c74c364c4b7d6f0a171221f661b4ddc3ea86fe5a750d3223bfcef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b906d09cd0b34b7bd25a33129109b81527e906e259ae91ce4d75e15529f935d
MD5 bf04eab3f7c6f8cae74e264c6976aeac
BLAKE2b-256 5d3956092ba87c01d48a9b32456b137e0630ce803b7fee5c81f9dd0696768f73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e69e95e11cd25ce42852c7acae2ca50da90bcb673cb7e81889752410ff14d628
MD5 e34e5b3fb9e1fdabb9888df99866d873
BLAKE2b-256 2bfbbce335ece5406e87c536d4014e698571ce0ca479660e849c9730a88a7e5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.22-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.22-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cca4106d348cb3972952d7ba1c45691ea615e63164ad05da788311919071cb4b
MD5 dfb219a52d36750fc1d7b1b746b40b2d
BLAKE2b-256 a84e29af4275a02b9decbccf2590c242d86b9b0c2354cf932093e5531b78dd23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d647dcfb1779bdb4f0b78cf7894c80d4e68db4270fb0c93a1dc49ba7e29cd21e
MD5 ab1f6c3e1fadfe819d96ea5115496aa0
BLAKE2b-256 4ec66ed862c3bf4286e3ac8c99107182791734f317d1ef640f7966e340ec74a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5684cb96f5ac782a6a7d2965aa2a7fecb619ae92f12939b1a3a075c71992628e
MD5 18c10cf86de55368b0e1a6d664892cb8
BLAKE2b-256 098e51744e8290512f3ca488b02ce3f122db87b67bea639cb2c4c62d7e63051f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95407c12177cab8a6573b6b830bc35b8b2495cde76ac183b0c787ed7ef586d4b
MD5 d260ba7d8e1c70988a193d1aef25c23a
BLAKE2b-256 ce0e4749739f1d1926e51f2dbc8330f1cdfebb93aa6800508ad9d88f5907e330

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.22-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 637d98318b8329ed771a68210f0f495282eff9670f04a33100a9d2e8b6768e56
MD5 a10a434992de2e51d59978060278bf7a
BLAKE2b-256 403e0d81ea0c6c39633ccf78f33b865b0d2f183b8d05b96ed642bb6532031a94

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