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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.124.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.124.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.124.1-cp313-cp313-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.124.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.124.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.124.1-cp312-cp312-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.124.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.124.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.124.1-cp311-cp311-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.124.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.124.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.124.1-cp310-cp310-macosx_10_13_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.124.1.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.124.1.tar.gz
Algorithm Hash digest
SHA256 326ba2a10758aee03db602a04d1b4ca5e303b633a47ab77273b40e03789f6112
MD5 bf9c3f46cdc12e0bee64c3ca326796cd
BLAKE2b-256 458cf91119fcb213e9c99f464c1134ea3e07a78d4da36467fa4b0c56783f1b34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.1-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.124.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 92c70a91feccd0e085265e6d012088daa1e96d34f37c7f075eb6befa6be77d6e
MD5 547cb21670a131047329a432174d1adc
BLAKE2b-256 0077ab74ecab326cdaa9355f420c94a9b0d94a2a78a336b44fda47efe3722591

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b0254b0ab1e107246021444edb88115b2710b1711c2e4e3c6d7bcfabbd74c115
MD5 f2eff3a56ea5f34417a8ac93b950019c
BLAKE2b-256 ce15ae44e6f01f8c3d295e79859b618c7149e188c4249a88e1f2f329a789fb1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0c461671df78b2926e2756c24236cd5c1603e8ccbc3023e28454bbe3a4410df4
MD5 678689eb0af12082837a0eb62c55950e
BLAKE2b-256 c02ea08968d78a87f02bc225839a514a091ca3610fee1430aa8c3605cdfcd3c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08cd0c7765c1a68fd85bb09497a5f300f84a74b23a574bba9a605e18b92476c4
MD5 1c99f37bb14cbef363895c8f8e3ebf02
BLAKE2b-256 b167894d5ab669baf46b193e80bdf3e865ea6a637d80c7327571901b2c48d854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3165c7ea9a5091c6635d4f01f5ad1b2dcd1b117278175669c62bee5ebd0ebb60
MD5 038379231482c89ca240eac3f6d8752b
BLAKE2b-256 9171c29f46bc7b0f1dd8d99d39f052a10742b1dfc90c9b96ee934b7267e587f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.1-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.124.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e4266cf567d1f289cabc8b0f1b413790d3c6946182f9b916fb93ef9a2de249c3
MD5 97aa04b642e1e8f33cf72946d8693472
BLAKE2b-256 fdc713d97a462f959da425439a32634d5f6c988fa424099da453320465fbfa8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f932aa24faa1688b7055a4a0f1501cb08844badc26e7b4add8d54ec8e707f891
MD5 4fe82818701658590af19c8d300f410e
BLAKE2b-256 b1bb5fc6202c1707efe569aa3ffff638f8237b1dc32072d02875c7ce76f7cb1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6bc09ef9008d9849674b12ed01e201eabbe3d00988bc5c9bd6ab941f4f95d007
MD5 1df5523eec513bd96eae372a5c1bd526
BLAKE2b-256 c2712a189d86639123e0fe1d6a56de4178ec41386db7dfe4e18816154131e569

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 362cdb5fe864901625b7d016b5febcc16f6db6c7b45d7dc33ec93c165299d58f
MD5 853d50f27531b6cedabc6d14c28cc79d
BLAKE2b-256 eab5f9ed5bff49871ac48f0a427da85d3527319b0c2973d98653b8979e5c1258

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 739db450715d041b721f54c5f1dc24a9bdc82f78d7487064361cca01fbf017c2
MD5 a398b0b214d14721a0711478334d4164
BLAKE2b-256 e1f6c33f0659c1e0bb4cf062b4b2e1e1c0cbfd00267279dc00a149f843f14065

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.1-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.124.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 56f2bb2cdfdda12c578aa197033107480375a787f4a82a48c1b43005bd1ad949
MD5 df08e3651d40175dd36cf0ad1e30e1b3
BLAKE2b-256 6ac3a153715f0a94b585a0dd59e5fe03843ab9931df0c202aed1cdbcd3c840af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6434f0d8861042ffe22564f062a6f57ffc992e108bd71796e3a34b3bc2402381
MD5 cf2b19d0e6c9a5a122d73802e2c8ca9a
BLAKE2b-256 e6d3621f2b4334d189cd3d7df1bb47cd0543a008d843153cbb9a0796fcb5f7a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cb862ed7d7929de0a439c9a3efd6139049e2860c979de737ac9984514e8760b6
MD5 d40a6b4bb504e389137b7ac164d49eab
BLAKE2b-256 3381c5d340d7bcd57bbb9b80513a99f89eee627b769ea4ebc5c7b15c6e81629c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c38cd2cd0574c63d2ac85114a71994224e8526246dc6d2c049a784d58f56074f
MD5 979c131b50624e6e61239a4d0586ba44
BLAKE2b-256 ff2ab72ed97624933b5d2cdec0822a65f2878f3953112dc552837701aacca775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3674b34113f71a773b57a17f2d8d0272e393c869101dbd6fed600446fdbbace3
MD5 c85fe72361df1eb7cb22496f831af135
BLAKE2b-256 5ee9570e3690de7ec4e94433df61904fc1620fdf66444a72a3c645d2c7879a9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.124.1-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.124.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d9c9c3ba0a5bc416ce5ec84c9353991d678ae1eb5c4cae9d0ae861a3e5f4f582
MD5 1e560b4f11b78c1d9676b05b57efb74d
BLAKE2b-256 cba9488fcf46fb6b4d7748dae4b06b4db722a8fe5f9a1ef1ec72d72ae310063f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 29a35af1a9553bbe577c474ca669e2a0af896a8f46a60934da84f35b45c7e1bb
MD5 5e5d9e104802db20bae38634075a4810
BLAKE2b-256 3e523b32a37fac5de6e7c3c53512fd103e31e351eb33e99bc10c006d32d92391

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ddb246d18c3247a7646d6593cb11dbe7318a6239980f75ff1f86cd6a7f03f85a
MD5 631f9ef6df050da8d2fcf54c31106e62
BLAKE2b-256 54bef09c55cea4fd9854460ec5da0bf72417e29761811325763ba73118e68e88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 010b4fb5d32ce092db111eb5a08a00f62adf557d913441d6d341cb5992c40038
MD5 12a891bbffc84654a9a0e7cd6abee6b0
BLAKE2b-256 f96476962476245449528e447036eaa30486f5f8f484c18ad2ec16b3fd0faf5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.124.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d46642b67121acb072d95eea000b5511a07702306425fa0757f9c29eb9f88c00
MD5 fe4c7e8656620a2f80ec8753c05db163
BLAKE2b-256 47452cd0968c642976d64ce389a3331425ccbb47297b936da6e560f51ac4581f

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