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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.10-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.10.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.10.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.10.tar.gz
Algorithm Hash digest
SHA256 18734bde78472a061e0a3073b618c3270ea4e22695488df56a32fb81ba22630a
MD5 d0f7def7f62dd3a1b5c108a5f0855f26
BLAKE2b-256 a9733c45936448d3c85639d040131b4eb33730f0f8b8827681ca4340e643c23e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.10-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.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 498e2c983bef1ce18565fc672ad6be9dbc84e08ee96d119ac61d5ff9737cf24b
MD5 1994a8f3ee257362428cb69c809d124e
BLAKE2b-256 ad7bfcd4cd16f8ae3bec0deb5f393e7003dba4fab782f0ea9e2af502354962ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d244f707f5a78f2a502d25f0dbe6bc1eeb4f76bfbf64b3ab5f70e6da4d36112
MD5 37409d32ba9e011a4778cb9cca5aa3cf
BLAKE2b-256 5fdd48861c20e670814d1a91f4b54f0ee6886714cf732c298ec897332bfb80de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54037033caa75497df7e571a64bd8cc23cd3d360562f564ae44515e3ffd1fbed
MD5 f0686bef50c02d5fddfa6636182e8d3f
BLAKE2b-256 0ed4c01d8418b438b59bada4302acbbb2b55a8a9cbfc0edb1a65d55875d09518

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e621e608c17512d2b3c5e674b4115392b4c7225abca340a6cdac52808f265949
MD5 3d2784058fce2dec977f4b10f7fdf520
BLAKE2b-256 a73b16a1844b85bd2729fa1b59422827a0a3a9f66d768e632d8b121e5d8b97d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0a317cbd90c94b7aa6f9c1d2c38d06cc287ffae3c3ece42ede00740233f7cfac
MD5 d79dcc6fc69566fb95e63da5f12b1e8b
BLAKE2b-256 b0aa0d059fa4c39d20d1a2510261287122fd5037e8ed76b81403a1fbb5a7b274

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.10-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.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4e34699892dcfb8630cd5577652a370611a2b28a1130ca44f3f7e404f5ba3aaa
MD5 7f4265db93a295c9f878ae7d4d8de0af
BLAKE2b-256 d4a5a9115695b30bb5a9b7f8b41049b67ec9f99d608897e9b084e71028ef4d2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 39923c0dfde1679757626fb851629f143f71315b55930b255087ef11a18c401a
MD5 f6d93e21650479c8347000ca59c5675c
BLAKE2b-256 2daabe2e2a87cf5a81c06e6b5e32010234f2b19a1f3a8ad9b7a3eb37173052e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 322853c71f648737b738c1fd531a8d1733248bc54e2f12ede3080996caf2f856
MD5 f8673eddb21403e1864384de3a7c6cba
BLAKE2b-256 ee3598d1057daa1ccb58d02fed83d22bb6b533e167e794ae6a19eb3908afc120

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93715ea972d9d7a9ccd6ca62585960cdeaf64d1bed3c1c43417401c587a71dfc
MD5 4f4b4eeb3c261dba7bba45fbd04b0ed6
BLAKE2b-256 09960fa3e81af6e4c44444a8369629684a2fe47cb56b34319b84a77ec3a2e9c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1d7c561dcc984c91e534acce174d19528047b5ad15bea76d32fb9740bd01de5b
MD5 6212e3444e949713a052ce50bf8b6c97
BLAKE2b-256 fd03d104d9bd12db39a4b36364d66e98c8af5945d0b90276d1f7e4650301a089

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.10-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.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d8139398c1ea3481e70ca07a03a1bc194d5ae460a2f246b75da84e73a1729000
MD5 a20f707f7cd0a253d41bc5d86e0a8e00
BLAKE2b-256 550d619411ab62c215a5602dcdc86e8a859659ed145781ac6c2be9762857edf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b0450c1783fd7a21c6bc626818e1afb53c2634eeced3e57701a569be7e6a7321
MD5 0597cd2471e919ff6097968acc17801b
BLAKE2b-256 5031bddc73ed43c8c7b85c678bc7e6af5a6afe801a0daf92bbebe85f1c2649de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 91e461a3bbf06edf3995d41e8a84578fe0cda3c82aabaa7f041e3d0d19b9890c
MD5 8cdf759d170c40e9654675ecc9624a62
BLAKE2b-256 515e23e548f1ed84f4d5a63c967ad6cb3957b0720e3308f16a7b8dc75fca4780

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a6a2b9611b5b43bad0e563bb5032fbe10f88b2345c22158827f067532fe2bc84
MD5 45d4b9edf84ec76b22cbdb30842ab902
BLAKE2b-256 e1f9fab5eff6fe8b17bcbfe454b845eb7e688aaa6434e3fda28dc2fb7e88c9a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d0afcb65e0d3e745c38afac322aa4db5751336a88cd6809fae2fe8cdb7b6d14c
MD5 7aabf219fea88db62fe858d86f3716f4
BLAKE2b-256 837c96740f9ae6b1e30477b99543ba90c10d32bc0e7a82ede2001d09c216bd6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.10-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.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8149e0796fae61f295988110e5df53fae17e2f7662326c8a9d2df29c58086698
MD5 e860c2a7ec92d056d0204d97e21cdb56
BLAKE2b-256 15a4dca6bb64c7be3b7beac8ee7e02866846c051f0434aeae9ed09ce0f25ff42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 99fe0de5e0a549eb444318d471bb515142a87b433b396cf02e7992b5cd9aeb1f
MD5 9651ac4f453b03e76a462661bd0931a1
BLAKE2b-256 52881fc822bb024e2dd56480b7f6f44dbb17fdf5a74eabcd4a66de517c3d72a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 47ab8f43406e7ade181c43d38ecbc9434aef92c82de1b186e3485e5669e8877e
MD5 aa047e5fd3390ce567b0cc1af70c98d5
BLAKE2b-256 0d00e4e59f1ae280a4811b6d53741e3bdd3c60902c40d39be993f114d19fd954

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e93b210af44e266864cf9a9fe5686eb5f77fc3cbabee67e4f1df0bac954c9729
MD5 567d2e0eaf6dbcacbfe05b5b1a31b711
BLAKE2b-256 629631945377a5b4625be208afd1dc5df804962f90d6682ec28a6bd35d695fd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.10-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 19ce37199438a9b9c6dd6066812ca43f3e0abca7a8bbf5378d2ef12d30ca1f47
MD5 50a120ff7e4018b579ca203e743e4289
BLAKE2b-256 0287270440e93f5f838eb44b80d76c43160c32fa48d0a8f06a4d8e3770a44a76

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