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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.16-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.16.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.16.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.16.tar.gz
Algorithm Hash digest
SHA256 29b972b1362e59963c3517be66b8859b128a851412202268ae629cb380149781
MD5 7052a6f849a9b98a5c1588cbaca5b0ee
BLAKE2b-256 6965995e8621d54f01eaf5faee4213e875666d5039ad6131325b38fa80e4cf7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.16-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.16-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 23bc026b36a2ccd4fce87e5787f60d93a5fb2ee1c5088850f958758e4fad957b
MD5 c47a0290c27d3daee58fe8538f63dbf9
BLAKE2b-256 cb901f9f0bf3786a8f0c4b4f8838d2e9eb5aba3ab6cc62d01caf5dece6028b7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1ccccab06af846582b20c7fff5c6aaa2f498fc89e56678613a154b4bc88e18b8
MD5 fff2a5954df9e41ae891aa91e4430856
BLAKE2b-256 d0148d50cbe667229ad5db8825503a3d6cb7e95a3f26ab281e80b4b7ecf663ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2cc31d37616dc03be63af3289f685126ede9c22f9d45986e243539386a0929ea
MD5 020ce7935b2fec5c0e3cd603d67675b3
BLAKE2b-256 6e5c17aa4a75c43cd6fbd71fbea4eaa1624f3016a3963bddae8f0864631950c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce1c94f6dc89fa8d41cdf9b42d705d7acf317b7e6c0540734a67a5150c9e34e6
MD5 b546a7177bcd8f521eb22ea9ca1a99d2
BLAKE2b-256 4688a23fd499c807dbeef877c9de5dcbbc2f2959356c071860641e8a15a36677

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fd9ccf3d1531e7188308f9b3ff9097a288410235d142257671d616341c222087
MD5 4a3a6701aa575a0d7a4221311aee7c16
BLAKE2b-256 1a5d3cf16b1bbc269a9ead9990c4b0690b26505cb2e18623203ffb028387661d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.16-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.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b0ed8ca09c312f42798dadaf1faebdf023e4d1babff28e9aa8a97244fdcf59d0
MD5 dafc0590811b10e329e1caf8cb8dc5a1
BLAKE2b-256 3cbfde929916f4bbaf69e211acdc1f37534b1b64951497d54992acc49c124130

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dfd2692c375efb7421bab68c7daf89854f5d7cea26c0b16f7cdb6e4c6f52f956
MD5 2f9fbad6f86e22c1f15fa760da972a80
BLAKE2b-256 e02e43170debaae04aa1ef9c74297f0771d5b7b1bf36606eba1329830e5b8b1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 40fbadc7756a6ad45b6551f3cd7822143150318b1abbbaebeb863a1ddbc43fab
MD5 ceae2d6b9537815eeab83508e4fe7bee
BLAKE2b-256 e1ef8c6051a5e9874dc16468de34ab98346438eb3c51bb94678cc8fd505e2b4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 120896d400f01ad9d1adae694e1cf03de0a1778bdf8324426a6770c34c05a1bc
MD5 776134fd2d9e70a15a8436a8628cb93f
BLAKE2b-256 b858bc3d043f992e57b430adfa8137a3cb21c0e8d64ae6e3ca4a3bf3373c9803

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 225888aedc59511f3a950b6d309b60bc2caaf4c7291f01237d389e80f3122efb
MD5 03854883f189142af6e08ad39a6c3616
BLAKE2b-256 ab0b496a87e89722edff1bf27237fe9476aea33b2d6842e3da91bd03eed4ecac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.16-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.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 97b7cc2b4a4bbd3b728d1e4273007d1d4b569c1a36fb574fd47a6c0f9c6f5812
MD5 160fb4642776133943dfea200b9e56c9
BLAKE2b-256 8f3aa41e515198185621778a205990c0c04672a061883a04e33369c0522681cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0a25a2ce2910e4abf3e0ff261b417fd2dc72b3f2380c58e1b8c1c3a758ba9c1
MD5 3cffff33f107806ff6561894379cad09
BLAKE2b-256 d0ee288080e0f958e7a45106be7f2c2665d596f5a2906d38d8a63c98a9e25cc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 265ba66c9108282ce4d14af17339269d1a04120f71a481e4473eccec714c94f4
MD5 708252d62ee68212669352c0dac648df
BLAKE2b-256 cb89d6a79e198ec2ad39de353b2bbd5d9b5d10109aefae45a28812cad8145f3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2ed9bfcd381c6c6a126c97e96c4d3420b345b464ae3af7653587f0879ca9f77
MD5 730a97e1308edb1c244322ab6779e36f
BLAKE2b-256 4055e6f6c09bfb5ea51c33de6833aa8af9dd2149380ac3ea80cbb2cd6db560f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4d8f3a29a1dbcd4b05e99a8a5a78c9c43271477c01ed595cc910466308d9798f
MD5 413277cd6b36227eaf8684b75051ec69
BLAKE2b-256 ec28eaa86340073d748a011e464d78a5e31b08619a075c57e7c6d9bd2716f8f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.16-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.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8fcdf9d3e5767db79df37a9678079733f987232cb10385f753307ab4bda27965
MD5 5ded2285833cc66d086fb2a2c72bee34
BLAKE2b-256 e81b19f2ee26efd5ede50519a9f11b8001d3ca3b9bd3452a219896b7db69f68e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4b7c42e0222dd4de81eb378bdf75924b837c333dc9085736d0dcaf729d91b033
MD5 03bc77a5e24e88b1ccbf79904bf613f6
BLAKE2b-256 f63311e27bbf9152dd610bce6bab63cdddee0944263a30e8206fb0b39ef51269

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b3ccebb8d6874d83b388feb9d57bfc14fec09b6373a33dedc66eb9fbdc8e925f
MD5 3e001ed1854a10e0ff814a68950e4fa7
BLAKE2b-256 1e6f44ca9948fe1ccf1ea3fd4b5dd4eb2033a5ec3f27f86eb709d35d583b69df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8236aceb62f410e1e1b87e3e23f1b79bdeb2df080a53710a01acdf740c46635
MD5 594a1de6d2d6975a572af48012ca544e
BLAKE2b-256 c0aa8bc5b0820a49ed77f63e4017fbf043b26b826b4999653bcb65d37f9647fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.16-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fadabb18006493c10f7f47b6fde467c7f152179e53cef2f35ad76434a9e328a3
MD5 19ed26a5b54b977c5ed3b462a306a313
BLAKE2b-256 af8844482574af305d0989e3f991ec5a5df6047adbd28021c3cf863284d512b9

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