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.110.2.post2.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.110.2.post2-cp313-cp313-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.110.2.post2-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.110.2.post2-cp313-cp313-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.110.2.post2-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.110.2.post2-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.110.2.post2-cp312-cp312-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.110.2.post2-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.110.2.post2-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.110.2.post2-cp311-cp311-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.110.2.post2-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.110.2.post2-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.110.2.post2-cp310-cp310-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.110.2.post2.tar.gz.

File metadata

  • Download URL: chalkpy-2.110.2.post2.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.110.2.post2.tar.gz
Algorithm Hash digest
SHA256 a127de433b29df55e87906badca42512e07b4512d52272a18e8f931fd7154dc3
MD5 863b2bd2ba39eaf1a47c406f1fb05ede
BLAKE2b-256 e4d28711424c5b8e2317f1b786d41de97e15fe783bb2c7b4d225777da03edebc

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5de0a75f7758685d475d17a998e9f91a90d12b17c75cc791ba9e037201e2ff96
MD5 317fc32755d668b4678f8684ec181db1
BLAKE2b-256 6c85bd3f5482b0da8ffcde81e7de2f22439d9fd8c97217c5975d8aee594bdb34

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e03f9cdd7dbc89671b0bc59749b2b7d0b3cac6f31185bf83175e5b30b8bfae91
MD5 277daca2cb22b2c02e15138216af925b
BLAKE2b-256 a6d938a39e0b99da1b7e4b7b123f078acd1278a75e4bfe73365f76450408444b

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b080e94a654c182c4d829f848369d3dfd8bac399cb66eed3f816bbd1f3c1d5b6
MD5 8d49c060a858b04b5bbec51147f18a48
BLAKE2b-256 4e9996f6581cc5d9474cc7df826841335aebb9e1aac9941c3ae613ba8574bac1

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22a2c436f2a9d9fafc5591d2375db6ffdb227662880a8f06329925b74902a0ce
MD5 9f2d7b6ea04dbe8a1b4dd2fc2bc7c646
BLAKE2b-256 46d6c38cb4542dce85d9932138d32f872fcdb14704d321be590bdfb97fa60e7d

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 822247627f016a0e6d0ec46503497377d796023214ce690e363fbff8868bc09a
MD5 e66905f946b76e1708c5c5de78a83a34
BLAKE2b-256 48f0ee0e36a29465376756ad35227b1db9940a05eea55de642f34ef157414be9

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 77d4f63981239bbd0d6b34b7117f7f3c892e10cb29c5889c08e9c607edb1d0f8
MD5 3d31305a6800b8cb85c201278bea7b5b
BLAKE2b-256 26de7a7ba895a0fecd5c9d407fca18b1d150de0b20d1f952d402ad633306b219

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ebf543ec368163e67c6f039f02e4e893d00710bccc7a8e58ad00d4419acb7de
MD5 0bc90b582aacb6f3826800cbbeac4729
BLAKE2b-256 d956ced54a6568683d967d231cd79785ed735205e5bf2eb2ce170fd83e55fb38

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 303f5ee69fdd936ebb4b4782ef8d094eafe33b825b4da438ab009adcf54e346c
MD5 ff5c4ed20cf49ec6bde56c1d9c4b31b7
BLAKE2b-256 0ca85274b6a6116e3952c08e2008f74a99c84a011b010f708a4e5353b5445998

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a2818bcf47bc59148ec8163bd79a0a7c5f0768519936bab34a5235ea9d9cde8
MD5 5e43fff995223448c78c6f6c2c276d6b
BLAKE2b-256 a30f740af3dc08477a891b67b20c6e3e65af4d8d094927d588e26702a89e2005

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d239be57f1012e837ab56ef69614d457b1a3af054ee02281b014de52d9bba6fa
MD5 5cf3074389ba08d6aa0cffcbb25fda69
BLAKE2b-256 2075c1c731c5ec35dee6f7e1d488068e94aa2335aefb4a4b8047da2623a97e98

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9f1d5451a363ff53a27df72a45667ab99ec81f7edbd0aeb6a0bc01dbe62a1ac5
MD5 7178240a154495ba6394a739d720da0c
BLAKE2b-256 9f8c6982f58bd11356c962d87934070bc26a19aa53979f53a551315638dbec97

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62353fe2b659e144c2917a29b9f69c12c9ddb218d6563e26e6994233fa1ba8aa
MD5 0e4bfa48a672e94f77e1a4fec019331c
BLAKE2b-256 f3c9d24cd1c3869b9ad45fb10527834e8753dab579c749b1047ccff6ef059e16

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c9269db19345e074233578b439ef1766ad93d15787810823672eaa26281ae1af
MD5 3742abbed4bd878574c8d1f87c9fd751
BLAKE2b-256 6d19a8b4079753dab48c100701475d03019f60e88182674788b9650f000dba90

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70f31b8230e80f82190c831c4d56807ef8bf390e2e78bf7af32df4b84dddaa09
MD5 16553f1fae55321d54952afca37802e8
BLAKE2b-256 b8852c756fbb770270a3821a860a4505b20dacc3136df2e2ac16d6d5625855d1

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c9831fb50d527f8b790084a963501b3a36ef59d557d62b3006df4953cfebc8c7
MD5 7ddeaaf7ef95b9395538929145fd3c0a
BLAKE2b-256 29c14cfce5dff3705eb0340e64fba84cebf8d0461e7f4fc4acdab0bf0974a6a9

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 90567fb1f944e66229023d6dee659b041a93a6b4f752b0be9226f10565626799
MD5 44627edf71ed49de3c67c57b337ed359
BLAKE2b-256 627584e52d55506da6680f00a97fcb9150c9d065d1f66f8bfe639abbf74066f9

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c9caf07ac142049f59d6f3f8f5945456b9bdde47abbe6051c9cc910c621f4ec0
MD5 7546d9d53438da4386f6830cf2418623
BLAKE2b-256 e0028030ef3afcbeb67b24f9c330bb6fae1a9ac4891b6105cca51ac10dc80b0b

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a8c05607e335648fcde8f431801b7ac1436031ffcfcd64dd6b191767a35a6e56
MD5 cd35fb5fa24f703ab006e7c57ed5c464
BLAKE2b-256 873522fcbcd40f78d4bc05b2d7d274a9e4e0011f41bb18bd3f55c6589b9e708c

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e6ee4609ec0aff6d33ebc3bc5f236a2d78e5b0fc07e5f8f74206bd91c1c1d08
MD5 3194f34aa1a49e8d2f3adcf175950ce5
BLAKE2b-256 018ef31474abdd5503972a31359be3c58cd1933d45491f167f45e8b38f238c66

See more details on using hashes here.

File details

Details for the file chalkpy-2.110.2.post2-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.110.2.post2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 809f812014685083f3c0d29a73d2456605aee59bd77598564f79b18954f92231
MD5 524fef04480ff4c4ac1f824de7bc6fe9
BLAKE2b-256 92a7e1f6b95d4ea7518d75e71b7a68f0443c8fdcaf34427c6e2ee1c629d01692

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