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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.112.3-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.112.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.112.3-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.112.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.3-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.112.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.3-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.112.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.112.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.112.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.112.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.112.3.tar.gz
Algorithm Hash digest
SHA256 b707cc986837f4b6138b81c322478dbf21e5a14b7c9110d4a1c7e25a894450ed
MD5 e703ed0ce6decd5b4dfa413c2db9d87e
BLAKE2b-256 f7938683d0f3b27bd49fb8d2ea903b57fc0379a46b7a9ce2847d5424207bc2bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.3-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.112.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d46e7ee8dd770f06a0e62e711e513c0f9672ece0286bed8ceac0756ff18de704
MD5 0e3529956ccf642ca92595c3ebfbe0f1
BLAKE2b-256 ddc5da7122dd1904bb0ad43e580e1e301683fc500bfa3af8ca3f22d0d74f44b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7872e86aade43e0786de9bffbba95ed36fc887a933864531bcf8d8c96f5b92e3
MD5 df594cd28f44674c470732bdfe928d00
BLAKE2b-256 f014d3dd4b8b8bd33941d38745638b12804278a5180433bdacf4c50e43de81bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0700f8cef81e98fb95eae8ee5e6bc79b3ba4f6608c7311ff6461450aac71f4db
MD5 3a7652aebf4591a2cfd8ddac8c1620f9
BLAKE2b-256 132e00b65f49c6d98ddda1fb90c6e4faa664af587aa6bfd944e14ebaa9af41b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8cebbd75fc25c565ceeeaeef841da91959be3102a3bc5fa9728c57ed581089ae
MD5 8e9129d2629f01c0a5d8dbd883663ee7
BLAKE2b-256 bb89de91b7e085e2e2e6c9dd5efd7f9b96a238d063fe74e778eb1144f61febbf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 80db25111d3d0dee31ae80258d5c6434b68ef1ea19938de48e77266c3334c907
MD5 bc460071c450cafb7c315f06dca75850
BLAKE2b-256 433691b8f3bd7a07a76ca90c37b64422e27b615a725bd428e612671e33944b70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.3-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.112.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ceb2f2b25508a8cff97188bacee95e1ca5afa99e9bf78e0a4fcf2d99f4c12c9c
MD5 00056c28a90e719e0a2078b234238d5f
BLAKE2b-256 e8d7f9bac38685df7e10d71ed5c4d2c157875472515241cd6d2e1ea4e6dba347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d23b46f0ba14b33ebfc6cfbf4a845c2aaf27d94692867177dd97b89fd6ea53f
MD5 8f99b0fe436164306815320596650ee2
BLAKE2b-256 630ebd6df33635883d2d101833fd7587c7e6c60d4ea9784772f99d485ffd37dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9189e5319b5e834f390d433238ae4bd16113e55a35165bc06ccba7330fb259b0
MD5 da5f89c9982db98b33a04231cabf602d
BLAKE2b-256 668f739045b2e85f4727dc6c669dd51d35672fb7e635d070b5af2be6039c313b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ecf845446250c1f3a88a89cb27e1fdd716ffb776d15eefffca766162fb4af0e
MD5 d9efd7ebed5e2d2320c12f6620c70aa8
BLAKE2b-256 7bc1229394ab559a12f8877611c0c5d291c2c1427c0f90110d172d60e5410b88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 abb8869986cd7049d7f9ebbeeb0f220c31e962665786621d51c47bb7d8ab3ada
MD5 cca0b3ce65000e245ca871105407b0e9
BLAKE2b-256 c67f83f0fb731e25a9df7dae3886012854c39ce305b739138c29fa90cf34f39c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.3-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.112.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 95a0bff10e6761030b0595cb698ebef40928cfe82eb5aa55905b0d9fe366db32
MD5 b3174d777713c8782cb3c46efcd363d8
BLAKE2b-256 91c40b787838858a911080c82744f0b0a8aa3a512e96f1c9e79a3b82104e46e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 32dc3e5263877b19a3de0bee1f849da9fee625f858cc3826fa762102e234069b
MD5 da6555f0b6dd301aa41b0401ee18c4fd
BLAKE2b-256 4851a5d2934a6ce2d1aa888cefa7bff7060fcd57148f0231d3b0eff006c458a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bc5fba1cebc92ae7e34cbf8afb9acf60fa5ed6481177bdb7797c9055a56a2db9
MD5 b3c571f4710c8b0148a56114356fd35f
BLAKE2b-256 e1831657c1ce59cb4fd729bb803aa21f2af7fa6eda74368c9770f2d8a2b84c9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 183a9bf5002438c6bff419ec1da4e6f22d08041fee5dfef1f819f3b04aaec6f5
MD5 4e53113e9737d3e271000c14c62c27f9
BLAKE2b-256 9f5d35ca7be66ad4ece430574f1f94e1561b3a9537277ea874fcddd1835a3702

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 61c86546abec70dec69927200e9674129532bc7b845e52d7f85dadf9f8162837
MD5 83cf53665649584a8331eb49da966482
BLAKE2b-256 7221807f20735eb9d15d7cac04c0a0808713bd8f4e87de5e7fafb8a6e13167ec

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.3-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.112.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4216b417e015892ca80970bed3ae01c51c694ca36a65137bc0b07b88075bd3b3
MD5 4442f46697f29c8848f55fa93ec19129
BLAKE2b-256 f17259f5eb1a452fd1ab18cb1a2ca7903d76f3653fdf7a08b5e2547bfe4afca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d647669f23218c656fd645ad6c601f401e175c28c03d2eeec1de1c09a684e3e
MD5 9d316917bc37a1cfeb0e64c2bdf954b9
BLAKE2b-256 1eaca9dc73adcb3f8890dd98a22588392d3d570d8882b0a111302505e2add7f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 43ef60cc769cdd78a114b39c29ab3a6f34a73f6926d02b9fda720c202e786fc9
MD5 df18929a08514b00d10b16e03e7e74b0
BLAKE2b-256 5c9600dfc25afb0b2d1778ad4ab834801a304414964e20b8dbcd0cf0a9221c8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d4ef3cb9c6ab9cceb650f0912df4bb2b205acc12a3fd03777f715ac1efcec5f9
MD5 55f7cdf3826cdda063e5468085461486
BLAKE2b-256 38ef1a9c7707787780c9b5e8e95f58eb536d9059dc226379f014193bbf872b16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a50816cad71209d47ec695ab23e293c1c45fe1b5bc926371ff3b71e588bc3e64
MD5 dacdaa31909c166bfb55a2747af550c1
BLAKE2b-256 20e68e65fc25945ec745b9e7b8a9a6a5fa0d4336c4605a22ab9fac270c2e41f6

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