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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.119.3-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.3-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.119.3-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.3-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.119.3-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.3-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.119.3-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.3-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.119.3-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.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.119.3.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.3.tar.gz
Algorithm Hash digest
SHA256 e12ce09f724595bae992161e50f87d868f35018e9648fb7074c5c0f163c41548
MD5 e3151f1264ba3ce1e5608a600116c6e5
BLAKE2b-256 e7edd6d2b95a085f05434a4446ffa53e2bb1650320de34c17d0e209a22acb041

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.3-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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 174cb34735c95c84c16aeecb49c09a0626612a838226014c98025df13eee04bc
MD5 fdf4a2356aa66a42a4c2c4fc62517b70
BLAKE2b-256 40727aebd3145c2b999e0a912d668209a8e0818c9e38d94d8dc932fa25395605

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4659c17edea2a8c59920fcbb3b6f2a2635d59ffb2876294017c22b3ceb387913
MD5 9c49a4747411cdbb279c2b1a39412d65
BLAKE2b-256 a58fb633aff169b190553e8bfbc6b8cd5798ec6bc2ccc7e4beee760836fe352a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6248570440f23d84fe1299f359f65bcb2533a446b743fb436847c5c8ad3bcb8e
MD5 5cc102c0a2fbb7c6e748b2dbd1e9b2e8
BLAKE2b-256 373ed8332d1940a03fb8ed04404012819b4d85b5c407b9fb537e768f53c2cd43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 721d60325d69fcb4f60226fc272747575a6e6f012a236349cbd875918bb61035
MD5 30811b9ce3066c5101e5bfa22b8b504f
BLAKE2b-256 c6020cae966cb5bf73657d2ecb90e22b4f1ed7adadf857b6a9f6bbef6b95f788

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3bc7c845be31a4abb97a0d5fa628761db079a0289e044ad54c856c6b7fe4925c
MD5 2cfaec6123de5e66e0b15a075feb4fe6
BLAKE2b-256 46d063d7dbe0f1902227146aa238ffa000787d8b84c2e86742abec63fd084e90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.3-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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ad937d01fe19b62ee42ad371b6f5e189aeb8f80311813d16b28beeb9c178f7d8
MD5 51f3b59d6f1ad1eed9c9e711a03000f8
BLAKE2b-256 dd1dceb69e123c95c70925f230cf4c7d8f87e8726ff7fb9bb730085548e1593c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c14e79ac5c7389174d0865dc3d2814d7292055613ab4a9b7f0913f4df093be9d
MD5 e0b06f0f5941e8752f55f7cf68ae3d8c
BLAKE2b-256 8191e9117dc22ebb8cc731b53791fb5156ae1130ebedaab426499b1425b8089b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a0285be3013c6ea991417d557c7a8d2a029d2bd034cf9d25b9a7e5a7c7644333
MD5 92defae558066bd306197ee9fa6cc400
BLAKE2b-256 aea40bf56fb2cc635b8ce79c374124c6a3b683c50e6fb7de7f48b1aa0309c87e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3ee37a64609bc5d0b5baab8c3b38947c89c9dda6f4b239eec68e3acffa4c79d
MD5 f7ca9e696d4b19fc00980ece10d9ff5d
BLAKE2b-256 5adaf542115e85f6a71d64dc225f5ffaa847d9c68f4ea062c4136edd5a2148ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0e6b0f33945798ca400e811fb485138c19a2b298098496c23c7863e3f92e5c8d
MD5 9516779e3ef9f678e73c4afb5bcf3c66
BLAKE2b-256 e8b43fc76af9693a5e42919a269e0bfa7ae4a466c3150fa295b1f19bbd0b8969

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.3-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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7c375f9ccf7be0956301c65d87a7227b2008fdef3f69ddff08680ee01f1013ae
MD5 75a27378e16eb4a0581294ad0ddc3d14
BLAKE2b-256 6a26dd01d6155ed699e42365b226deb77285e0bbeda4086fc36ea22c05456865

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1909e98e69b2899457e49e1ccff2b4fcea4ff8401e12e09cb5375d0cd0f4fa0c
MD5 f94ce73c7ce325fdd2a2f8b9f4bbcc4e
BLAKE2b-256 c603e80e1fa07f44a7941a4a25d7797033ebe0981b3e58c3f91172c2b9943f45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2ebfffd83d91842a352489006ca5a3a1a64e868ca22c8d86484aecb99ee7ae84
MD5 f63728c2903ea51ed7d69fad24635c31
BLAKE2b-256 87a84113ca810f0b0e9c30c922414e6d7780c8c4a638c11cf64bf595e7563d78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 589e4e48b30c0e928300dbe1473c478a52dde79fb12f526d3f782c4a3378515f
MD5 fee5e32c24be55a121aa8e5403b547c0
BLAKE2b-256 7b498f955ee5351a4bb337c6f5e18b9766763c0277575126aceb1da669b58127

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1ae7e1d2c1c888a5402afa0d440e8dcfcb206762f334bd3707ca477ed3984a4b
MD5 e9f2b27d683d2f224d32629faea6dbd0
BLAKE2b-256 50edda14ba4717fe251963a17fd53ea04fd30d834b37f01c85d1bb174fe89489

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.119.3-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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4a0f35f2910d11d7b23756987171e2fa23a09b1e11efa620ddf61761623b5e8f
MD5 7818155d3514793a836b7e35c6eceb67
BLAKE2b-256 b61811a1f7955e74ba079f154ca5358ca4f190c130cfb9cbe057f15036456eb5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a8d8d8a3f9403df9b958fa3a5ddf93863a90b0206bfb9094a222df35089d68b2
MD5 574f1c6a0d4b0331ef2d8b220527b41b
BLAKE2b-256 dd42b7b7ba20043590f901392de1b947a9beef857db8ffeafb832e11b6a02f3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8b18cddde93976cef1dcab1285c817d5aa4b4eb52d8a5f5e719571a8cb3c4a01
MD5 708bd6123d7075e0d449551848554053
BLAKE2b-256 f6652bee2009a87980ef4599af9283c48f6d948f3a6e0036450a078c954bd882

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 789ba05cdbacfb7a4defc18a32c860897c4e3bcdeffc10c7cb6a21c304475063
MD5 a2ca4b005c95c3c94e2d62c58b1e24b6
BLAKE2b-256 3a8e5d4590c7a1d547a66754ff9a76c51c97b59487fe3c7a889e1d3f7698f5c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.119.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 80e10e79a97ffca7028433555af7423dde2f570805e0da65362075e7f52cda74
MD5 dd6719c8eb20b28d20bf4c4e48df30b6
BLAKE2b-256 d4b466d6865d4bd7a91bd936a4914b00bb0fea236bc50e1b6d175e4e5e512828

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