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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.111.0-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.111.0-cp313-cp313-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.111.0-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.111.0-cp312-cp312-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.111.0-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.111.0-cp311-cp311-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.111.0-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.111.0-cp310-cp310-macosx_10_13_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.111.0.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.111.0.tar.gz
Algorithm Hash digest
SHA256 54cc5a064f9d169409b9a3d0a328521ec2b6c29e293f5bd89b48b38a3a8e0cee
MD5 a6c026281b02c2efc112a3329b04b952
BLAKE2b-256 963d43642d15205c84d7038a0725f00d1300c6d0f5544c9c025bbff8812280e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.0-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.111.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c27595ffef914fe8e32351f1277e4b0d2c53648fa5389ee58203599e58455ca0
MD5 ea026c7b0caf18a9a68c75e188372d27
BLAKE2b-256 17c3bd8626784c27afae9b9e15e2e94ebe2348e5db12fa80e52af0fe96e460ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f85f90829b781aef99b126f040f167168d18542a6c5714ea9d119a0ccee9dbf8
MD5 537861bc50e6ff98c1cfb73dc0f18a13
BLAKE2b-256 f93c12b8fcc431aaab79157ff80b4cd2d462e3c625d5f0b98913b2638ab5aa52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6032ecc836a48214e26a620345bf129b01e4d46ec265ba89952fb682a9f0082d
MD5 53c19d51a60c0c61ea9396d4a154c6b6
BLAKE2b-256 b68d63ee10c5824693f94c43e54c7a457e433ba6b430d2bde5c90de69ce40a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e0b757b37e28588834eb7e15d55c9c84ad2cea8a990c0ad67f9fd5e5d6b5835
MD5 a2366742e8e221cf669b0ac2adb97cad
BLAKE2b-256 317f32477580b05b2bb5f15bd81291ff373406c5cacfad33193b3905380f0875

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 11b223ac14a52584d236cdeabdde7712d760e09e9a1f09f8031dda4514572b12
MD5 0920303bc75b61acd19b1c7682dcb9bb
BLAKE2b-256 636242d20546ebb0ba91cc93860206ae2b5eae6eef1caa924c62af067c96dec8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.0-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.111.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 02ef4618b7a9522803f8ec213bf8bbdbfbaf0a2e07392a867a9913f35776109d
MD5 e4ecdd96f3e35a170f6e9bac835d384e
BLAKE2b-256 c707f0d7fed8539fcce2968ac3540d3c98b5906cf805a95f72bafc5993880ad8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 89b900b25faf6b996f4d8859a7bd9802719f2ce8f01dd1491c46e1d959735d1c
MD5 fdb2ef05ee97b108ac4ecff91f33056c
BLAKE2b-256 d9c495096d07b5a010c7903eca499744382b0e39a263fe0ed75ca493a716d0ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f1241ee4d473a0131114e2b678eb97154c272edce648b3ee5cce325b01a9bc29
MD5 5eb8be5e043b7ae8a0d89cc14facc098
BLAKE2b-256 bc385cd316f7d60e54059b54f1062113f9906b64e809651a3a97dda688b4abb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f3b5fa1700bf92e82148658988cecb360334209652e40c2f192667871c6cfdda
MD5 6c795cf31c40a08d1b20e00a2f3eea71
BLAKE2b-256 4eee0aeae68eee7a9deebec78753106d04c0b173c2645324161d6fe630558118

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0b11ff2fa58aace4411313810d33f8144e2b5845527666c8afd78f8c4f20e7eb
MD5 416f657c96cf73c79757bec13b5f9763
BLAKE2b-256 b8700522c3e96c1656d69a55952f084768d2c2385cf38934c3471ed5fbd7e5da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.0-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.111.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 63acc8c1c42f9f091b683f3025a1f1ac20ac004b012c508d45c0a0dd2b463221
MD5 0d64728d45ce2054f6f4664fd902f866
BLAKE2b-256 6eaabfe1f4adda64026bee403dd83ed2d96e410581a34240eb15f2aa796eecc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e42b6b6cc3cdda5bc9ad7468dd6c7a40644f63cdf5f07cffe58b9077335300b7
MD5 197b429fe801dff73c4df1aecdcf4303
BLAKE2b-256 40ba56191db28e79a9e7d8efd2f9010760677349ce455698684a6817836e0cb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 774fc704f49aede53bb7c5c335dc98161a2c99f251e7b784040e7f78075432c0
MD5 ee5b1d79a308c13fe06adf0697e9b782
BLAKE2b-256 f7000d9c1dcfef585789830a5c659586d786f4e3b84844a3c9ec6adf2ca13219

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d9e450a2a33e9d2ba31af37813c4f1b7661cf4e02bf1fdf515ce17e6fb3d56f
MD5 d0a38c6c49a47ba9250cdf042ff8d840
BLAKE2b-256 0c8d8c15bd01ffa60ccb6868b1148b4194666cced80f3e9bce72e2118d646825

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 11eca99e5481896faaa5a387f1ff6994fd49c1ac859d9290d69e4f8097f72d0e
MD5 c2fdbbd9aecca4f22aac14601b8c5414
BLAKE2b-256 e1aadecd25839724d3ae6d19c3ea5a72104e3f8265f590a9baf858aca0d5b401

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.0-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.111.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 71723af6f264c476e059243baa46895cd1842a3a95f2ea5c7a912871fd7b3d00
MD5 4ee1cdbd61ffb48d45882c402436177e
BLAKE2b-256 431b5c0f5bc993d464ae4b22ed8e9b849186b044f898bc14b0317473d1272c36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cadae4daaedafc06415941bf491dfdfc2f8fead32b56f8efc3e37c8774fa762
MD5 0404d030f8c1ff0033174a19fe50b52e
BLAKE2b-256 22006945121f6e19801b5dd37c2538849cc04249eeaccf970cb2ecf1b576d2c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ef418532f3f729e0feb8e7327db2746b10cd9774065f8545d1d36fc13d9f1643
MD5 824657d5c63488d407f90a7629137208
BLAKE2b-256 e3dc8b74124f56d73867ca2e76806c5fd5faf259a2a12dd6ad09035144bc3766

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 359cf388b2c94784e965b1a5c55bfd04f63283c295cb34c1154c651c1d8142e5
MD5 5cfdddc4f9a49d493e3d032ba521933f
BLAKE2b-256 9ceed427f5fba3dfc58ffe796ccef66d1e820470a9f652e1497402ec9b855ef7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 89bce15a4aaf1bef0bf02658db4118067784a70f5f3772d8b95663e55c6f80e7
MD5 08efaca99d3d4e8008bf9dce140dd5a1
BLAKE2b-256 751338cfdea5d1697959c6ec5652754481f0e2abcda5366e32703c6793167ccb

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