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.11.tar.gz (1.3 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.11-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.11-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.11-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.11-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.11-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.11-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.11-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.11-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.11-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.11-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.11.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.11.tar.gz
  • Upload date:
  • Size: 1.3 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.11.tar.gz
Algorithm Hash digest
SHA256 0255cc114e70448fecc9bb1f803f4bba419d9338a1e01defbb0c50f9433be3a8
MD5 e072056dee7c00a25980647e6dead173
BLAKE2b-256 60a4e6af7a64ea22c9882d0597208e633eec2595c3b88dca1fc4448284100b59

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.11-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.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e81cc893a462d0d8038fd13dcdba3b5c4db135b84029bd875383897290a08586
MD5 12e7a79c0004d788ad442eeb402c96db
BLAKE2b-256 fec1825f893795150cfceaf3328f07ad7891aaca59070980695c2fb1b192781d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c706d94fe53b8bbfb2cb11ba45e2af13a64959d7a794a08d1f242f9069669df9
MD5 e22b100c77c43c2e18cbfeac2650c6d5
BLAKE2b-256 7ee2fc49c3373f0e29c1011851ae6ba2128bf89a6b83705ba7918bde16b9dcd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 054c2bc5aa507f68ad56fd7dad8f905a5c3ffb8e077b6ede3e60bb3993e54306
MD5 fc3c957dd89c27f7acc7b4f243c7d9e1
BLAKE2b-256 6b456f453cca685b7ab5b503349663d42d60468a3eb75a83940f878b0af40f42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa9c17ba7e38fd55259a03d21ae6b65e707855900b38d990e6bd484fb71bc54d
MD5 b0773e81ab46770a72917e20325dffb7
BLAKE2b-256 854399e8aa0cdc2bdfa1a2941250771a5944b20426d5eda448c09be351ecfd76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1862d038b6d52ff910fd5ad9b4a3c497bb1d16adfa439a2d56a58fe662da6187
MD5 72fba4a46f8b7908e376bde1d9e5d51c
BLAKE2b-256 c7f964be85f0808dff14a7abe1df756f1b65d11e95a9fb18a1cf0b4cf81a9bd9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.11-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.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 727c0c9cecbe3c69c9af6676f113da1086b6ad58de53ef190da1b80c2b9b4e3e
MD5 257b3d5957fdc225a7fd0850b9d2382a
BLAKE2b-256 3aab18e5809bc2764e8be0960f9f20b19be01c111b99c5eba3b9b96062ffa931

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1dbabbaf1a4db242602514ec385e31f399175375882f24cbda2bb118ba719270
MD5 efa1b8721add1c965d732d8f0fe0b565
BLAKE2b-256 4157e2644e536ad8ce927c542c99092437d15a5404950a6cf3fa1423a590b502

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9516657b389e51076b2d66a4899c3547675a6be0cd285124e2366870462e17b2
MD5 9d5869cf6fb485836e1251e8f62a466b
BLAKE2b-256 777ea102b6d98a1cfde9244e8d20a50ed98ab9db54fc5b47ae5b3c3d19b978da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 61ff89da9e4f98e2362217997551a5cf9ed0094e0bfe1a1df4926bf11a816047
MD5 391ae00778c645e1d9980a17ec455ea2
BLAKE2b-256 b747f3975bac6bdfae6297f26e8f54a9150617be40689d2ed360f8e40a030363

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 55443927fcebfebc6df4db4584b9312807dcbd50659ff9f597661d22cf59bfb5
MD5 4673e53e9bacbb5fa2c575c6bc1c2834
BLAKE2b-256 e3b7276a92cb367d660ef7634b9f66e54eb19fbef7297d0f6ecc312e6e6aa050

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.11-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.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bd541949266b446e5a077ff7af2c08ab089d80b48465a077ed3fa2fe5a04fc76
MD5 7459eaeaf2438ae427472e276fef0750
BLAKE2b-256 320fece6a98ca8e7003b131446e05b5174e8cff5f3724278508b437c9ca30bb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa08d4d87919025758abdafc913225c6009544fb52aedfc1ad9f4f8ac29b0fa7
MD5 b2b1cd9d071abedd658ad9214d99418a
BLAKE2b-256 e8b3bd33e7e8d41a2a288247d448d38061884d6fc0215dd0c74ad0995b447e61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6dc5665fc453a78708fb1403efc032417553f52fd7e8676fa984b27a7b12e9aa
MD5 0dfe85cee4aaf450539911e542c2afdb
BLAKE2b-256 c5e5bd46dc3e4269646103ab253b9501cf9fd3264879b25b7c0a57eece18584a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 95eb839b265e7e00b730844e03f8a0f1ecd31088b149855c231462001b1f53d4
MD5 d4dcde4eac640c7af7ab12f603948cd8
BLAKE2b-256 d4c8eb02510c6b6f854c622823acf8795d7f5f01d3800e24c8310544b0057bcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 208a6fea7f101ffa1ddbb20e794f319da3ffd0806f08a303ef19086abc3253bf
MD5 bbc4d4c48520b1ac8e3419a5f9f4d303
BLAKE2b-256 451e87c26daf303353205be8999ab09769d143e89668a9c206dcae80d8fa54f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.11-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.11-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c1e4f36ec56589d8be57c5f23c68af63d831ed4c6e6f982a79135dc9dba2b5e4
MD5 9a96316415b64835ddc5afa72b100008
BLAKE2b-256 2ff41d7ac7ca14df689fe7eca68ee9e475bb14199cc267656bd9d65a7200ab61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5dac0a4af079312fbfb72917ab59e74f88583577533d66c359c399b18cc5db9c
MD5 088ecce6ff55bd3d35c26a6a19dc1986
BLAKE2b-256 7c401263c7fa1671cf41a7188b7652e493ac00bf6ef6257e75757de26a855ca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e21e794d3f11afed5120442034cc67a59d1030cbac88c5d944a550f2db33be30
MD5 373c51b348c7d42ff2dec4854d3836f0
BLAKE2b-256 833db4796a00b8622a2e6fe1afe77c2ccae04fbc36c661812626f0da47306ef5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 873dd64d29a67013bd8a247e18ab63fd105309997113da267f41ffee40a4b315
MD5 2b037c03c5e44ac5a05499d8d5a6f415
BLAKE2b-256 2f73f52fe4823d002071d7a657cb923e75f741bc92a513d5e582f72b92fe3e50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.11-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3d324bf22b8a7a744a0165dcc3dc3684f9919d3fee0269d8e2601a309ce29680
MD5 a78a611bd79834de95e7b3273d11c304
BLAKE2b-256 79649ce353f6385865cb91119cc8ccbdf890ac4f9d1e400d1099b60d217ab85d

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