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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.12-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.123.12-cp313-cp313-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.123.12-cp312-cp312-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.12-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.123.12-cp312-cp312-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.12-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.123.12-cp311-cp311-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.12-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.123.12-cp310-cp310-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.12-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.12.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.12.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.12.tar.gz
Algorithm Hash digest
SHA256 f829ca97be48c4d26b697ccb25534c08117029b17332258eef5fe8dc09a9dfce
MD5 cbc2b1b0987dd73f72db1e47251080f6
BLAKE2b-256 36c2f265cbad1b95ef8b7075f93dfb3bbf9e4d1f40489164ba7a7e67ee282964

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.12-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2a4c783b524509b52f2a81080d0ab0c84e28fe02d6614fb06627a952351872dc
MD5 bd2617dc28b1e5d4bbd58646c7c8a52a
BLAKE2b-256 e4639e6229b916ea11b9380150479944eaa8cffa32a4b2b1c9d068eb6502c901

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e8b0bd42f79b1f11b128b466f933305ce5de607cb9aca456aa165f974a286a9
MD5 eced47f30b37ba2007cdd62527ee6374
BLAKE2b-256 164bac73f79cd83af1fa5ca754855918802afb53b6b1e313151b78a5011b4d75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 74e4b4cb8891ebba8eb9a7036ded77ba68616f80b2a6480e398acefc6efd7245
MD5 39bb0c30ad0433b96cee15ab7364e4f8
BLAKE2b-256 f694699a209dd2c926de59f3cbb86e4d35adef896b4ed97ed8134bd8b1085d99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59db04740dfb23d83cefdb6a105953afe6b3a09bbaf5dcfbe45b92ff38769fde
MD5 86c4e9c1cdace197561c91a9d29c201a
BLAKE2b-256 c59d9277255cdae0c6aa6a9c3f4844899a7066e81ef30a00c92f576dadb1a190

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b7c6696f3c4bd7d7d982a938a28cebb9a4886f3982a9e19ed89830ca8acdcf4f
MD5 b17eb2fab825b7f3b06bf5ee43891eb9
BLAKE2b-256 057dd873ecb21a1467777db21986dea856c411c9407e47f2f12ae237c2bda3ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.12-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.6 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.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 391b85c19916e90dc6f8783610d483b6aaf3f18d0d55cd160b359b683e9fa012
MD5 60953b19f4d0808399bb9389915a86d1
BLAKE2b-256 6dcf7eb8baa0c2a47c1ef885345722df05ec44f16f609d71f11a776a302f6d8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ea8902148785b31c747a0f71e25c1f70074fe37f11d7e6a355e296ff2381591
MD5 d96932b0e759f0ef6e8645ba1a850c73
BLAKE2b-256 f2e3ac207da445fb503275802c33ef65da3cace8d14a995ed98cdc4bfc07119f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 54e4cb8041dba01a7551174a15d266f23a03fd335e06eb7dda519e96a6d90e5f
MD5 7ea48bb1bc0dce2909239a4ef30f78c6
BLAKE2b-256 fa65515b1fd436d1c3380170aa3f2a2961bca3bc474081b183ae7f3f489fd9fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3e117fdb6440c9bcbc4f896a678ea3f170c0bfc99cc63ce6a20481b249f6c533
MD5 6f35384a54417a37679d752af31f5cfa
BLAKE2b-256 854f40206a1de921b29fc592b328864fca05d8941232e0c32223081870992c28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7e9d642c61108c00faa781ea5e2f71344dddf0f094f0df6c2e6e6055473822d1
MD5 0cf77e94094ea29e4352de9150fb4dec
BLAKE2b-256 1179df85e49579b4f806f2043503a2d15cb6e0e2161b926f96128b34fe2d51f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.12-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.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 04d10fb3d82dccc3db116af14a1511c06619fb9a4dd555fdd8c9d934e525f04b
MD5 d21a168a6079a10fd71e5e711cb53761
BLAKE2b-256 c356a0951e815231e0a72d95b1596d2e5138d186412fb6a73908091f208879bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aecef0b4cdb065c54e8df35025f6bcf8e8c00fe5fe61954b1810387ea78365d7
MD5 cc36461e85570c45ecf858495755c5b5
BLAKE2b-256 c36d1f138a7b10afebcab9b148b9d49838fa6655644866be4f7c727a2630c969

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d58c61048d4149d5b51272f15b370a44d625a274ee47537d2e48d42ba8a5410a
MD5 cf3f9e8a3665ca27e9b4f1a375c65d50
BLAKE2b-256 c14b02e0a6aff2907761315972dd6c66b5cb257730f442b1d58680feb7d6ab2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 98a6dc46fdddb1e7b912ff4b56b19c3c394bc31eedb0ac3dfd32ca457f05ec38
MD5 6c768f065fd83977c21a4c8a47914a0f
BLAKE2b-256 b022a8dcb378d160709b8ea1a81725b5c252260041e4562fac1a6896ba77d2c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0a976e5fa06cc16595331d60e3c682998de83810bd36f9ed0a089a7b7edef448
MD5 31ae74d362187e0b3840696f5ff73702
BLAKE2b-256 2841456a5f07b3f0ba3bd143369f703b2ac9075e6a7e78ce0676a54057bfe479

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.12-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.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eb61bc0a7b3bcc8fda4d80b9939381a2117bd1528fb0c9b044ee3f0268cacc83
MD5 4d9f8df7a48be96e16013e66474a2b59
BLAKE2b-256 bd5cea9411177604f56a1a51943c5ffdaad099c5338bcf58f304cb3715c9aaac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e634409ef66e251746838041cd96773d6dc0d3bef638fcd0033af546d6e23ac0
MD5 4c7d75c6c0ffd3814e07ea607f3469a0
BLAKE2b-256 db366f7fa47c691f72ebed7434a63ac36a70f79abb9a6b788e4f5aeee5b7a6bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 083f5afb269d6c4276f20bc026b7bae7ead6d7f728dd14f75d5c0ae010769cf8
MD5 1f82d1551d5444682abe570d90d538c4
BLAKE2b-256 75176b8d62a8de309c1d39d886736ff71b8f5ae395de327512a1149b22ce2f2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dea0c20a4127d2765fa08c17c59baafce1aac19b2b1c3689c85bc4c4455ead7a
MD5 353f4e8e5c830ee1443e0d7427292f0b
BLAKE2b-256 eff17f4618d547fbf51414b333b1f67811e39f66843fa316b2f3be60b8af65a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.12-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 47d65f4bdbca58ec4ede9eb9e11e8cbc1f89f8ed74dc10c3c8230468c88c829a
MD5 a244a0cb2169bc2c45f95ba303da5a26
BLAKE2b-256 090215f7fd9ee6be6b6d8c652631b168002e738f36f1db7ea6886e3e838d7bd9

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