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.115.1.tar.gz (1.4 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.115.1-cp313-cp313-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.115.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.115.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.115.1-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.115.1-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.115.1-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.115.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.115.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.115.1-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.115.1-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.115.1-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.115.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.115.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.115.1-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.115.1-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.115.1-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.115.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.115.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.115.1-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.115.1-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.115.1.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for chalkpy-2.115.1.tar.gz
Algorithm Hash digest
SHA256 59321fe512413ac6d650fd3ab625fa46b6785bea3dcee019c8fe2fef45fc5c39
MD5 3044ac2d868cf824f0d4064be35c449d
BLAKE2b-256 1016585c63ac28d1eb434555b0a46d338a145e040ab7dcd6ffbfba94739403e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ddcb5749e96b0efce4461e891e7ad94d57b429a9dcf7bd55e657b69c5542344c
MD5 bca5d807cd66119f7d2cd92bc751f086
BLAKE2b-256 8a5805c922975d78d47683ba06f2b530378456484bc0157ad450aa16770c825a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e5cfa2407d94af0d6fade5f23c751bd66723d5afed3a8fb42d65c5d15eb3131
MD5 b1e42e7c2f73f50d961ac0949232feb2
BLAKE2b-256 e1306a1d7268c8fceb24bf849870a9a76c62dba5677e2d9905c0252bc57e9719

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e7658dae04c1e1d2780791efe10bf3e5facc0122b1916ef3fc55a5b9f6a52d20
MD5 b4ddffbe05281a79315956445e734212
BLAKE2b-256 e68c1cc61b31466e5e0677d3cfc3b000bcef0e6a18ec0ab3ea6a653130d1dc23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ae885ff7353479567c9492ae1c0cb6402f0c82cae3e5608ef8fac0fb3bafdb38
MD5 280ab577829ce94019905c0fb801a9c6
BLAKE2b-256 4c5c5cdd064e77048a6baa378e314c254a2ff6258cc40aa9aa9a0920f64ed9a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6bf99d1e5cacd48a93199cb50f25d6af692f5cbcb03f765f0fe859aba40b97f2
MD5 6b7d1a0a87deb59ae1f75889b9b02e8f
BLAKE2b-256 dbea7e7b83f4aea121c842d7de4e498a83777641b0a393e5d43160b5bc9bca15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 26c20616b60b6960b6de2014bba638d1a51e621e37003b00f22db16242dc81e3
MD5 6d21b8fbe4d1064be55d1192c68ad75f
BLAKE2b-256 d834989b5ca3b539f9e61dad7803db59e3d64ff88799db2c0788cdec9eba3a40

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc993a9203e3a12f77a3c65d23e4e0f9e14523584c5175c400796992296d6e9d
MD5 16cffba10d171342e7af02e486ca7ce0
BLAKE2b-256 86b152bf0bde6671a63cc678eb420fc5f2f492397cbc5fb2debf09d9fd1ef299

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c9be2ce9e13636e008dad925962ab50dd1029b2131dbb5e49d3c3e0699a96255
MD5 f7064be0247b42e9611f5edb582c6338
BLAKE2b-256 959a7b380dc64c6a6f5fb98adbcd61284c52647a5bdf7ba8025433974c7c20a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bf6a13f2923990e521e5101c7fc454f998bf46e1b56a936a865ccd7b3d51aaf4
MD5 17766bfe6e50f80885939d116a36a53f
BLAKE2b-256 677099b4d171ae64e4268bf435ba1f5a4e39f911864922b1fff84dae064ec481

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 abb0a73249bf34959293f179fcba844f057406bead4764f42b930f2fc07a340c
MD5 ecbc4769e7223748ca9f3663662be03c
BLAKE2b-256 26d878cff759fb910f51b672869630dd61b63d2ef53b4d48d14242c7ada57db8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 aaeeab0897b600e16c4432f801aa81c19f9f3abc9635e9209e94ec1346c50498
MD5 b9245889c0fb570c7bed09aa629ba00b
BLAKE2b-256 ac28a68ce9a7c1d328b1f4237d2793e9222055db78c9d2d137093a618c1644be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8dd782d41cfa6e2abd83ec0bbee1a2afb16b3117ac4dddb0d43116eebb0f627b
MD5 2ea4fe72b18eadafde4a174add011ba6
BLAKE2b-256 8ed08df6309dd4532d69360d2051a50f29b6481f2efc22d641a6ddf0b8365cf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 47edffd311fef479d2fa21a93f529d274bcba951d29650725b554b08d3ab201b
MD5 f27b1d56dd65507dd94e3a2d26414916
BLAKE2b-256 ccd5ac7534acc5f3e11de279965473a43ac03d65398ee3312a1786d9cb672ad3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9141767d8d5423ee344f5c2f6a74cdeb20cdf56b82a6108158f2da317bdf8067
MD5 c214401a8ab06b5bfde4d3e3a733a992
BLAKE2b-256 4e5504303f58832a7ab254baa6281cf0d11f658b1112b8a8c1158454f78d22bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4ce1e6b0cb510d3a9982bb0c01a413ea019403a01a85d501c780e43270415d34
MD5 b394a147e1c60ccaeb728dc6c5ec13aa
BLAKE2b-256 987c996572716ada01ce880efca981ecd3beb4fab8edf34cc61cd00055705832

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c031193b9ddd44c6a45706240ce8f6b95219ffbbaae0db560bf75fd768deb535
MD5 e206096ff4d8a3350ee33564ebc5a6fd
BLAKE2b-256 0797c881b3ae9bf329b57d3384c94a36b50359309fc3f81cf238888c62df9bf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a59401fbc9597fb9976a326146ae62affd5c63fda073e6cd95f461c46fd813a
MD5 37b2439bb2e5c05b4430c4fa1122497b
BLAKE2b-256 b579d283c08294f1b84fb66e074a363c17c823b86afed1cf40f899e80ea3c969

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a16ac8708682e6dd3240e7278dc3b80b45d407ca8cba80218f3c18bc1b8061ce
MD5 01d9b2b887996fc4cdd6a638bd25ad1c
BLAKE2b-256 0243cfc6a7e99df88a165df1f08b91fc1affe84ff7cae8f8f04f4779a32660e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd180ddcc54667d1d52a6c43898fc268bfba1a7d337e1a79cd495ccf20ae7caa
MD5 09768363aa746d6598ed422accd7d978
BLAKE2b-256 2a64bbdd48b4a95f841887513917a1f358726d3404a8a6f92ede3879169d1f0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f57539cc4ae2c72751ca100fe493fbdd01e0ee4fe4a812057fd6ee7098de18a5
MD5 6f182888bd16e1a3f41f1979a750603a
BLAKE2b-256 03e83b31a6da66189e1d1c286d20fde0b1626d9ecfcb46779f8a4862490d8ba2

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