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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.109.3-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.109.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.109.3-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.109.3-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.109.3-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.109.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.109.3-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.109.3-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.109.3-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.109.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.109.3-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.109.3-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.109.3-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.109.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.109.3-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.109.3-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.109.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.109.3.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.109.3.tar.gz
Algorithm Hash digest
SHA256 0c6910716e5b0b11977201fda4f39528068fa150d57e5e5e34a2c9e34a0a6b18
MD5 c9344d7cdb0a0a032852f81db2f46d73
BLAKE2b-256 e4933cca1e35dd5c8645fa09cb41db85914e4b651ff739dc5e2ef5f0ee0d9aab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 59c270fab52eb55443c0ff99773820cc075b47646ef982739b74b0d2d9a4151f
MD5 7ad4e862d6d9bc392a36a3498abf3fdc
BLAKE2b-256 00762608dcfa660aa620597e253a086548645c4cd15289f9cddfd58e9a6298bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d42972b194fbe09a06b47441e8484fe8763c2c571a9305186edcbcbdef1143c1
MD5 e043a7f625afaf43a001ffee8af820e9
BLAKE2b-256 cacad701d0745fd14b5ffdaba4f27cdb082fff5fe9ecb1c38e8b72657dd11375

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 19982eab0709ea7e31c5f4995b55ab8868d5d5292f567c26cac012e0ee921d21
MD5 d49fdc4ecdcdec4efba0ceca863bb0df
BLAKE2b-256 b692bbfe3b57aedd673c38ceb4c15aade416ef8f9c71baaa2d2439025eff91fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77fe5d33250357ab040a6d65c1cd81a267a9ed2d7760aac29041e673fe581b0b
MD5 2e1a327b2be3b1395ee343e4ece877da
BLAKE2b-256 675dee84be2cedc8a0fc0e1a327fdd07922d0afacffd681cf37af43d8d1c72d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 abe9cd465f7140cca40811c913420049a404e3b834045c7e60cbdf46473cd0d6
MD5 86a3b5beb00768fd299c944fc24b274e
BLAKE2b-256 be4f8a3822cf3cc0b3f7023770a597e84d4a6dc0c88439189a0245c6c75dff25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0cea65f3960801567fe05c1886b0f897f7646d2ed6356c1fc5e55605d2b6af2f
MD5 958bc0fd7a6489f1171fb0d94f8eef0e
BLAKE2b-256 59afb7d664e62a3dc361c4bce3142d85e51b457198762d0cfc174f44194db40b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 24e64447aeca27662de346b597d27356eb29a8eb642e034c4780df1cad54b327
MD5 dfbbca36d66cc6144fd02be024501b01
BLAKE2b-256 94c29188bc2430b6a6ed57c03ac19dc40bf20d73aa30e05f4cb450a5bea71566

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 52c7577ae38deb129127be3e29cb56694653d5b6da3494c397b3543c7150391b
MD5 06310eec739402d3e907e8dd1987d524
BLAKE2b-256 6346f7ac5611c69feb9824d437496ee9f1a414a9faf11700cb9c205fdbb64da8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e0bb189c823f3ac940b30a0e17528a90006aff0885220226b2aeb80375536097
MD5 286800b8a78e3015c54b0b47eb6a7de2
BLAKE2b-256 53ec4027745b482cf5356abf420e9755238b27eda01524d8969625201a4e862e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 83c7a28b0bd45d8e1140a5ba3a45a5f1816943eaab01bd8d8ffde055233d9f78
MD5 f266bb788bf0904adc96d5f34d3ceba0
BLAKE2b-256 1d325961a4e1ed25f308a6d10d25c87f24c72367fe0869c1bd7efd92c887fc41

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d57055c83480e8b23c5fb07b4ae1c26c65b37c072c523b7c6025ecdc43c48c87
MD5 07cbf7b1cc338734ed46651023d4f511
BLAKE2b-256 784f7bd924bbd50f1574932333bb734f662ea16dc6fa23aa985e3a4afc4d629b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6f834979230cfd42d73c4734f83106cddcaab4869f232fba7c4c2e4565cceaf0
MD5 1dfdd56404eacc9a7f1bfe2f81d0de76
BLAKE2b-256 f08d7a34789edb0872298fb58526e37ec13f3f9fdf7721b04b99d7c83eb125ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 51fa4081d3b345e173d1c74b710bdb6df1d92b1a051fa1f0c6b9cbde8d552d82
MD5 57462abdbe1352682b737f8c36ebcebe
BLAKE2b-256 bacadcff83a1c8fcc290b8f281a7433c836bfaf25115ea261662f615c7837359

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d58699e894ccdb791072b7f3de788c74af8b61b89dbc1dcc970e8165c481e1a
MD5 eab3f132022598b04ce9400f31fc5846
BLAKE2b-256 03d1cfab58c216d3b6d84dc747beae66c77bf46392e4cbc696427076608e43eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9b342578d5ce83af5fe086fc511a3f2e52d86455829c89d5000333f34fcc2180
MD5 a0a974363ae6df9989c8f673c6b76778
BLAKE2b-256 d1897b9c7fdefd348659f45a3a0a4880be4eb251dc9be922f2f3c41b35855ca0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5478c4518687904e5fc021b2c5d72ddad6abdf3035b109ce1b88bbbd2bea12ab
MD5 49afb408cb2d78d396c366602ef2138a
BLAKE2b-256 f955b4121097254862bc53fc5b71e99d72f507d896cfdd49af102b51c558da45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ac4e2e91e5514b07c9c8b33827d90f2b50553ba83bf30d3fc84010387ccf6a19
MD5 5fe7f1b6db7222a7eae05eef1baa82e9
BLAKE2b-256 da6b3e785d50a75ef819523f066c2ed4cf4ccd3af9e5f83a58f64c1c63825939

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d4e63567eb207d54e0d32fa9b7968b19138f095635b852bf87d0eaa9556f7609
MD5 3c25e44d736af2a0e4d639e7701c43c0
BLAKE2b-256 8e553d5b00dcad4d998d2a18818d2a1603339007bd497c2a365fb656b0c10b10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b37417374118c44dd4cb29dcf26272c9b0f8fc42938b53c89b747d47f13cfc5
MD5 98586af438fe97d4c1623dad1db1721d
BLAKE2b-256 2928e8b0ba5695896a6f2401268e8dc06bc5efecfcca34d423811528b4bc6515

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a49f28becfb8135fcd45d77e89aac0f0141c7860be6d97be5baacf129413e794
MD5 ae3ab34a6dc1e4e83d5f3674d2deb14a
BLAKE2b-256 4723f0891eb1c6a37e551b6167b0510cfb7f6c17a2c5c29eebc904349e2b813a

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