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.119.1.tar.gz (1.6 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.119.1-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.119.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.119.1-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.119.1-cp313-cp313-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.119.1-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.119.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.119.1-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.119.1-cp312-cp312-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.119.1-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.119.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.119.1-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.119.1-cp311-cp311-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.119.1-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.119.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.119.1-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.119.1-cp310-cp310-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.119.1.tar.gz.

File metadata

  • Download URL: chalkpy-2.119.1.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.119.1.tar.gz
Algorithm Hash digest
SHA256 1a570c53d4ee4f98c2cf8632d3e994d5d8666328e98c2b00a92abd9da35fb2bf
MD5 960e3fc8dede90210da5923d27d8185e
BLAKE2b-256 a7caeee7ae45ac567fe5c5d86eb3eed27ce889d998c6e4a0cd2e83473609f117

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.119.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7ea2217a4e808b74461253213dc9f9076de29b03de124b64237a9ab6b8d8fee1
MD5 d48dcc86a7ff7c0d55301da5fe94c685
BLAKE2b-256 d8a01d3486eeb7151cf6a70a91a8c26e1bf24ed7b480029b0710b875dfaa7aa3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f66f0ac6e4ad015a9c43f8dfdd33281691aa09a45f8c9bedce54002d9ee12a78
MD5 70c7155ea616f8b4c2644ec384300972
BLAKE2b-256 b7f5c7d13dfa5d8cfdcd81ec1ee79f2fad45536cf12be775652a5a1037d67ff7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3e147c029592db0b7b49e0f8aedc248b1f150f21f6fb034c1fa157324869c9b1
MD5 d13a3cb11b1dd2f0374201425bc942b5
BLAKE2b-256 ece0822db5a71f7745d428b145c5445dfab60254095722bb4c00366ea4af1bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d8550be22beeabc434eac6ecee82f065bb2d41f9602134bd5dd6f12d3876b3bf
MD5 44cc067e75f8374ee530845e9fdeb579
BLAKE2b-256 4f58698a2e1858ca8055032b575a08e35f9f6a1a9e061092c0f2fd6e0d352560

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d05f22d2956e49fd84a692dcf03fb275ea5601ccc5efaa0d8ef9e267b22f5423
MD5 152c5b58a4d95920c580fe6311706fde
BLAKE2b-256 b2c2a6ed3fad500fc6a61aeff6d85af1c1cdf71b23e2d87a2efc5a11cf7abffc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.119.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 16e1af427790f41712d85e712b592c62f68ac283c8cabfd1024b27bc82e5bf37
MD5 bc195f425f5eae94f3e62fa272efaaa1
BLAKE2b-256 219b616f7d083820cb10e0cb72aae723c9093f0ab597e9336092ce5f8082eca6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 902189b8321740ce0c8127eeadabbc8981cc7c2fa2a72c046c1795fdecbe8807
MD5 984ebe945c63c8cab78903dca23d5585
BLAKE2b-256 c67fc3176f6336e42a29b2a7245d01d4905d58214d9c5a301ce02077d46375fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2cde8df4610a98f59a835240a71056304d1dbc453e75802d48cba093b06081d9
MD5 7e7291fee61f7f76d4df960ce765abee
BLAKE2b-256 a768726ffeb7925e447307afc8cbb0eb5f770f336dc781d2fd6ac6514ed2f620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fed396d67b45c97fd3a4849e36d916e33b97f74f2c74d8c6feb3fbaec617bec0
MD5 b6ab107c406cf6dd4e032e3856538f05
BLAKE2b-256 34c077bf6b1e3f8a9a9766a7f8b1ecc3269a21be8e66be2e5e7a97dc1acf591c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2b906d1eabec8342ff344b3d2243fda17206813ee062ad462de62f0a03ff3d7e
MD5 f363f970830bd3c7bf10d353abba03c4
BLAKE2b-256 faa98681618022a846d305df3856eb2dd82eacb1b5e95bc54705d5d91ef6b926

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.119.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8f1d1f6e2412baae4a64f1d8ba8c63602dfa5cdb515e3d17176995f67c5cb61c
MD5 557c677992c3f5a685764ef7a264819e
BLAKE2b-256 232147f059dbe1ab6b82864c26f268c0ee0f12bd53d6d0555d12e39004efbf69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57f93e6b3bdb1fe90687e17af91abe77bf04b20cb8a157bccb5bfe64309807e5
MD5 8c5640b07dd8698c11f6a8f810dd15d1
BLAKE2b-256 6f42ed5f4474170a397366367c73413ef1fd1d9ac29c7a78ad5e7b767948fafd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 07479dd552e61a99bd1280093fa5c2ed62345b714cd3991dcd049cc3660ee8d4
MD5 380a5d1a0a33335c75f19adec6268d22
BLAKE2b-256 b9daaa61f3b5cb1c757b38d3307011e45a1511f725238685b6b8a9899afbfb7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d445c5566a7311b9725753e41dd1bb18b7aa587c0118f7b6609cb521da9dc744
MD5 aa33f20f10dab6fd27476a48104d86f1
BLAKE2b-256 20fe0f8d3e288ed3cf20823e63542bdb51b48b6491cd1b81590faa2deb14f031

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9512598e323aec9a82d2f47546189bee14cf96a4bc83f1df741e4171fcfc8a86
MD5 1fad8beaa5b788c6284c3a03cf194595
BLAKE2b-256 6a2adc97d0602fc250ba282f640c0b12c8cd640e6dfd16637ea15984f8dd1ff4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.119.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 311bc1973be1640296a6c46064f636b583ee3f5c47ff43147dd2c8abe5cd4fbb
MD5 fba976094b7f603ddf7f47b8f1fe9b3a
BLAKE2b-256 96ba6c9cc7d5adafa3ac3daf4328fd284ac7f7c00681f801a524f7ad049d34de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02edfb59283c6d37e6d5b9d18283bd2f71bc6234a4d042e006022c617347d9c0
MD5 2482a11fa0d7115af87d263b13a7701e
BLAKE2b-256 0b71ed67ddacd2d9e84e3005fe5f8eccfd0264da8d23d1a0e64546e97474b3a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cd5eeac8e2a545e05e0507ad1d7b4d23c010716b9fa50ff8e8e44a81597dda08
MD5 1f545613ab05d01690542b73a570f0ed
BLAKE2b-256 d3ed21584d8fc3b2a5a11e9852a5bb7f921b41007506e84879ac983651c531f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8e3c934603e55794d3f053f933081060e688be57aae665b5f2d429976c83df0
MD5 dbbf8d483ad48fd7a079c352fdb18ec6
BLAKE2b-256 62148b65636fed1f3f269ea0eda173768fada548c4a12724ab27ef1f2c217ef2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cb7a4b68c38a78c8e310f1c4c57d9439d43fabec6ee466fcce67817f569c0986
MD5 cb5b5544d705bd1a5470f2ae4983bbc0
BLAKE2b-256 859abbfce9c20ba7ae3d27b610aa4a649b7804ecb4473c8fef019eb5c6a7e189

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