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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.2-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.113.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0d9cecf54a749f73197acaa420fb531cd5e78c3b8b936dcabd548f05c4286a69
MD5 ce939a4e330352c417f7ac3b5d8306e8
BLAKE2b-256 56239cbf316ac69068892f4ff897f05d4f2da1dd0cfd996a7811b9e62af4e422

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.2-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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 514d03161a359f483c49af0da78646bb3e89830c6779c50aa32f27bfa6bdcbc9
MD5 270e681153631334bb2a3f51bd06fde4
BLAKE2b-256 59d257c608c4654a377d17c39d1b8ca14211194cd8d4db9cf81fef91362bc4e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5f72245bfa52511168ef580983a035fc06ff00d6b419a06252ef98b91c2249f
MD5 e45a568353aa171f2aa18a3b7e7f43a6
BLAKE2b-256 cdf382d890f42572f934276a60b8b75f913449e93f38d52f8e6878561d93db0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 421fb98784e224e387b6d37388b7a068f34f8d07adc233fbac6f07f611c501c4
MD5 c6caed1030080f0d8758e346e05cd36a
BLAKE2b-256 ff02c090364c1f763b1678d425858b040d3491230927bff8160cf9efa1a0400d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3914c196febe9cf27bbad5af4988823d712ebf5fab3c784e5808073c7716e1e
MD5 9706621cdb36fe20b1c53ab0ddb7c23f
BLAKE2b-256 6b5c677c87afb82f67127d657485056a09181b5cbcd5209db72eaa1a59945146

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4661dcdfb358072ac62c719475adeb97ef72ce2bf0b082c042ea45c0bea5a37d
MD5 02d09622c8a7ad79a8cd0a8e5f9e405e
BLAKE2b-256 795dfb1c5f24a72e46d3cb77b27c67db5873dce4b237014248abcfc96972bafb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 455df7fd945829c8b87d7802ad8cf185db9945d905de213fe0f48edc385158db
MD5 245ed903a5e8e665a4a79ee2f369849f
BLAKE2b-256 99aa730826b72d4dd63feaaf2b5d407c4f60891529ca0f5b8e3cedd0862b359c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b3024176b039de2035e09282e0be97d3eaf0ef019869836e030fc91a3923e5e5
MD5 8daa10661156a4cddf75ca213802ac38
BLAKE2b-256 fcc63c45d9c83d582f752d967d15222126453fd55987f38583dc54699228f042

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0f1a6e7e6312a045f7582310978f38544c7a4f434fc779759ae7540d5944771d
MD5 3956323aa1113978218ba9e8c156eb00
BLAKE2b-256 9c5ec7c143d37b9a70714de2c63e750743e097da770856dfbf129ed0f510cfee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72fdae8322bfe854b6aa6bd9b7d76c96d1b131162afad3e68227b1a1720583cb
MD5 5b8ad1c3c92e29ad7458c9d9ef117c79
BLAKE2b-256 fb7b519ff6fc575a4952c8f2730533b5db5d5c8f13772189cd07e2f6cb922428

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5b8e8df6900bb07b8493f6015824a18ebb1d4f81512f61970a44ca5ca00d8d61
MD5 35b58bc9dd3dd098bd7ea24a8cca1d23
BLAKE2b-256 c236ac9b79b3d1f6b83e980d107be7d2f878fca7fc2910addd45183a5f2daec0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.2-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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 353ec137544a59203c9da880302699e257cbe08a853f8cdbdbec5caa82161817
MD5 1c869efe7abd5bdf2abcde54e6711dd9
BLAKE2b-256 3aff857dbc6af0a8a7c8e5bcaf81d729f7318c21380d7d5a9780e60c8597f5d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e460030eb0129852c1db0f439a8e20fee949e5e2be6a8530f0f5f366cc5df7d4
MD5 92e04faa1216a13de4de2a7e67ace228
BLAKE2b-256 255fde9e7f3fe8fc8788826a7d08f2b9aed062a7ccbb8c36c998ef733cc6cdbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd903a11afa0cf35f710201575b949dad6769fadfe85d2b9f918c84f2a165512
MD5 cb2e34cb4368cf8b970a5b7f4a602853
BLAKE2b-256 363f3f5bccb7242a2c548e958bb387231c3645006dd0cc0cbcd6c1ef7d10378a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d9dc0a2ea775d47476b76c03e6640eaccafe4fe7bf2f7a12a8fa5ea102835d2
MD5 c22bdd1744f79568ad339baa1d2444ae
BLAKE2b-256 05fecf267ad447c4943789253e986161620d2515ee309e1602b78f6d9224a45e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 83e91937754042edfcc991bc00ad95e37977ef820676937ab4fb25160f9038da
MD5 5ca19eed02086c4440adee932f3f7094
BLAKE2b-256 192d8d621890e9ae1ce0786850656bd27d350caa7e6d11dd2407ae7dd670f188

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.2-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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 da84e25c772386f8fa389c06fa971c6237f6cf9ccd8d22868d9abe6a0f543cf2
MD5 51eeba7a668e049ff222b66db28f33c0
BLAKE2b-256 225e219e152e4d0b99a019c84f79bfec80da9d2ed81b96d809df4c318e0eb24d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 273a87000cd9edf33e3815d5ea99357755956bba0b81670abd46f43cb1457922
MD5 f76d59f8b7fa92a65a28ace95808df3e
BLAKE2b-256 dfd0bd51dc0c00cdf92b1b896d4591fcbdeb187ed2e41024da9f17c9d0535896

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 22d5c9a250b0c7c66adac3b382c288f5fcc457436e8ae66060dffdf0fb855e2e
MD5 033ac263ebf8f4a17b1426745002d54c
BLAKE2b-256 c8aa34c6001de9e61aca2eb783817012d7f232e2e4dc83b8073b0d839242c7e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cac95db4e20c9cbc77be9c0a2b4b0ee615e7f595e2d83d1f24282c1b655dc997
MD5 dc13002ddfd5e93758ea6d69f62e594e
BLAKE2b-256 68da79bcc1405eba4e3519c4a17475483492b36971e89a6d8f8b4baa4be27a3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 34f2b9268ba4a3b2481acb14c71885b25b34b44cc9b93fb2ee3358a45b3ad137
MD5 ba9adc6211e553fe67f82a97fd18701c
BLAKE2b-256 ae7fa51255ecb781de526f17844c19ba955a58d26143a76d65559c529473cc1a

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