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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.6.post1-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.6.post1-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.6.post1-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.6.post1-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.6.post1-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.6.post1-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.6.post1-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.6.post1-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.6.post1-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.113.6.post1.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.6.post1.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.6.post1.tar.gz
Algorithm Hash digest
SHA256 ebe038e8ff5157d4916b2081e4ca9bd7bb050f4218dc34087aea7ea9865d54df
MD5 4ae485e8cbadcb057ca9f2403ef4eee0
BLAKE2b-256 315de871dcc537e7b579914ac89300696779b9a70957ed0f18be2a326ca392c1

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7422fa91fbbe2ed3accaa735fa80a57235b8cb901e8c7985e7d9c0fa40700cb7
MD5 27da94af4117f5c20c24e3c8121b2c2c
BLAKE2b-256 a8c4fedf5d53e3b18af99211bee5e782141d2afbf107bbba91aa0b6ebfcb3f51

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b50bb04afd9b8e685eac5bd790beb8b62341a766ee13419f8b22e2d6a668a9d8
MD5 a046ba0ba118513940290dbc918bbbe7
BLAKE2b-256 4929d0b952b2cfef8d56a043ef90fb12fdd4c4bea008ae3e57863e5c26a705e5

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c779ac8ece18fd4dbb3f4631606ab9f65c751146e63ebc0dcfddb0ebbed57ca6
MD5 9b7691b6922b919f8225714bde1d48f1
BLAKE2b-256 bdb7adaae20b0056def127a1f0ee71e61b71e968dbbbc76f0840c519e8370d56

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb4cae3e5c09e5e477e76abdc62b8dd2332c3ecc8d5e49e4c6b7ec7c2c835bb1
MD5 8193656e8026b2b281cb9ef5d251ee8f
BLAKE2b-256 14fb34bede0e23b0c8df9175e5b2174dc11b4bb22b53d29463b1f0d6fe84f4b8

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 350e7d05a434ade2b21d352d5e81926fa92705b4bfd0e257e8102e05d00a8186
MD5 61595a0ef2dc00e81b2bbd3b263baa2a
BLAKE2b-256 3b6f193793add2b2d80ba9f14a62fd0e6e6abd80b751961607fb00b6ff2377e8

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fd7e62448acc6eb38d42bcd0899be16a0adf76a5b210d33a9bf94e6e861f6c3e
MD5 703fbb5a554ce3f384d743f11f5afaf6
BLAKE2b-256 0eb2e4643fb8b4c2a4aa5a4a882426df550479a925fb998ae102128656ed8557

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 acaa92a94b0e6df3fc9e7aa1122eec87280b00cc5d67ea316dc4609a3de78c4c
MD5 248c21ae0c9278300f6d2e92397adccd
BLAKE2b-256 9f16e327171245274abd72295287ecb1f70b835212e7dee01d4b6de2bda68a02

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dbc2386ded0671a8253ad68b5d21830fa1c30952883ba956c81654ee135bf034
MD5 b659f2e4d2b468ba5f2b2eb47316e5e1
BLAKE2b-256 eb984ab4f405ac8bb8dff62732da4485e92849608e609cd93e2bddecf9bdd576

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 122b7ad1e5de9eee963528149702d8874bccc855cfb7d733a9af56fb1f6a8986
MD5 8cd5c2b8be6d6ff0c5240f8e4948a9d7
BLAKE2b-256 686e9879fbb58c09ea9765588958cfb32a6c64c44999a91b32b1996badb02e33

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ae32e225494c83a2df1bd57f191776ae50018d752ca32ee6b67cfe1846b31599
MD5 0583b64cfff3e4bd23eab0dc122b055d
BLAKE2b-256 5bbe991508562db9d5d1d1cda1e2466fc3d9d7dbb1bf4a0e61747408f2688608

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ffacf4498c8ba7720f6aeb96b857d06d4814f226989a71a631cb9373a6909b75
MD5 1c7a1477afd49cb7674940f8478dcde2
BLAKE2b-256 ba0acd257c8a634fdeb6182b5c9234222603b6f878247154fd3918d50cdcda9e

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4df2b980697b168eec9efb12d135f2cd79107da166077b886eda66a5c3763585
MD5 3bc20d4dea10c2bbdbd730ab4d6ec6b7
BLAKE2b-256 08b58e57bad388e260264f2b299bd9e0db4d58effe1c381396de809511b68a71

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e435d21557949de3805e4ad65d65a076e981de7f73b3724e764587f88b6e12ba
MD5 6e9a743f26d3067dc0603830ca922635
BLAKE2b-256 af47c82d71ee583d99289c9277761e8584a32544d4b59dba27275b4297325d91

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 21bacb1685dbc167afc809612cc02a89e5caf6901f89e2e8086553b4b9483ad2
MD5 00aafb28676a2f1a1ee76ecd2015f4d0
BLAKE2b-256 05392fde8eabf5f06b633f65fdc017350ef3dbff97adc7625158f604b395436d

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3f886a6ae0554cbf77fca260512aa8d14328a15ffecb4c8733b0459759bd29b7
MD5 d69fc631e55e03eba98e3001f00924b4
BLAKE2b-256 21a3b7e266d1724e63714c227140c976d58e16f808e2db944a4a7089ac4c779b

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e7ceb446c945337c4e614068ed7ccc2fa5fd23e0ff9f12df2f912e05be3d9d09
MD5 df3595e58946e3e0ed7789e2aa4a4feb
BLAKE2b-256 e1fcd0d4ca92572c16503309f0c5141fcf8c6c3ab5d243e5dbf648eb3ec2f698

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03b2ec02722a0e54920a34a87efdea7508327b566f5e9073f090810f89accfe9
MD5 a5f1b8a3c691f5797de6ec64ea65066c
BLAKE2b-256 491cc6d5160ca421751b26eb71be30ecf1de9969183435a13a2b43ae9aedb535

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3e395e56f0fdd3968ac937747e523173cdbe808d574eb74f585466eda707128b
MD5 1d3ef97b78a94626754973a764f97cf0
BLAKE2b-256 2b3331eac51aeb352f7303120c73cdec3a7e1d1e917f67dff9abf03cbfefb4a3

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dca272035debca3fbe40323cc31222c13184c46a8e5ba8f75f629207e0ff75ff
MD5 b33b59db8836994eb884ac8bc462aabc
BLAKE2b-256 dc8ad1e2a31ce0880b17db1f26736f8ad80124cec7c7f7b059dc15280b31414b

See more details on using hashes here.

File details

Details for the file chalkpy-2.113.6.post1-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for chalkpy-2.113.6.post1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5ee832abfb08e8238e511da8bebece211c409972b48bc0c34d381d61e9e09810
MD5 507c90f6b659cd8b1cfd8568265cd6b3
BLAKE2b-256 133e2544f809f601afcd96d65e0c8f95098b1d004c2f72b2349adc9eb039c75c

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