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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.112.2-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.112.2-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.2-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.2-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.112.2-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.112.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.112.2.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.112.2.tar.gz
Algorithm Hash digest
SHA256 97b41232cb3c8483ec63fcd4f528fbc17f30e834a6ee35dab8f8dfafeae38e04
MD5 9cb6d10407e659f9bbd65c738d0ac1f4
BLAKE2b-256 17b18a1b3ad2f1defb0cb90ba5274db35d8fbf2bffc3d0900e15a0fcd70c5cfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.2-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.112.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 51528d84efcda02fa0ab373f42ff7eacda16ee178a25d266a05de1208663c0c1
MD5 37160d74603023ac3872ec20cf661609
BLAKE2b-256 6312d848b24859a8aee154e61454e9faedb09126517614d6a7b12f44da102dfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7233cec212b44a4aa73bf16e7dd304e5a6a4fbfdc1868681716c5079ff7e7d05
MD5 7eaabeba3fcb04fd0cf63698416a96f3
BLAKE2b-256 38b713b968db0f51b5b25bfaf99446e10a2b9e6e1e071714ae3c3e2b3f11c8d9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e366a5ee7753addc25bc97002e0d7071b4d458053371f7421336474c6a364876
MD5 e6c3ac07fa0071db5281ca162d382e79
BLAKE2b-256 c48516c4600c8dfb2d6ddb6c92e1ec62df55d862c8e0726c8640fb18b1727f9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c06b5ec1a663f48efdcc68441234bc054b013ef28d420f55e86a9402394ce8e
MD5 537cda26b7a524cee114d4879e23597c
BLAKE2b-256 a6dd26036176509a3eb34f9663493d5b26c8b70c8e3115ce8783580c73eaaa7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8928df519c4a30da63d1308f2eaf1dcd05ddeb28757b554c4c94d94651ae8552
MD5 54d4758a9d489fd35bdef8c30bb78bbb
BLAKE2b-256 62b18fd63c1ad1e583e4159eac42996229d13e630b63b9731683396012b4c666

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.2-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.112.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 01df8fc2206d87965c63ef3549c362cdcdbdd7cc0869d86a9991b219c59895d2
MD5 b13a59459571906426aa5d48229978a3
BLAKE2b-256 d7b8b68abc88e5a4bf441e8f83737984cea3b49b3da89f36c14628f65635f516

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fb5759331d25b43775a68d1cb9952991368ef2e41dba83c5f5dd04f78833ab9c
MD5 98a713c9ddef12d6365bd7987611b9a3
BLAKE2b-256 878ecf4d1821acab64b9044f0d08528044682cb583e3851242dd98caa2ae858e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 36b0456b800600c65c9f459e43db69da7d8e6948befbcb0b8ee1cbb2246e24fc
MD5 25b57bb08fb7f05aa79eedfc33de396a
BLAKE2b-256 ba669a49a9c92f82d770f56c8cea4a0c190007ad6224f98b0738047bca0ab322

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d08194ace116547c6773c77b84301308a46ede1d842457fdeee5c52f6dde3759
MD5 ab75a1fea7f105fca841908b85004d92
BLAKE2b-256 d23d8b8b5ff2c7cafec9e13748f1b8fd146e46d060730b403684f0544c5fc921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c5cb1cab7753f8121f1930bbaef65c86c84c553b8c25ffd172c4a633e409cf6f
MD5 eafc9bed1681c8772da172808f32bcaa
BLAKE2b-256 429d32003b5da598a12d01359017f41094bbbeab4dd923130259abe9de55b25d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.2-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.112.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c1baa6a7d409f6e39343d00c28eeb87904cdde13f0c81766e6e5fe4a523db43b
MD5 54441392a8f9c147a243486b12ad20b2
BLAKE2b-256 e59b3210a7657170cdd7f7307e657bc5d860b9dbedcdf3c08d329840d4b9588b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b290fd128accdafb5422f9d63beeffa2dc3008a8f2f9cd13bd2841504544853
MD5 ebdf0e829620abcecdc050fde0f40fc4
BLAKE2b-256 c6d735c845592a5d3b6daca1471c708c092323c954db8c41f1dd094b04c59eb6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 991370f9e857a9b135193b241ab1cc21478f2c01efbefb55ea5c842cb1d76ad2
MD5 b0ee3a25ac9bfae5af60fdea40259e8c
BLAKE2b-256 20501314a62f8b104f4030a004569bff36bc8def7ac96e4448c9181276651701

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b5fbe5e80cfdda82d42e95fce4e2a2a68a6af365926b114a48d606d10369e31
MD5 de50a14916fbb23f6556355ade9ee769
BLAKE2b-256 d888ea49ec5bc50611fa32a383c9689d375a262f454ddfa3ca68822efc714f75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c55d61787fee199450638bef85f090452be98e4fa99d13a9b97809ebfb694b78
MD5 79b86126160f7ed96937e633dbd73356
BLAKE2b-256 f82ce89c25a2da4e02e185ca8e5993f4bbc37d67f1d758b8aa3e669ba50064c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.2-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.112.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f5dee00dad5ae801536a382fdd866385aaf474c4623b6847619ab0b4cc75db82
MD5 56f47b7ab6a7af644f8b1c2f7891acbf
BLAKE2b-256 6dcd821dfd555aefcb9e4a95ff2a733f58f5373dba860e8f988fcb8232132c8c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 78ee1841ad699b25fa57ecd28b9a66000d5526823084c3d1810594f064a7313c
MD5 8a86148a89732d024b53d2e257d065aa
BLAKE2b-256 ef326b5e8792f4432d6a0573ec3f8def2b4fb6ee75d7983acb46836c3c74af57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 725b5deb49be20c9bb19a083481258ab61e370912b4b192ba4847b1d0a5c1d6e
MD5 8f7870a538838a8d328a061ed67396f4
BLAKE2b-256 686b88923f5fa39c31a3266d7f97e05f712780898075c24b2d618f3ee4f53c6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 276ac5f3d767964026d1238af847bcad267db015099316d11725e880cea44585
MD5 d2efd02238c1f564ad1f0a5f9fe71185
BLAKE2b-256 a25660d0ae9ec184977cd6ad54996c25d50e0509d726e8eae4bbba0464a0e11e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8e48f35c292268877e9775df6e39f9ffd7ffcfd8ff977fe2e1355088e1e5eee1
MD5 1fda3b21ad83f371fd1d8ff2f0764287
BLAKE2b-256 062b06e4e58fb91f848db0c7dbb2a6604c45cd97c6e5b512a447853b0ae75455

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