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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chalkpy-2.123.21-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.21-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.21-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6f0382311dd194a5da2fe54d7fd23aee7947e3c3804898943c19daa08173e973
MD5 91fa60e8a9dfdbc3a00c0658b83c72a8
BLAKE2b-256 3fb141bc8749d8b7e93bcfc0860380337b1dc084c2cad7d380a14f19523fe5c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3952eef5125cd33a270efdd9ad575b33ae6de0e25ab5898870ae72a453730ec
MD5 d97739158349cf2ebf2edd452bcbf02b
BLAKE2b-256 fa72ebd82441b09ca938daee93e74e181bb3f17071b3af76ee05708b67015175

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a47abb8e9c7fa3844853643c234de71f6c9d1531b2608ada49d035790b75a83f
MD5 27946a23d82c69ba5b5b90ff3e2006e1
BLAKE2b-256 c935cea374db748d219111d00c77deb0d1081dcc2d53c127560fb516b0454ac9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.21-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.21-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a1a0b094bf2317af01f84cefb33df2fc8fcd0d47d0691ebc6eac654cb484dffd
MD5 457fe5ee008df022b6286f7625dd8e29
BLAKE2b-256 3a90b9e59fec02f54ebea2214096d686d0634872da798b078b6ca7da4df94ca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d99485b159bb1aed48eb876b2570f2550bac4088cd17e44960e78771f2e0b6d3
MD5 7454e023b6f0d9cdac6efe25d2e954e2
BLAKE2b-256 94b235b3df2381f408ee1f15e9ad7972ce2171b7d9de6ea27177ccba5b2e36ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6df58d4210f6c2acf115f29b890cb269b0f7533ac4afb095ffa65d6451c06ba4
MD5 e75a08391f6a068d2fb6af7b61b187a1
BLAKE2b-256 2242992a76b241b6f73ed0aff2d6d393fc3bc8a56c810b4ea4953d74dc9be8d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f828815a6589f730ffa66ae711437e576822c3e276e96e3ba1b9e1c28a6f421e
MD5 98f5be1abc0a37beebf88d7fff341150
BLAKE2b-256 eb1ff4cf00f3d72f2097a788d7acced290252c62f098180268ed2bb898b1e1e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 87ca25b9b9b5ed41101d3a211335dd23f70311e6137b7ed9faca19279c53da7e
MD5 ef48b7011ba24d23c1471aff1fd8e6f3
BLAKE2b-256 650c58c30b939c6adaa02c5dd84528670889840610bd92783382b229402e672c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.21-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.21-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a9299b92ddbbd98b1db0303adfc6037e6641b6896ca188213fbd7800e588624c
MD5 c8040f7a5eb802579121eb4adf740f57
BLAKE2b-256 03efd553eb8659b8be1b554b0a736d1223cf842cc9fc2dbe4a39a274296f8ed8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 125e3b4b7141e6b476aa615a0bcf96db7b92ae4b2edf856420962568a818bc95
MD5 790a4fa6a3e3c640029b5ba6a9901a58
BLAKE2b-256 d5d769f318c0753855d91fbebde8ffad26c0cbb2bb5bfca183ea24aaf8b815bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b66726a3d932d7323855447f3bed73130a1d3be83cbdfa485482ea663379d30c
MD5 4acb9f86702345b7ae1aa36e7f75864c
BLAKE2b-256 d74f2bcaeb3646be76ccd09789c3e3120150ee0f2211a49a6976a26dd04dc14a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c221b7603d68db89c2691998da47144db63513249656dd66962792f8237ae9c8
MD5 dc3833eb37526d44030362a50554d3d4
BLAKE2b-256 8c9ccc5012a1105f03c628045bfbaf4e656bbda68bb27897e4feeaa8cc975bda

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f5693f57dd94c401d8ba6143ec62a41eda5b3f2cbe12b5a66135856fcd3565a7
MD5 80701f1a842411fedf544b14f0ec8d3c
BLAKE2b-256 32bd17fa0beeca981559c29cd2f854ffde9dda7bbd6c981322c00ad8edb3c406

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.21-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.21-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a33f62e2fac1a8073958a9ff63ebb920e2f3d4fe93431cfc95a941fde0e23784
MD5 a8856bb32a2b13aa32da0752413d5955
BLAKE2b-256 3d1e13bfd40c2f14ccc091904be052b8eee466249d6dfa0499570b03b14e16c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bea398ccb0339764c1a532fab1e576913cd15cf35e524d4348119a8b86259de3
MD5 f4b5ae36a980b14d3e3230fd918956d7
BLAKE2b-256 e55971cc1f49a03ebc6a1e7f2608daa7378616f4b082e32f2242c3031fb72caa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2a60a52614b7c83fd4eb3df573a86e416fe3246b6bbb6b3782952b18752e5065
MD5 704964f81dd3d4b8bab3c428f1e3140d
BLAKE2b-256 c0b8f731fd459380a078b414e1e23c8cac7c5767aefd5fb2d15f2131c35deeb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c833ab23da3db411180e2e1677d169f6c448598d7b774499980d17441df2ff4
MD5 309fabb2ef8a56dfea5af70a269720bb
BLAKE2b-256 433b4e1863a220b26926037dca164525dabf893cd8b1f74220d1fa3844a80617

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.21-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 90c455e8b0756601aea61b0f154bbf7ecd5e6465d91efe9f6069826027132eb9
MD5 29335a0da0a488c6c95966c279f4c33b
BLAKE2b-256 cd7b6abfc49540f0a3dc39645e3d4fa6494c0af03c268f7fc87735bc3c44af79

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