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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.123.6-cp311-cp311-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.123.6-cp310-cp310-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.6-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.123.6.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.6.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.123.6.tar.gz
Algorithm Hash digest
SHA256 61c948ea46e634c49855e1b9d62fd7386a660c30ffc328c2be41c07aa103c33b
MD5 4852763715aa3ae4ceecf909557e9bee
BLAKE2b-256 384e6ffb89899931735aa03fded78bd2c8744280dc13ac6408c2347ddd7afd70

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.6-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.123.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2f7f68f4345053b46956ef062c6f034b5e7adcc1b9f4756d7804410f48635ca0
MD5 161075d14f893b4ace192c654856bc7d
BLAKE2b-256 879dfd7055c8e6b0dd67731b772c6cb258d2941ed876abfd36b842ecc5003e33

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 be72aaacb529f9b8ed08c22eb3a5cc4fe385f4f5210c4d31341b298bd979af1a
MD5 ea63c39cb2bfa53e41dfc84a38a0f7ab
BLAKE2b-256 85b8b94f6226bbb8c8821f103beabe84dc01a9f4a653fa52f2889b318bc736a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 606d84d1bf53e753b1a01f22fae586244507cbd6b201c3c3ac0ac639ed88742e
MD5 50cc90879e55a8eaf974287bfa569dd9
BLAKE2b-256 bfa5814a7735f46da8c7c5f0bb43ca1088465cad49074832b7cd3779b962621d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 986bd97c1045f2213827b6a88774d7e611ba2ae4482427fe3a640f0e24f6ef2c
MD5 ea6850c5ee6de2ec29cea939b31dd022
BLAKE2b-256 8f241a04561e3eb84a1547f3737a4db5e7ea34f97564f5d6b3bc630335e6c0b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8fea34d57dae04d23fae6c7dbaade50f7d931bfcb127b046a4ca147cae2e1d46
MD5 d0420881c542f815dd0eea99facfca60
BLAKE2b-256 b97a5e5a1f15f4d01c8d2a9c6b2148049b595bd777f474f5a4b2f981954e0332

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.6-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.123.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 750608ffb0f8482543b5bda74a81c062aa2626c6a95cfda3e727fd6e90fc6850
MD5 7cf457d81dfec5e6ba6c747d81784678
BLAKE2b-256 0ee65a53348e04fa1f6b896a9adbbbe20cf85539f4194b5c3b9a21e9ee000cac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e868c86a9e3ec007d3dd63c69821f39cbf9e05401e9de0822fea60bb84d5627e
MD5 33068d41ae392a8d6f652294ea88be87
BLAKE2b-256 de93a4f61619ef6a4ceffb47be39d66a05851c610c15b36d0e37a9aec3ca9215

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a54bf73d2dd9c633aa9a87c77caa5ee42a0483f32ca3eaab4ceedf4c7512f97b
MD5 1769b4fbd1e6a490f9138a36ce3f0132
BLAKE2b-256 ad9a00a6c9ae411a8b99446ad95624c7b7b58e75e01dd397a4b368538be28d7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2459f7d3c00e7c2a9acd73d03621eed3733f0c868ba51c0b5f7cce1de72e023c
MD5 ae59249e2ec51d66510f351d9f893e71
BLAKE2b-256 26a35291b90af7eaa00e7fde3b5169fcdbbbc5d45a7730b0d5ac09057719ccc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 eadecea1ac46115c892c847ed202cc28d6146564a390bc32b62eac65044c1ae5
MD5 2fe1b077e47d0c669791fbdfdb1eebbe
BLAKE2b-256 94cdbe1b968dd35319161faf484f1c7efaebefe16ec26a731206fda6ec68923b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 f730d8a96946ff72243153c1d9fcb26c4afc0facbecf6bf4e21dcbf6a6045ab6
MD5 e79b4e1d7b96953c912be051f9ad51bc
BLAKE2b-256 e75a72f174bfd3ac9af971217eaa8e1da10b5b9f4a86573e99e0c2cb29ec91ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0bf926f9abbd10627abd369647e26760e25872213ad4ffbde8fd014d39a4b71c
MD5 20b2a0f29f3b4c011e91c89dfbf4005e
BLAKE2b-256 a5a8e3e6e5873854c4d65481138d7519495390e11419a0207908436b8924f028

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dc0b3ab8e2a28d8168ef1becf1c6cde5b8ad75d26c4a756f213ec88502f1c657
MD5 8b111916938da20099c4473ecaaec1ae
BLAKE2b-256 fe1aede66a82d8dc1ab0f0989846009ba2bc11f814ceb3b0d4e9277bdeba3859

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 303ecdacc9ccd0882044977b1bb0e87c486f25790f92357ad8aabcac5419a4f5
MD5 b004fe3a871677daf5712146b86a57aa
BLAKE2b-256 2022dfb3b164d14b1b479b11496ea00d0b5a4dae5c3b1f732c052e63c3b8b514

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 19c758ddb3abb4448b3d77ffaf262a5fef3529f61dcc7ab2341c3bda1b4637e7
MD5 d3307983bd77ca64bfed58a43302f8a8
BLAKE2b-256 e1b3a4ffd61ce4c302b81368f844789737c927ad703f881136561d45b248329d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.123.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 21a6b717c59e3f1327db892c2182268707394a7a38b8dd84b7a2dd78d283cab0
MD5 13b5ff7b854d3da81c2b9b28b32dbed2
BLAKE2b-256 226945a60d0c76322022f5afc76ea14370730ca858e63b6a2e523074c756e13a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4338eaff36b87e86bffb22752172ebca01ff5574e306a4d6fdc331a80c76ce6a
MD5 6454743fdf3115a00d3d513573c4e915
BLAKE2b-256 560fe393d2e6362c66e415c6b2fefa15806160bbf8b2b156114eefa9a1a58c2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 55d56b0182aec1eff3bbc4db96da8fae3bee7fce3fea31374405689f90ec2b0d
MD5 8dfa863d55bf0db62b8ab71f5e6d0f0e
BLAKE2b-256 9e6f3707b9ae101e2d7e49f1a19fb8806d8e0b8bebcba5abc07d71a05f064f9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09afb4e8afbd47addf23e8d963d2b33e449023906d8c917052898ed9d7c8d037
MD5 b051d979b7e6eedb18e57a9fa7395cc9
BLAKE2b-256 e25451040be5baec2845b784d8d984d0a1a39ee2c94d305b2be0ce92525f16b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.6-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f039cc6daef82f033643c134fcb7cb65b478127aaa01a926644d1cf0acaa8b6d
MD5 add29457eaad14d86df0b2049568c476
BLAKE2b-256 ca5d962a805e3a33c0b3e161d29c114524b778979ceeabd9afaff8ee1f7aa669

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