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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.4-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.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.4-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.4-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.4-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.4-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.4-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.4-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.4-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.4.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.4.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.4.tar.gz
Algorithm Hash digest
SHA256 1e311e3584fa50bb391dae56e80e9b12fac04b96cd8ae987d879dc1f0ea537e8
MD5 4259c3335d8a0ff5b55227fe22080896
BLAKE2b-256 95363c77e7be22e2b0de94d2c989e302938d2105f85adeb9dbb7b825ff378646

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cd10c6ed10553475fdf4f5783bb4c7d9f91d80e08fa46004897d1f677b9b1731
MD5 420a3d2757626e859fc6942d396be447
BLAKE2b-256 5ec8f88f558bc827746d370b209f16f124980d5bd89dee5a20e03c1fbbbbb1c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96413bb78cbcb5a7a183d676a25e6b59507506931de6f435b1d7f77e1f023d7f
MD5 2f6089d27177a12ef63c9e61ce1a187c
BLAKE2b-256 4f42de632eeb9bc3459b0acfb9e4ad94480bd25c5916fe8c73bc55cbe1416dce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6433e43633e34803fe20a072d1411fd02fb5ba088c241137ee0459f05309ce3d
MD5 3361c1930598a876c68ab5efeb63c47c
BLAKE2b-256 0b99380aa122a258251bc2fab29a8a4316a0ffb0a33ce7e2a0e85a9d9aa1199c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bad3ee095f0a5c52b9afdcb9731b03ba9abd278575472a0ca918ef7361075d06
MD5 2b42367a3c237ec9c5c7b70e398642f0
BLAKE2b-256 1f1355728c407366148a5af1afd95510a711d1ca22edb5680e8a2665ed54e4b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 52e3f61d0387bf5cb8689244f82b006946e816d02981a028f32c2c98445f512b
MD5 7af4e9529be774776052128b9319a5bd
BLAKE2b-256 ff9ab0135146fc173e0e6ccebb97c737e2b3802de4f34cc7a301b6e8eaf7e25c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 82cbe7d494df8cb7d3643e6a1f391873b834c67b8ba827cd6953cb0f388c6ec8
MD5 e9ec329eefff1a62e271b0b0e9a6e922
BLAKE2b-256 9efd6507f5a000c376c4793c92ce916245df8d3983598a99318dcc958a91fa28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8ffd7bb3a1bdd4ee7c691d73e4d7a1859a877ea5336e5202d79edc651a1e963e
MD5 851d933b7a3624ea56286eb65c7b6c13
BLAKE2b-256 6ed51e4dd482d1a597ff6cc0d23c43566fb622d7b113b1ce4f19aea4f1e9f016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4c199a071be0694da5f41d30a42e51ff85db09d8a5ecdf52db58b8b09a72da75
MD5 750392259d301640689d114c77fd1206
BLAKE2b-256 944e1c338211e5a824ea2331bb07e8bcb3e3775c74398b491613ddd67ca9b22c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4d271b13bb688fe7129dfe35bb4230e9bcebb74c85b90264c03f6f74a62edf97
MD5 49b06888dee3e8ae3a926c1b39f9c28b
BLAKE2b-256 05f1b93fb865028d1b97e39a65eb45537401c4af912f360559c79dfdb80bba56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a90387c23e2faaf00ab86135ea2b98041f24b324c1e00cf9b56d15c3e0c44e45
MD5 6bf840644d38b88e8f31d8ea0a1c8c05
BLAKE2b-256 62a49fb9ec3ae61044892308ae217746290401834137d96e5f21ef46dad87572

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.4-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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d04c2c41957e9d61f49866a27817536f957a40d4a1bc4d7fc71f03b3eed29f55
MD5 4ee9559fc5a378f3971978020c60fcc1
BLAKE2b-256 7c7168e01961fa2e784c24cd361c0875a50fe1e9925432cc6634b299f7e6e4c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d9bd402e81a29c3f5b2dbb376080b161e78b93e9a735b1a0fbfff07d0d8bca24
MD5 11e3b598aa8c01b41048b765c63ca0dd
BLAKE2b-256 830765b108f57bb371cf932958939b94a97687d24d5fbff6617fc90b9f3c1799

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 dc5899300f0eda6f6f117f8f9dca6bf2b09c733c1031f914e8b8574be2c9b495
MD5 60c626e70522bbef9853e1a94aa836f7
BLAKE2b-256 1fd822552eaf53f544b63401790da8c2c60e3b27aa6a8c4f20e6ae9eadd11816

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 22e9bfe7d1a8e1ac4a20fde1ea8ab872bca6b17da1c05ee10c6ff1d4882739b9
MD5 e9eb1c3fc26f561c491d2fc7c7643026
BLAKE2b-256 8bd33371cae3247f12d04d5d0f338ad8369f08a4c4baf89065a0e57487f071c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 25f1e56f6c125360eca13364ecd6931e1ac849d572273fb38d4d9d371b0fef78
MD5 901df9329bf94f3d139d49abc0267c74
BLAKE2b-256 969c90f26fe075f2eeec7ddf5eb1f8a9e470d9f170d98fd2810acdf66088a7ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.4-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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f3c63dfbafe4669b9af3a08d836d7a6f4afed6b3867695fd8c8dd270972d813a
MD5 540bcbafa07de5bd9d5ddc17e2a4a576
BLAKE2b-256 68bf03f164ef46447310a55622d618c4e61efe27b83d6fdfeaf93f805c2b9fad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e2ba620bebcd3bf21ff40ec33eed35597eaa7f2e0fc5f7c211d9737c3be6a74c
MD5 bb3a5755737be5ea45f2b656a0682035
BLAKE2b-256 f1e7f94ad611de4af225ae1d70edd5fbe873a904f64a18f73d8154c0ecbac125

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6a6e9f029270f41a89e1fc72dcfe2894cc41bdd3cad52988830906122dae9f71
MD5 8bf64aa26e7543782f241a5014d2ecdf
BLAKE2b-256 edef8f479effc867cd860e6aac2aac80cf9143e4a72906974a74b5f31f5efe02

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55e3a4ade3aac6958dd06476d6d590c87855488eae941509372341362c812a9a
MD5 0c2af7262ab7007dba523c958cc80f39
BLAKE2b-256 9de41bc09d46fb5d6c32bef29035cb2e41f348091744d2c9127c3780f4e91558

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a3ca5047a7067be0ec8f0a4069b49202327f00d1760f4f7e17eb9ecada55aa8d
MD5 1a52677a6f5372013e40a882b708ad21
BLAKE2b-256 5f3a0a97702fae09f92d48be98e5420d70fdc376e53e39cd9c044069201f4b94

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