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.17.tar.gz (1.7 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.17-cp313-cp313-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.123.17-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.17-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.123.17-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.17-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.123.17-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.17-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.123.17-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.17-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.17-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.17.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.17.tar.gz
  • Upload date:
  • Size: 1.7 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.17.tar.gz
Algorithm Hash digest
SHA256 de14973c30193b16d3e21286a096111e47d02b15b77bafec108641851d7f68a5
MD5 166481350d0a0697bf291d707c88800d
BLAKE2b-256 5a13bf00a37db461b1c1702e6bed4471549bab56a5e4a0d6a9246e8504ad2b6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.17-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.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 01c3ad738ce36650ed89cb3a1e369bf2b943a6811f36a77bcf9cf51cb5235d4f
MD5 692abdd199bb9bb5718a52edd981fe63
BLAKE2b-256 403021846b6046ce438f78df8d42bcc8908b7a74a61e2f085fb810b085f88771

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7030b1135c061bf578f0a0c856d2e52e4033c9a71ae73ca13cb16fb4614a90f6
MD5 683b8d588361a37676b1b2e584aedda9
BLAKE2b-256 c6ad6990435ccac2eeac4119299b0cdc71144c21aa8ba9fea4d1ab6616dcefc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3e0d482e09738266084db105447acc95c4eb4803a4a69bc7162ca64f8cd1b590
MD5 7ba367cbdb584a74ca2f2ba7efae2715
BLAKE2b-256 5fa38a28a5dccf1dd303cbd059d9cc2312e694f355b9cd012028ef82276619cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ba08135fbc0b3ce5ef79040d71a4de7170e8248daa451ee373c6945724dd179
MD5 b2a6ed34d70f0d828d045f1a3e7b1fb8
BLAKE2b-256 955067abb104d1a4ed11daea56c5e878ab024c194cc10dcb0214205eebfedd23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c1bda40533412a4d76952de7193b34d832dc38a58273ab14380599effc43b766
MD5 3fdb5af5ca88ef9790f8d12955849a1b
BLAKE2b-256 5c2e19909a1ce6fa4f2a5fe20d1eeaab40e4082f9d3e0ab2b5f685c88b71fbbb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.17-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.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0d3a8aded32aa11202e0c46f113673d57539d0b507ff8ea4aacad43884ad6007
MD5 c6e9e937eb2f29130411e1e3f1005c23
BLAKE2b-256 1518c9633fafa0fa1fd39bbaef30240ae9d1221e6457c840e1c8e3a918d9651d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b039024f2d52a723872eee075288d6f2664d545517bea4acc8412b3c8f7ad1ee
MD5 6c595e11701c5c432a32923288c2eab9
BLAKE2b-256 9d5c09b1e278622a0f59ccce96fc8c2d8f45a69a422703a9fff9a83322ce0775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f63546eacd82b5ab21064743a4be30f102e3ffe3fcd28642fc7adcae4654678c
MD5 1581968e0423504367befc1ab39b7c9d
BLAKE2b-256 f22d18eeadbea1b2ae4810cf75942a40ec6e664d78941243e05c0e7e7e31135a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e9d85bd8274e78561e1d1a72a30b2157936945120b6f77abf0d8196e006b269
MD5 2b5ed477f1e29699c33376b3fc54b712
BLAKE2b-256 0bdf4e135e7125ec2da1c49878fcbfb0a14411ca9f65d846eb16562342bfb040

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9a218b771b1fea94463e050ab1d68e420e172667047b2d857e9476f1ae914550
MD5 28c7ae75d95a23aafc544ac752699c7e
BLAKE2b-256 0da38ae892d8d9faa88efdcd4b2c4bd42f5b0c3dfc1cf11585620f4b6182a060

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.17-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.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b445629b42a9c147e8f37199864f749fce56556ae3fd7f627ceaadcd7f13262e
MD5 4320ea006580847fa88d461d06f9bf67
BLAKE2b-256 01b2a10b1b7d371a8f66f74749381481aa270dee1c37ed871e3ab678cc2eeee5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 877e04547fb7278ea76dec8cdcf12b667ce6b0e650531f2e928c97927aac13c5
MD5 4dca04e07188a07749c4d8c0a50b1568
BLAKE2b-256 01def7d6b110755c4f7893732577b598c1fbe4a3ab7625587add1e44b0e4d7ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f62f197e98160eef0c4ef5dd01dc91b61ca0cd8b5f4470d26bfa80afd8997ba2
MD5 14f1ea99fb1c93cc242b2518561fc1c8
BLAKE2b-256 da53f2d1ee90075c517be89c7b0e586f9e70f54791c380e8883c841ee07ee01b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44c6045388ef258fd3bff54f733f80c07b28bf3a4eb44ace6aea4a2803c5dad1
MD5 eb5df41bcb8c8f56b4024656de7ba3b7
BLAKE2b-256 c3d10155f1ab25fd2ad54a85512f0dd411ee037bee8a77e7822364450b4c8821

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bc2c1cb43b5ddd3e860d720b364a3427e98bfa214bd79b7e9c601a38822c636a
MD5 e06377d7029cae088d4bff3ee38644c9
BLAKE2b-256 2b53b15bbd69a6cc067e417083a1eafd34a4c20db8951f58ac295d1494436481

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.17-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.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 40090bb9da27db337a2592d955c6f23db873754465dc60fa6e1eef2049a48712
MD5 09bd16da69ae648b51e241374d42e40f
BLAKE2b-256 3d58827179ad6a5bbf2688ce3d707a6519b1cd5e9935e4a01d7a0863beb9663a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c3ee97e6d75a45e99b3ab5cf36cf7a8b9649dbe74fda9415f46bd273493c476
MD5 06040ff536f25290152c032778365b3c
BLAKE2b-256 63d6f93585eab80bfb8a0abc1568c4628ac7edde5031f5bffc6cb71622cff846

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d5d8f6ef83d5ea8a243e8770211d4edfc5a8cf5383f69502956e09227fa2e766
MD5 30b5afc1a3346d98a17478d7d2bc1b8a
BLAKE2b-256 27a584a704e68493025bd7d0e7f31550561f499872a16366ea0c4631c3d03221

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2ff3db04fe9059e77c20edc72e805e9bb2c4b0c59f1378821e9b69539ab9b9e
MD5 e51807c47cb11cbe5f255b97d7182a36
BLAKE2b-256 e5cd3877fd9f7670cec5c2d61c23f26d7965f548a02e8a1cd2b845929676018b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.17-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1e530f947c5aa725176b95a8f10129d8149897e0fbdcf0f24de6260281f907c1
MD5 14a10290eb44aff247ad6de83f1efac7
BLAKE2b-256 052ccef7954ed6f4aceba9ff21ceb20b73390055d29575fe4c3be4b7f533e8e4

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