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.114.3.tar.gz (1.4 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.114.3-cp313-cp313-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.114.3-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.114.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.114.3-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.114.3-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.114.3-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.114.3-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.114.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.114.3-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.114.3-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.114.3-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.114.3-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.114.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.114.3-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.114.3-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.114.3-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.114.3-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.114.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.114.3-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.114.3-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.114.3.tar.gz
Algorithm Hash digest
SHA256 592ab17202db5487e5942169ac906231680b10a07ea792622ccf2412fc7b1929
MD5 e8f0812804437836a7066cc924cf8921
BLAKE2b-256 aa007016f86f2fceebd4ea446652b22fec50338b57dcd702d2d720dc09aa440f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 33d8c4454fe06ec556fd0119b97a3dc430af6a39170c356739ccc3c89b64766f
MD5 adbb8830e967aff785381f7ac319c4df
BLAKE2b-256 b84908fae70e467b30a257ce9ffb31642af7748a5cab4e5382f922e6ed5ea348

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a17cab305f91ae3f9f9e3a2f15d02a537998fd3e1459016f1ea57714fb4ed22
MD5 e3bbc8c3b4abd216ca6f120bd5e9ce17
BLAKE2b-256 881055910e0db4cb9077547f19fab04804419ee43891938666cfae75d91a118c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d94f183d855042eb0d064075b84ad5c74eb0b59505dee6a1c59429ce366e2087
MD5 d4c1b018494ddb298d75443483b66e7e
BLAKE2b-256 4253d8343f39c97f6eba32965ebf8d68a6cac1dd55dc733deee5252399ae30cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1819617c1330d02686afe86177de5ad9b4e3953b580f89db6cf5bcc05360ed5
MD5 5cef483256bdac5e7e7c8e5f24c9e5c2
BLAKE2b-256 1aacd64816f813cced67f354b66eb72f492b2c0d999eb226732f54620dbcf4b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5d82e0a918666bba37e9e273ed03e3bbc8e00cd4d32c07731840e60214bb75da
MD5 76e9086d52e95743c39c1854b542573f
BLAKE2b-256 6d00aebc067e16e374c2267e78d5418061786e8eb5006bf03680e39e4f012776

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 49a0842118673e56c19f01f4bbb2e57c07391e5c192c6481c684fede3bd1ed49
MD5 c7709f0f114af4ad4df8551296a751b3
BLAKE2b-256 bed3b8dc47bff67a7b18492e90d0682e2a0e3bb3eb56c5305a80b4fed6aa0cb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 340f2a8f071d0e7e6b1dcbe72f6a7de261b4989c8beefe486656070d820bdc26
MD5 5c40cb1414efe8d5f3e22b9db4b80b34
BLAKE2b-256 2294bb043af9a3e77adbf700ae5e06e0bd294f5d42e7808b3b11dd8d44363a63

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2cbcab547f3149d22788e7b58d66a7452da6164b9e2113a842eaa1418a183c32
MD5 9d8b3e63619db4a89e3b649b645de460
BLAKE2b-256 5c4e0222438e445e1e8175eed4719cd51d1b9f98eef9c2feeecb922be6cdf6b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ebf323150a8752620e27e0542a9a0f1fc740b63e2a70df65d45be9d1d5a7e29
MD5 a2ec26bef221ffb12e2110603783fd3d
BLAKE2b-256 0ac700aa265c5b74e63a222fab5d995e82d47d517810fb4fc17fb5a8a641ab70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f3d4314053ef7d1c5a15149758e158d68e98535900186b305bcfe5bf90de7a72
MD5 0b6a27a5d412cf019f93e0aa9bca54c6
BLAKE2b-256 2d664a4223da1f9284ed47435360d39d4f5903149b812c85865f6cfe9d1e5b47

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 98ce5d0710b00310c97e1a3c9df9edabece0c0caea39c5474410480a1f4fee7e
MD5 41aec3b3140ae53d9889e04f2bf2bade
BLAKE2b-256 d593bdf26a96c0898f9004f69d1d320f6868e1125bca16d8a94070c105a4d391

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f3b4a8e560b86f70e9f524a7745d5c996b87229fdec696f7405316dac21ca50d
MD5 d478c19674e70d860cde09230b67ac8d
BLAKE2b-256 114df0fc81cfe59b931380a32346cc6163d6ed25d839a17bf01c6c6938ad1b73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e43bcff8188bdeb32e7dd2e6043389b67f933801f45f5d947e8d11054e6d1aa8
MD5 b33581c6350e804acb69b0cf90c53927
BLAKE2b-256 8f40fa25a145b1d6f6bd5fd0b37a8a91937b798e40af754a88f82a157ae75a98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34a713d60fcb3358e751daf06cbd583f364e0274afc712bea9aa3e6c26622bc9
MD5 a2d45353641d2de9c237bbfc99bd5c50
BLAKE2b-256 600be7e9b4ad43e66926ea70f5dbcb7b6a5598bd970042ccf4e9bf64a27c3f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a2f1f4b0876b4baa70ed52ca0975a71c0496acb20dce7847e0b0210401e12f37
MD5 068141cf68763a1d1ac6ad8e9b872fb5
BLAKE2b-256 88988deebe87310e628eaec506a7c53359e7ecfd6b3e00ace0dc6c1dab51d9cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.114.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.114.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 59d6fcbadeeb7ff7c25b6f067c6966f16a9038b2d8da61b2c954d70c0394801c
MD5 9307b2de612943cf1b441ea5cad80303
BLAKE2b-256 261c135db8ac12e6a778773b75c20b568dc1effbd403d1a9a8bec418e2539b26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8059f247c4fcc7d2fc187417bebfad100abe9386783ee201ccca9f710813801
MD5 5a645437b836a9bf8b173474c2b652e0
BLAKE2b-256 bb7ce65e8e20f9aef7b0f3dbbe5ffc9b4746f2f7da96b083e4de8e9bcd50edcb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3f976afe742e571ecbf02f5ad0185226699f2e709a03fb1047b70b4f381e8028
MD5 de0de7fcfe63e3f54357ff1350c2f9db
BLAKE2b-256 93ef87abae391277623eceeb317820823b188a095273284ad5bf9c6bcf920961

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a4196aa65a6d9ac562e097ff72f9c0325188e2f6f74d97d6c809dee3acf80e8f
MD5 d1db4e7d7ba4bf46938d565cde79a546
BLAKE2b-256 39e640c02acf19a887b72759448370db1569e218ff48d007e67bca38c6b80445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.114.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1dd89006c278dc3c583e5c02255cbe4506ad81e877a02a31af307ac81407ef32
MD5 9deb155db530f2b4492dc253fcc9b2c1
BLAKE2b-256 91e4fde2440e3330689b8510279ae541d2f76381ec943c9ec714872acf3d6f86

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