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.109.2.tar.gz (1.3 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.109.2-cp313-cp313-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.109.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.109.2-cp313-cp313-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.109.2-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.109.2-cp313-cp313-macosx_10_13_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.109.2-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.109.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.109.2-cp312-cp312-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.109.2-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.109.2-cp312-cp312-macosx_10_13_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.109.2-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.109.2-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.109.2-cp311-cp311-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.109.2-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.109.2-cp311-cp311-macosx_10_13_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.109.2-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.109.2-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.109.2-cp310-cp310-manylinux_2_28_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.109.2-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.109.2-cp310-cp310-macosx_10_13_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.109.2.tar.gz
Algorithm Hash digest
SHA256 37c653bdc25de7a192654886f6e3daf27c7314ecfaf7de096f5ef977af21f533
MD5 add9a16495da6dc8a93ab7b726c38fec
BLAKE2b-256 6cb560e467d9f77d934504969fe72ac5b7386f1d8701693e58331a927f172140

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 68d1ff37fbb73d002237fdafe89e06aac16b6f450d724c515999407f59481a6e
MD5 add4c4ee32a0eee4b4a4ad6172519cc8
BLAKE2b-256 a5aa60f053d394df1983606be1c45649ed40a710897c521a6fb6665dc83d05a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e4774def45071f667aa67bdb252481c531fa1a6fde1625e71a4657583901986f
MD5 8c2afc4984b385cffc0f55d3f9c05595
BLAKE2b-256 d3a7a1b6f1a03097c81b4273352b0302257481f5fad28128e35898aaff543a40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 581b15657402ba86f58eff184f5402836228879b9df085e19127e6c713c14560
MD5 42cbbdf3b43be7d8bff5bbd7fe32a311
BLAKE2b-256 2b9a5892555944b0374ce05b4742a52176b1df0ee68b9283550980cf59e798dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 763284ec8680530f2a8ba82e511d2102cbe44a0061c4e5e72429c8e398bbe3c4
MD5 f51ef0fd5dbf3869c8e5ce7da6b5c2a3
BLAKE2b-256 fdb871062de3f922f13f203809574fddda526e27c57760beb0a5f2cecfc6378b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d56060befc3ba440196c74115378bb88869f0a73dc7c5ef7197b8d9050ede9f3
MD5 e2ec234f1dbd4006c16511b66415f6d1
BLAKE2b-256 e0e4163d839ee5dd151ae51dafe9a5e891355e4b1c66f60b0b1be8c657196182

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f555d2d43249f23f8970a8bcde21af56db4b17d3fdbb733d95e0e481d13f6f1a
MD5 17bf4f71f73eccce2b517256fbedc879
BLAKE2b-256 6a7721f558c6c97b05fd3e0c5d79a86f003747758a264d9deaea47a6aeecf16e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 12f2b7bf353adf85d791a50bd20af362dabf125823e8bcd7521e34cf61ca8996
MD5 0c2dac9a7a162121327d0a1877538ea9
BLAKE2b-256 f164c3b3f8baef2929994d2a40cd882b0012909ddd2bf7e0e8bc1189156cd2d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 433fe660dff30508589e92b32d78f781bc244f9b281b265e7b286b73682d35b1
MD5 f498bc3be898580caa48bd117ad839d9
BLAKE2b-256 95c88a3cd116f7406a53f58dfae1f28c5fd79f008f63a98d96b84e83f9d5a38a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9d4056ef780f4084c84a5c5789b452817ce2895976682e353b4ee977dc56a399
MD5 7458d1350f1d88c9d19dc2e03c06f4fb
BLAKE2b-256 a4abc951e7f32b01dbf0c8cdc886237bb709dca8c023e670562dcecf12c49561

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1f652dacca66662be5242a4eaf32f2a217065c58b11047d80f00e180492a4afa
MD5 d93f25836323627a65544a6c11d3c50b
BLAKE2b-256 6763fc519261b7dd212fa66d694ece9871165cd2421a59a9af981932c0e36001

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 720e20d86e39aa856025f2da6e8aa62269f3f8877e077722b7a70670efdc59a0
MD5 66304965b0cd7b2205d9787e091c6a32
BLAKE2b-256 3ad39839e8406f46c13be25be4eb4d7784ffb65ea3c5103f21c914e818d5ecc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 618db21aa8a7991e248c8ef207362b75f92adeb72a3939b73bf0f4565b3e1eb8
MD5 6d8791afbd25747717f003d58c46b431
BLAKE2b-256 7b7ec8e9df70ce9dea276e92697c96eb31b2db0f75e7257327cd03c8f557d95c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c9924735a867f19040f2ff5605049715cc019fc81f6a1ae7fbd17e8308697cf9
MD5 a5758a2ed46750f881150e03887fa803
BLAKE2b-256 f4b8b70519d5809208f233cef20a8a55c599a0d5911ddc9a10f6b7e8406c83a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b241d0e0a266fbc41f6ba2f47131f0800a87629df23e575cf5daf6e8bcda39ea
MD5 2531509c13d9a6cb0fbb28207b057c1c
BLAKE2b-256 5a053cc7fb0b324b62a90311491d5c5cbafe8e6eb08cb10307bb366d1ff9a233

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 14256bea9676e98e52b5f21499fb2e962eb46e3e61150c5825d01aea67f8d805
MD5 04e9fd6343da17b5813b9126b79df07f
BLAKE2b-256 58befccb40ce333eb52443c7c8b886d790e45795aa315088d577617639cbc9b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.109.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.109.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5e78be836f4bf44479f69224d00c56701294fe439c94a366b8d469e566f3ac8e
MD5 0f705d79e317db99f9702f839a0fa153
BLAKE2b-256 4e5b0064c36057c7bb72d0ef8967c7ae473242530b223f0ab90f50e4ab778dd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5c0a272247800d56f3bcb46c3d672c90d01dd58ad38fb1411755fe5d105cb62
MD5 a615668612616fc049d973941edb6351
BLAKE2b-256 c94e10f234f3a7878220614def9178ce8b27ccf94701afc5919f42d347559164

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4b2fd7b9cd1b5543e6acfdc7a10099a1a233ba949d3d782f558aadc8f8fbd81a
MD5 2ff525c0d82d058a264685621d8330ba
BLAKE2b-256 bc6b5ff71288f92d18318d1909ecc525dae061aff7942c8ca3eac265f0fc2696

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d9516fb60369a3da2b9918cfb63ff3c714bffad5d22f19383d24282b9339b5f3
MD5 c74af9a897b2d731e2f30b0cc6d80b92
BLAKE2b-256 43f5da2a4b13ab34265c8c7611d4110ea642c1081d448140df5de0bc7a3490c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.109.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c53640d0304881af6016100547a9bf3a8c92c2aa356502b730900b8b05730e38
MD5 5b36da0d1f61a4c5f384119efb23838f
BLAKE2b-256 267f7fcafe91d7b9fd10b2374b63c8e5a334487cf4235463f73ac7b1ebce44ee

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