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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.111.1-cp313-cp313-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.111.1-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.111.1-cp313-cp313-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.111.1-cp312-cp312-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.111.1-cp312-cp312-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.111.1-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.111.1-cp312-cp312-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.111.1-cp311-cp311-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.111.1-cp311-cp311-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.111.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.111.1-cp311-cp311-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.111.1-cp310-cp310-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.111.1-cp310-cp310-manylinux_2_28_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.111.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.111.1-cp310-cp310-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.111.1-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.111.1.tar.gz.

File metadata

  • Download URL: chalkpy-2.111.1.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.111.1.tar.gz
Algorithm Hash digest
SHA256 f3b1cd462e8c08c30f117001fa285682f44066c24d4cd0d6c832dad8a994877f
MD5 bbaa39d3556b2f0013a74a2263091440
BLAKE2b-256 5a16607f516528891f97701a64136d211b8c8682ce8f967eba01c3768b1f545e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 91869b427ad21b96062a2160421895468fa001c71e1bfa8c5719e015973a743e
MD5 7ef05253304cc379f15584fec10ca03e
BLAKE2b-256 a3ed501ee88e1e9fb2212fdcaf50bb05d6bd37b4fde08c661d13b3a8f71a8f42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f26aee901baa3f45a4f13454e805f96fc728478f45da98e6e63c4c63769933c9
MD5 f94cb3ae7cd82e1aa57b980f0e2ba6e1
BLAKE2b-256 8d44bf4c20b1b7c1cb66d7081bdd8a8748f24eef9b2b745dcdc84c289048e560

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 361c445a646c2d6c7e4699ef1b15a19d8f8d069822d893551933ea1e50b11a8d
MD5 0ad50d968ecc7c6c691a50be065a73cf
BLAKE2b-256 2c42c4873e5cc70b84c0807e105eca09f42109dab5932f5ff3e8d7cb17c87c98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a4d602f18d33b37a52f05813f8978823b68384c56afaf4d6823349e38f8c059
MD5 eb888560d554120121fb5bffcdec7aa1
BLAKE2b-256 b041721a6d12de3c26ff8e3bf85bce70ac8d57112cb5d5d988ff58a7b0e9a259

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 85c9c0dfb804a97f8da0b05854cc0ad8800cef3f7c2f9e11d7aa205fc188e797
MD5 fd28b9acef23b09ca8bf124039b1bf94
BLAKE2b-256 feef3092a6f3c032054e83925ce0508dbcbe719088409ebfbef5745b85b436fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 972a534ed7069f43b7750e217524f002a8233afe15016e9f92ecbfee9b2fffa4
MD5 3b83d7a84d117b982a4d35905b4a491c
BLAKE2b-256 7503eb0909cf022bfa35c2b58bd20adc0e2fad56e151c6802f435d4570a5e07d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb3d18b452cadfc885062745837cd191cebe219ba266acd2dedfaed0e003253c
MD5 dbe130d2aef21738828a847436a833e1
BLAKE2b-256 85772f44b7a575ee04f8db3a44c9238193c395487b5d9918e92fd65f65d25b88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d3e04fac12e8d1257330bf0d6f6c9f1dd2bdaad0d76ee1abc56a2ab366c12c80
MD5 1bb4f4703a722f1a406ffd3c462fbbdf
BLAKE2b-256 1b44ebd62e01c5e7278474711c25aebca10ae89aeeea1db79fe65730ee316cdb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad4a9e1d53bd35329c2c72b0b1412dd1ddee043befe5db324cf43efd119babc0
MD5 2c8a4badfced71ec9d8a2dd5280eac61
BLAKE2b-256 2bdaac90d5fbb258601b7fdd7201017582cebed52e66874e217d8daa94030129

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 530035bc428fdc25b03cd0e9650b2357b5c90a0b5343cfaabd6b53f457f6f71c
MD5 e164c142d4e4a7bce697ca7cdf8a9630
BLAKE2b-256 82ac8e17173ea381ee17fe13b782ca8f058d884d9d2497a77bd351d6681a13d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 82784d54c38a3670ac1dde0f3a1929cf5cac04190d0a30f9ae554a30682a7f01
MD5 1af15b0164d92f5d46c1f69c30d09b38
BLAKE2b-256 9b4d7d4568719c0556760d0e801d81cf4017d434015642b5c6d15f779a039f79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e60a3fddd5ea60c020c42fae782f8fe8ea3ed59c3620eecca72a54cf6964398
MD5 7e9756a616b5ade226b549268e3b0d8c
BLAKE2b-256 b867668f0de7a24772e6592e931cdeb414c802206c5c150f59b23cc910922a73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 753054d7fb93ae1ba390b87ee3ba2451473552802df8f88e169f97a56ef4bed0
MD5 c86a8efafb3bb8f448814096a1ab7145
BLAKE2b-256 6356212bdace73186377287397e5b636658960992e0ab7a989e034ca2823777b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a228a246dd11c09a95c9ab2d7f2ffc41b28be2d78f3f5655aa68d1b3762a0bb1
MD5 b7ac8e1f742ca5819d4aee3285cacee7
BLAKE2b-256 3576b4c38e3019f932ddc553ac0216a7ae0a33e21439364fab0c028055ee009d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fd381a5fb6abc6e7a7243e8d8c484125a583052021649a2848f62bf18de664d1
MD5 6888bd80a554b4732e54469662022773
BLAKE2b-256 989f1cf7ca0279cef6856dbea67324eb1bc47cc50cf36a72424878293781e1e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.2 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.111.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7552bc1b4ed46f320c9a36dc1991c8e513d0989ed04ec35e4e6b00eb6599d24b
MD5 d166ca5f70d8ad2ba7d65991d8a67dd3
BLAKE2b-256 3a36c56f99afdfa2e26c22b3661312db6e60cf69a83b520f85602785a0afa327

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fd5165ab98a3d74f2bc2a0db967ffaf78eb7dc58bbad9d0286e99b2b7095e661
MD5 52396487b82bfea8a7e9eddbb9ad4509
BLAKE2b-256 0f9d03b8cefb67c1f81c16ffcf5f148caf1b36322754772db63f5b7036f54dc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 43c40248f6e7254afdc32136f9bcee7a7a0b4e8cfb0fa9ec120dae1f045c230b
MD5 335603f9a8574f38f9fd6256976b8331
BLAKE2b-256 b9c3b27f5e556163fdf689838a910dd23b2459efe1eeff35502ed472a99960dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a74779879d5cce2a343585a3721e50f43ac5f8b1909f1476242003413b1e0527
MD5 31969d2ab00a72cce2da4bd66d6f79da
BLAKE2b-256 4742401e7ec4da34e0816573477bfcb5ec58c7f802fd3bb37862773a9b3bdd50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a4d2aca6eca951b208e479011c9a762b67c0f1e5b3049ea4889b9e999ca558a9
MD5 8006a6b12e28edccce2001a3a56fe250
BLAKE2b-256 1b9a1e722e9ec6d42e973b8f8744f134547d7ac0e0d1d2f0d2c1ef2fe762d805

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