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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.9-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.113.9-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.113.9-cp313-cp313-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.113.9-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.9-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.113.9-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.113.9-cp312-cp312-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.113.9-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.9-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.113.9-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.113.9-cp311-cp311-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.113.9-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.9-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.113.9-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.9-cp310-cp310-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.113.9.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.113.9.tar.gz
Algorithm Hash digest
SHA256 6134d6d31f96f0bd4eb802441ee0670603d100a67a9907a05196eab4945db135
MD5 bf3ecbd56b6c17649990e21ba85abe00
BLAKE2b-256 33006e4abfe88a55540d6b7a203535020704d5603303fefce6f7fa378a4e180a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.9-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 de801f6b6d983924182923d8c5b62c5158aa24056b5832fdc55d1b137f953a5d
MD5 4bad108ba05ab9b47dae10f77989e1e1
BLAKE2b-256 37e38bc77dcac20e827b4cfdb676124f62617f9b7ebc9db70f71526e5daa43cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 230fd17bb926d9faf2aea88a8d1b007c588d2ace9391ee9fd2f01154f9471637
MD5 9eeb29a8b747f42fecee22bdf3865044
BLAKE2b-256 027c49400dffb6a1c5525202e489941cec85eabd2447bef725c7e5ecf2d2c766

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 18c052105d8755885c8f841ccacd23881af926bc596793e1d0705f857d93e0ef
MD5 43a017e9993b1a9b7274be3b14d2b5a3
BLAKE2b-256 c6c566f5d58ff2293bb493e3a0a61efeb424b59fd84ac10705615b90893110f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0af715dc5fcc800ddeb9204f0633daad5e94ed1c86477688910a8d0ff6bd346
MD5 bc13d6e6b4483f1e23b93ff437866dc0
BLAKE2b-256 93aefb326b6955fe995e6905e8030190a7a6bc8e69d9d54647cccf3fd2c1b6f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ea7f6640d6ec2c58a946f1652053fccbcd2097c18b39e8913c63059563b95f0d
MD5 fb497ea641d6a4256ae4d1534542318c
BLAKE2b-256 07a9e159ad8c25c8ce3c465ec45d23528e9cebffe1782e8862a5d63d04c669fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.9-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dbb715ae11ba92b707698435e33e60508843f1a2090f4c72ab4a8c78e9b29983
MD5 b47845aab4d994a671ee0e86f7b1438d
BLAKE2b-256 c536b02fc3fd669b1bdf7be3fa8673715084c98de772a976e5e14dc708ebe62d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 efbc0b2c22c786ca3155909d55bc16ae55728bd19f682eaccf79c3e64d87af0b
MD5 443c1312d4dd2af62afd44071ac94e71
BLAKE2b-256 44f675c129989add857031f5f3895948e5d26a789b20316a59909eba15533164

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d64883573392fae3561c56127c203ba0a1ca54eda63a40ccf1774f19b82cf2ee
MD5 b9dc1b74ccd6f4db16f2456222fd5f13
BLAKE2b-256 bdace46f3d6e5464d3fa81f81418402eb662a2bb65aeb6e3ea1ce7b0bdfd2636

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fbabebb6a47b5a87fb4f1279ee26c5d62c37fd3459c11aad8ebf12dff76b4c27
MD5 7285433de046c7e436c881473414a4f6
BLAKE2b-256 88a656d5c1ec626a5743076a6eaeb31a98a1739a399e3ffb658408f4341149bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5a815a800a3443f1a20e1c3c96210e99d4ce2edfc0ff60f44e40e62dd29d3eab
MD5 e8926da911b3a3ba74ce40a1a17b2010
BLAKE2b-256 270320d64b3cd719c8a57330e1e7881b73e8319ab45d981546f1b0928820eddb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.9-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ecc4305744d60cf105bc0090a10b3e55af084c7756960ad20109a7d1283aa3cc
MD5 33881c6021a95bedd8f411d3af330cd7
BLAKE2b-256 25fdafb97c7df9614a50409cfc518da4d887a74a7f14565d34188820bf8b64da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c050da1d93feb60ca3db6daa53b6842878d2984684ae8b0371b49e312cf91c27
MD5 038d63bf9a5d73f23ddf73031029937b
BLAKE2b-256 b8cc4e3c97b5262c5af5f287d3be956fc164a25d220b4f73f891cb72eb3a0208

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8aad94749ea04ce38fc55660b14261a9bba531f6808ef14dca9002257dc468b3
MD5 c913f62baff145ea4cc9d2ec31f6b086
BLAKE2b-256 3d84d1779ec0bd153275fe0195c0a700e8159316930cbe7fca5f1fbdc854b175

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9ab2074f25dbc1d3cd1e5a3722ca6c7fb9fd9f1dd634dcb0a1d47544400fea9
MD5 d18f7c18c3e7c61bf1c59c2056d5276f
BLAKE2b-256 e950eed2e3efe25aec6e66703fcdc71c80c1930aa2545e728d6c866562e366cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 eab8746e4ed839c9e34e78fb00ab43bf4180a7c2f96181613ef97e73875357d3
MD5 8f9f6765f42f3d93464fb92ad7338b66
BLAKE2b-256 3d488351b7e6e549e2934ea16fc84b85b3406e8a15fb62d15a4342dbc1a1bd48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 11d0998cc26e8eaf70d6b269841adb5d7045fcc531b9527691c66d796f3906a4
MD5 99798eda20008e856bab0ecbf63958e3
BLAKE2b-256 491012495633e67babc729d2a1f841926db47dd8700dc9d6463adbe62dbd24d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4467120b42d6a44f2d8ee4ca92e5285c73ff95d62d14b22d2f85217ead8f45cc
MD5 acafb09a5a628b874a3c2802957c8055
BLAKE2b-256 93ea632402339bb87609e018300d71fefda2a48eb2349a7226af1fdb129ea826

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3740ad5e2166084b2a81012720c17d8d284293af94b2223ad27cfde5729fe1f9
MD5 dfc7f3609c7da2d6fbf88544766c33d5
BLAKE2b-256 9e31bc1b0ea3322345fa532d000c231689edcf1290083534cd4c256d5c0fc35c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f08e56d3c61ada50c779ff8a94d50b74d3bfaace76f4c3161edf82fe720ade77
MD5 9c71bc9fa51585956b86261ef81078d0
BLAKE2b-256 74110aaf595a2a95ae49e23eb849696cab2f60763eebc999e116d7d31e852f11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.9-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 70268466be02ebfa5920ddf99be22c6fe32b96c1296f892d88d58414754547ac
MD5 e6573037fe301bf74d2da72fdb1e9598
BLAKE2b-256 047fe3a3e337f51615108c2bb962ff6a34ab8e83682ebc22a4f1e24782205591

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