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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.124.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.124.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.124.2-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.124.2-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.124.2-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.124.2-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.124.2-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.124.2-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.124.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.124.2.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.124.2.tar.gz
Algorithm Hash digest
SHA256 19cab299445a4c2f05a9d9e5767e712aee20df944e936c46522be483399c5894
MD5 96015f1cc175c3b0d6fabaefd6ae1c40
BLAKE2b-256 addd1bea839197dcc8880d60c2c03c8273ed5a26f074cca845513a8f44e2a71e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.2-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.124.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 aa520434196fd715638f20c4ce23145b75ed69fd6d7c0d8a802072298abca836
MD5 d07504e3342aaa09ecedb9f3c0565e66
BLAKE2b-256 b37a8f24c26effa17dbb76fe820c57dce9988da0d7df2ecfe2f34c75c1a23038

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7ceec0485827971fbc3cc2545023134aea4df03f21edc71cc9b2eb9487d2ca64
MD5 d2e943860f1de063d2fd6c40cf94653c
BLAKE2b-256 e5806396feb4bdbe991b9373b3259adb34f589147d5a7f67887a3dff57c09ece

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bda777ef6fab046928abcac95fe917f9a1d3c1592a9e087e5e73f6c7a851efe5
MD5 e5240ab9f378058d1cd8c69e4f3215e6
BLAKE2b-256 77a59bd958cf483614e43637e7b953206fbefc9c3ae8efb5159f469b86f0eeca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ad76dcc096a63467ed8b438d6cfe0486b4f629bae2de7fe8fb7a3b05de217ed
MD5 89f8a7d629b273832ac3dcb62f061e29
BLAKE2b-256 25dcc2be234868cba586f90501b3052b96ae855a5ce89502d3a43a772013486b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4aa91b2154eb785ed85d4a2f6f7cda4381644a2ac7e707f78c0e79e004696592
MD5 15fc8843df4cfd0d7b67b88df4feb82d
BLAKE2b-256 a5f759a7d0bf47f962de9824d2c26b3ab877af6d033c12515a3f1b91bcae5cfe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.2-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.124.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 19ad54ac53652e77d80185a97bb9c778e72a1d1ec2a2ef329f748a84460fa543
MD5 b45c57c013ed6bc74afdbf1a302004b7
BLAKE2b-256 bffd949ac827d4f8a7ac5e6862991fcf77a5ae70f896ca53216ea5169cc6f79e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe4136d38569cd577c0c07567d7219c29ad0bbd5184288e306307fec38cf68bc
MD5 1759eafbc35bc5fad357307687b55a20
BLAKE2b-256 dbb7e73871ab10d90ad9a66200d0a86a6d5ab01b9f9de4c0fcaab0da2dbeb8e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bd2a491542565d1dd52dc44835acee5be0d01e35fffd47a70f8c62140f173b2b
MD5 10b6d89e5f8660a57f264cbb45862775
BLAKE2b-256 560ed78a71cc0a8b78afa18b2e2b3ff8385a006b80d987c9afa30193325afa31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec7483b5612d10bcfccb7884118162bd3aaf1726847643dbdd00b9810dd297d0
MD5 84ef5a76f2f32038839a4a3438291292
BLAKE2b-256 9c5739b10b4f6dfc87e11c1100ecfa3cd0cbff72586945d5726c76580374ca4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d98ca7dfc0ca6d32e3e98318948311d02bdcaa1d1a5d5bdb4cd2f33f4ea86476
MD5 4e6cffbb62efcd1e10edd59c16b09964
BLAKE2b-256 faf2045c402d9ce544ada510754ad3415620d00dcad43edd0fac0cf536a4d639

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.2-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.124.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 37824a01ed048abe349beb0ff28cc3b8e835ba30ad97e0e0108036ffeed99b49
MD5 93d72a7142a742e4094dce606eae4fee
BLAKE2b-256 1d7f6cb8aca8ea067b592ca5f3c76648fc061625f84ccfb1e9a9cb3b75dc87fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae53c4531d917277d19ef7116a84040cf19be83f3550a83e309d53e52236cb85
MD5 24a45c534826b21ab54649b77cb92dcc
BLAKE2b-256 b3a859292137747aeda42527d8ed2ad359265a72eb80d07f6aa491ce70653a35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2070120c00fcf51ef734979f4fe7ea14864ca78604d1cce08c99bb8433318139
MD5 029b6a22358c36ba268f24f183036fcb
BLAKE2b-256 5ba984ac8a86a7c4759235edad8d0611b214569234c79a8182abb9330f1c1621

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 da2b71cc8730f0f01b76d4958b0fb9a0e246f50be935c211466f53af94b26909
MD5 7c74d226a4880a3a77462edbc3188955
BLAKE2b-256 8e72666d67ee45bcda235be2abec2fffd3845b56748a3cf31d6d54e466fe9df8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c38bb2e03704ad2e9b41364a31572fead36a8f045cf46e5acc97f8767d2a14e1
MD5 a3dadefe58bed9b888afed676e334e05
BLAKE2b-256 2e5889012ddff1d166bf449133e41051217420546a8587723080c42f06d6a94a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.2-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.124.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d4ac0bc3b97b240457dc1d5ca39cce8a70ee366e0d9fcf38dc8c1b7cca1d617c
MD5 ff26320b17959b4018dfc240e23f0123
BLAKE2b-256 1916334fd1918d05f86cc3f40bbdcdc3b3560a11dd56306155383800a5cdf256

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ad33af994fe24d91d0d1c78c708ec077e6fde12b9942a70aa119c9603338c2c4
MD5 c977609af6c2a2a226bf64f1b7e763ee
BLAKE2b-256 5fe97a1ce0f335e50e291db8a9b89bbb9904ff39bdd6377a4d32da13b9e9eecb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d45cb24301bfd1014075ee4a93c55e6bad4cb932878751cf084abe5480e6a93b
MD5 ac573f88644c06d354fdc9e2b7205e5b
BLAKE2b-256 29810189176c43d384e5dfa12b867ec440486db7fd915029d60495e1158c828f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0efe6bba18bc1b262fc2e4e811d1cda11d046a5dcb9d5fb39a44e82655d29f0
MD5 062d4f5e78f4c55f8cc366964029130b
BLAKE2b-256 7b26d3af832e214ddeb0654d944bbb6a49c7fa0703b34a64625b097f981454b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e4116ef8d2bc6e2f921fb7b805662bf74a83474b39f3f46500e59896b7944e98
MD5 099e64e36878db9bd8becfe2f5101745
BLAKE2b-256 97e84d6e551ce507d4d0889106f7f59ce61af30d7742e4b53f74325443ff1bc7

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