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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.115.2-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.115.2-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.115.2-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.115.2-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.115.2-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.115.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.115.2.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.115.2.tar.gz
Algorithm Hash digest
SHA256 86da8f0496b010903b7bc134a169a0aeab5a52a1242c260a4b24d38159045766
MD5 d98c10bec33264aa40c80ab9cc3e46f2
BLAKE2b-256 0d172c647c67ce5510e1b3ff7910e1196b47027255b6ffb83d60ed2b81b4da4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.2-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.115.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 92c70a1065a786c4920f7e8ee0b840219093da2e439642520d85fdc5699fb489
MD5 682dc8f1ff4cebbb625f95df7b508fc7
BLAKE2b-256 143c4c3be8ed7af84670172be458542e6df417f01e93474ef1ff42886b13a75b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7a69d75107ba75d0ca5e6f0dde9be3efefc86ad8cb26dcb5fb1999adf5256a7
MD5 f2d1e5ae7e476b6b8f472a61b5813def
BLAKE2b-256 3c496424820c6f68da78dccc5be0d5f3b07f01f4b4089d3fb31f929f1f9e71e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 17b9d0350390d7d6c8d9448ce6d5f8db2dab4d479a7811a99a7fb7c00f4c0b87
MD5 eca593c804334d8aa337416762be30a6
BLAKE2b-256 58de00ca7a5f912e50a5fc2e8cf1c6d4cd68a6a3ed82630b148df47251ab0181

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 da3bd2752d19a20d045ff575e3f58daef5eee6f3119c4bc9fd96efd7628b17a5
MD5 80f5d3a6605d02afdaaad4e8c5eef6f4
BLAKE2b-256 a71e033d4759781f67a992fe59db8e482a88afd71f41e6847c6518570ab06e8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bc7b7f52a51fb7dc49d52c48978999f6be190fa61d46dba11206efb42ac33bf9
MD5 7c060c8230d7c7b5c328a765ed844570
BLAKE2b-256 14b21a89a2571ef48eaca9145573286498d0520b46137d1601036d2d2d524190

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.2-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.115.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f29e37cf3eaa041444b8e91c719d8a320880278a319ba001e07b69a4b12b34c4
MD5 df97b8b27f9fea2f83c5b962ba440c82
BLAKE2b-256 8545ee51d54ff3b901000b27391067bc54245c16a50e9adb09991b8d7a7e7666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e500984e18d0dca07f5db9c16cc596062bc93449391c80ad604424bfd0d06c18
MD5 fdf4790e1d1f91be7a762f8cdf031a9f
BLAKE2b-256 444d25ef2ed44f9f54befca34729133da421d1e1dc0d322778d1c37715722ee3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dd65c1bff1cb641893104ca763e1ca6f9ad88499b7acc819f3eebcedf34b370f
MD5 38c5f42b2141cdab7ba24f6175c8acac
BLAKE2b-256 4bf96c89e78d62efd8b8242c4fb6d8670fe0487d49ac2a5e12af49ec63bc82f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93020f123056dd11217a057cd318ef406f38db49c822ae395c3d371fccc01fe4
MD5 87c50e6e22d45ae36778750ddcb43620
BLAKE2b-256 b03adbdb4831b6f05bceeac3a16dedda7cde0a29a52e72fa7fdc289736934451

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1f9d571cbe263443f8397ead76f2bafab6a20dbccc23df3386ea72e34315aca9
MD5 837188cf045b4b2248563b96805122e2
BLAKE2b-256 cf3b291fbba19c99a0302b49ce42bd82fd29a187476b9b06debc2aa9d3715b55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.2-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.115.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 21927079a35a4f23fe7d2ec44a979ac695c12b736abb91c286ec50f5fb4ffe4f
MD5 969e0d1eb8c02f9ca333a0eacb5079c9
BLAKE2b-256 445bc21990bdb61a2669a7ff00a804cf54151df38368406e6b96372f0851aa29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85819daa674e079f45de08e2b64b3cece3e5a2e7cf455f142c05b69ca9a5cf5f
MD5 c72b4433d591900dd91491b50c5d4678
BLAKE2b-256 dce93c749359d6fc683bb6e6826d747cc208d456528cda4d417a54496b163486

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 588115fea190ec10d210118b4ac3b724a74c4523e8f195bcda7a529c5f2e9f42
MD5 038c6e9f7e473bb469cddd8c9ffcacf1
BLAKE2b-256 d0ebeb46a24ac1d52d3233a63bd7454d34ba89de69d3725da8171ee58876842c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 defae586e506b810fb1c62478c544d9ccd30b1889a4240a778c814cdfc7b8ae3
MD5 6effcae1a742ca5f4a0237c6664306d5
BLAKE2b-256 4c9f250b2f77611cd420495580b607bb94998bf6e35196cdd9a420a893c2328f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1501ccb5af0a0fe683613bebc3baf382415b7e2eccc7a99ba59a7eb5cbb8a23d
MD5 bca669c40fea4895ae8f70af450002a5
BLAKE2b-256 b0f61939b9e468f173a0fc572525daec129eb85c65a2e65331c000325166facb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.2-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.115.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 05c0ad9236198f1426e8981bd9631bb0306dfcc944a88e9696cf22131cb808d4
MD5 6bdbb91809507a89c12d5d051175b8e8
BLAKE2b-256 a4b41e66930364b37e09b8231916333e16ee56c392c5efc2bd346558b13998d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7300d505b68543aa35095ea0b374f7d65cdb2408644657a5f8df634ab7a3c3ff
MD5 c55d26d2e4d89dab3cbf2da1bd1f9617
BLAKE2b-256 c53642c468338535c8289ce0ffb258ea6db36e4007c72e44826da9ae23f2be90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7f43d0bddf7b60d48e072064090206934e3bd674a9fe97d91b4b20422432c155
MD5 b85a84c97d0ebeae06933d68cfc4662c
BLAKE2b-256 00dd9face91f0a8cee1155f61dc8f3d6fea43a8a0c49dfe68733b5b28fdf1a8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff22141c42b20bac245737d84fb5f6808b75ddb4b0f34fc8e2414e251122b352
MD5 4b6fec5f1185fdf81dedb725517650c3
BLAKE2b-256 e497cadf3996543f354cd9a263dd26540bac27c08d123940ef35eace0f94ed61

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e24156d2b666be749a2d8021fe5899f64795d416f6aa76cf8a39a22215741874
MD5 84b091139a9ea60da24a314c6179393a
BLAKE2b-256 8eed98b34e3474988d67d79bdf78098b83935ec129698e8d3354d495ce7e3463

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