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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.118.9-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.118.9.tar.gz.

File metadata

  • Download URL: chalkpy-2.118.9.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.118.9.tar.gz
Algorithm Hash digest
SHA256 95515edb68a1b0406d490e2e02800c4f4a347c35851df1a0fb0ae908a1a2cf71
MD5 33d9fc91f971beae4006a60023ca2312
BLAKE2b-256 105b8ce5fed2c4888314366c277f08d75d65b97a48e6d78ebc1bc10ee71a7131

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.9-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.118.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 489b293677c730f7c52513ef5eb179f8b36f04cdfacc4e3893b18c50f0345848
MD5 1dc573f4c94e1e5eee16563eb179f29d
BLAKE2b-256 56fe1faa4490ff68138768f93de4e0f21b9bd34b037685e515bb8cd8f904b074

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f52dc9c09d7f6ffec2f2ed97fe19ad6fb6e86acba685270720e1ecb008b1294
MD5 c42a3175f514bbc614f07022d0b1a9c0
BLAKE2b-256 f22b99e432504f37243b854fe4299fa61490cbaa5e3d2a2a0e82ea2439abdf17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0a90b667b8e93b5943600787524f523ce964dc57adc8b44cca81252fed71257d
MD5 dbb7d5a30c4a738d1a177868a15b44cd
BLAKE2b-256 0bd1364faecafa7aed15238fd18e6081481ed2d997078c633f62245e41026393

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f60df7058b755ace8ec3323fc0d7dd8ee5ef0b29799276022c6602da5b57c633
MD5 7dc40c1b013b4c3c0dc6b51a8ffdc79e
BLAKE2b-256 93946c4a4f829ccc30e894aed83212638b017738f4f50fd1b1db472c543190e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 63b60116148341959a767ba4caf61cb7eeacef73ed705dfb053a616d659547fa
MD5 51bf251c4323323b1029f14e43627539
BLAKE2b-256 23b90d85c486058200ade868fbbefef6137cef94267f246d7a12d78f74869bbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.9-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.118.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9d32a6f653bebfd1203d1d54953fa54f17f135f82b182d0a1b2f03692a08ea0d
MD5 2960705d3e265033e1f5b723c9f9cf3e
BLAKE2b-256 a9dfbabd2a83135ef9f9b577a976e1f0bba62934cc9659897f95b6d6226b6ed4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c0dce4cf691bca8c6e944f6e084482c1ea92f2d98ac4d8cc22709bded3c3b76
MD5 f37e1db64fa35e18cab0cf9a55d628d7
BLAKE2b-256 dacd1fed1ebc5150c109193cbe9f08d659348553eefde95e6ef49523b7aa38f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0ac9b0556484be93079b37360a60924d9b22bea444e546e5f0ff2081178c93ad
MD5 eb437d503e5f419ee77725fd8aab2dd5
BLAKE2b-256 fca994873f9f3b8392b6612e90dd883074d686c2f916f872fdd9f0bf795c87b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12c1f79684f935005ceb66c76275e384b4abe0aba9ba742461195a0c74914ea9
MD5 a54c1659139714cfe3561a34ffeec693
BLAKE2b-256 68f69503c443791ddb6c967d4c0ab02d0eea7a4254136381cb4c1fd2266c277a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0ee70f68c6e26ffed521c4d5611557472fc18da223fef25ab924dd272031cf2b
MD5 ab5e05bbaa8b6ad39870e469c76f3852
BLAKE2b-256 5ca5bf2c43c51b5dfeb8c1b01dcd5db7df1740647b7fef5e1ac66252d530bcb5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.9-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.118.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cbb6b83ab9e8e22bc04a35b66ea4c091b6d01eefda3fcf348ce758602e8bfd3e
MD5 7e1e28c4508011c88015723301296d57
BLAKE2b-256 36b47790c0d151c5e90c0b85313918a24c57f563b18cc9c5bef73d34e32b3739

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 674f803ffac862ce3d647f83e3b60973a3ca123eb0101bb6ed9e6b7341f92055
MD5 9460f6ea92fe373c84488a35b6c58869
BLAKE2b-256 a4e96a01062768aa1cf565c9ac6caa8a1f82404bf2f0451de09afad5d240b111

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5ccb4f9e8a7a4c67407d28aa89fcb0b0f54111cf4c6ed96c8ea93a824ec85583
MD5 4dc81f7baae78c3719857340e1d2b175
BLAKE2b-256 c08742c7a53ccaff15c0fc3d39fd7004ccce00402ff1fbd7a5ec2c6dd9bb2cf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d11d0ba433151457c29ca1fb92269574fd8895f02b40ca40a1c180c17c02370c
MD5 272ea0f9ebf4e839457977b84ef3874a
BLAKE2b-256 0be80da24cbddb115c4fe9298025b50d53421a998a150485adba82a653a07779

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5157c901380d0f5a2eaf70237590358d0db9ad7f75fa10d88067787d2100bc8b
MD5 ef5a54b47c36f484d83ff85aade6e609
BLAKE2b-256 55f66ab2e5679cbea84a7875aebc23b795ea1b5fe3b6fffb3d3b0bc8f119ad53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.9-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.118.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 db13fdde4333bef02da86619c41454e91174b65caedff9aa882d1bca63a50a41
MD5 599ee5bc49176bbd7f31c509fbcfbd0f
BLAKE2b-256 ae98d33b8972eef4a44ecf5c40ff36afff9e35cb35d6ee69109cf53d3baecbad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d625806ed7daad55f2d4b046f81aa7bf7e26a2cca2e962f1e59235c07158c4ba
MD5 1ee11def447e7f0cb00becf338c06760
BLAKE2b-256 5602694c87be790ffcc2c45b0ea39ab484fa12cb9e318e353de6d06b6bb560cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fa1ae5d207db60b7a9d69e734dd332103f5d6fa62ecb59b59abe4dc37b7a5a7e
MD5 0eac10bd5675609c7e98f8d71fd07178
BLAKE2b-256 b7355a21fda19cd2a3a80733803570846744350d0408a3b10efcb24bace13a18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 903d35747d48a504d8edf90b5eb6df334feb83ecad6ce310c18b1442866651b5
MD5 782008b46deeea5ab3e3a1f8972c8223
BLAKE2b-256 fe4e8956c619cd105c1b27110ff5434eb5c50af96f32f43ce4b0bcb5bc580f12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.9-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d181ec66455cf76f6f8cc27cba5edc0f938beb37a1934107ca48a10e2f0315eb
MD5 51b49a0ad5175de45616420e8bcfa646
BLAKE2b-256 360883f8c601f082548eef12cc952c0b04fa17cdf283cadbbc6cbfdbb2829199

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