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.121.0.tar.gz (1.6 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.121.0-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.121.0-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.121.0-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.121.0-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.121.0-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.121.0-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.121.0-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.121.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.121.0-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.121.0-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.121.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.121.0-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.121.0-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.121.0.tar.gz.

File metadata

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

File hashes

Hashes for chalkpy-2.121.0.tar.gz
Algorithm Hash digest
SHA256 0b72c997c36e80d9436842f906adcc2cf13ba4266b369f36914aeee7b09f5b1a
MD5 e782641eb74f483b805d0c71f824eff4
BLAKE2b-256 4e311eae7957537a4fd862b2fc1fee2b0369427e1e845564c11fafc7c105b30d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.121.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.121.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9b1ee6c9ff853e9a4f8117c725817e137ec9e0981de926f1d1406bf6c0c1e7de
MD5 a9b2c42f84c654480736872ab72d46f3
BLAKE2b-256 d2e7a85152b70877f6f638a6bdf688783f303954de5130e6b48da8b38c8211a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9547a8621e31756c3dbdf0b24ab4ca477a54446ab1c96cae09a7d31089227f08
MD5 bd865d69091ace7c701c44c2917d946b
BLAKE2b-256 23825c286a041762b6b93c69e4dd6b3ea9fec85dac2d9bab7fb985fa6f2e8ea9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f2576b8649d1e80d49f7cf124d99424cfc230c989666d9f622b099e1dcbe2172
MD5 7261fea5b5c258bf00a3227cde55b0d1
BLAKE2b-256 816bf4b8990730e428338d7c333d6330a3c996b5199e8d8ed2e29688ebe389df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ee528c4922c3da6c8365bad6fddfce5b4770a3a238e20a1539999faaa749756
MD5 bdf5df67f1300bd0e0a59d9f9e490b1b
BLAKE2b-256 b0241d2a652d4e9ee6297a72977b72e35ebd1875765a3dff1decc219c02915c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ccd9513095890de3c3638ec085c0c7d4688ca6b3a7bd4228579ae0a787f47f0c
MD5 aa86a8b1850719df535bb92ee314b8a9
BLAKE2b-256 83ce87b2477ea8fdb84f54f71f97bb6e40f4928f4aab8cd5962bbc30801a115d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.121.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.121.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a107fb1b9c61db609753f9e0bb54986e738f5bc84c2df0e32c7b22cd8e52731c
MD5 31d3d6fbf7f73c779a2fbd400a0749e8
BLAKE2b-256 056e58fd1bafc5c8094b9a93d91883db11a51dbeb21b10e0097ca415e33f8854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b0daa4ebada3ae0573ae2cde4957f6ba539b2210886649c2c6d548d8d793f19e
MD5 3eaf11bb5967e69d6b088decbd4404c2
BLAKE2b-256 108ac73ebe09d19d3b46b716708880c2f09382e111841f426f1bc75b37db9ec0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ce35313032b0c2f497bfddc5f04421ef636ad33c85992dcb282fa932c50a7620
MD5 ed3dba3fe0bfc660b4c8626b67be77c9
BLAKE2b-256 44e4593c079d6a55457d7edccc4872c2544c2b6a06c13a514d00a9d50ea845f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ce8b2221696f08c078214ea0d21c1ebbc2cd3b3a5b4be27828b758157da19373
MD5 9487cc99af37f870911d3a95c4889e6b
BLAKE2b-256 2ec93a7b7469f2a12b87212978aa7f51cd49998cd17bc82d6284b7f7522ad5da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f8a3320711c6eb94cac1536362fa0078277b2c6a48e32210750983b933bb2a5b
MD5 4f5456a8d9995626af323725ad4b0dd7
BLAKE2b-256 7ba864fffd54650d9aa55f62fc9deec49f46de2492b684b7e4ee450710723ce9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.121.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.121.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9e4a4e9a5ccbfca46fa7037f77d3d28b049c713be2aac469c7ccc3abdab8de6d
MD5 138def54b2dcdc47383f556a2bc01709
BLAKE2b-256 85cc97b385e939b99e69780694206d62197d7bc24c5ce4c04dc704306e7e82a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1cfd4e3b3c6d9306144297f963131d1cfdfdeec48adfa49a0fc2f32b77796547
MD5 0e0e47208caaed3f8802991ba3d52939
BLAKE2b-256 865587dd3766f27a5b3ba0d63c4176ba54f9c2ecd2fc82c51854ba6daeb2fe65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1391af569b8c7fbf50d51c2022cd57fb085f25a5b0234f752c53d403d4617ac1
MD5 506618924f0f37b4e4cb5abbb72caea8
BLAKE2b-256 cd58c924bc347ab71933f1877aa234f65d06b9b72ab4608a41b39c4911881aba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e47a3d0d14b40c67670be40dc59a599ab10e1318a915949c3dfd6bb8fa81a41d
MD5 6d6e88741a4f75d748228709dd8df650
BLAKE2b-256 3211b6675326f73d311a60b475afc10ba2f73be121ca010767cf98cb2de78ee1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 168896324c7fd8d21892be9f92a5d66b273a0a44b0b475f826510ee6771e5241
MD5 e38c011b47a039f575350184ba6d4023
BLAKE2b-256 4c06a800e282df2140592aff25b254a877fdcb84f7ccb39aa5d87dc0ebf549b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.121.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.121.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 af931690f1c3f483c238cc5e9f2ffc0fa62346d89c637fdfd3b6f0a0adf45e67
MD5 84c36dbcaf888fcb09ff9fa4fb33d655
BLAKE2b-256 ddcbe0766ec0ad87fc22ee3991e5d6831a17e7666f329eb4e2281e01cc1a2723

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5aa62d653ec423b3dc9ddeac2ff28d0909935e52e09955e458caf24398866086
MD5 73fcc0d5c68794b1b58967b754794544
BLAKE2b-256 abbc6281ea53846bfb2412ddaaaf646e1b80b74230afadaf3f3f06349c095e72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d149d8118accb48734ec2e86dd6d9d50c8a43abc1871618481ad91b19a347ca4
MD5 0eab21e605a15ef2429ff05c10db9759
BLAKE2b-256 9cf55363bc63640ad95adc875e0ba2d2b4859c861d809c6e8ee21ccf8f8b8d9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b68b06c6f4852cf18d36fe94ce568a8fc14d56f14fa14935c325001ce46f31d
MD5 702110aed40f0b9737ba1625e17c8909
BLAKE2b-256 3c5daff0d6f783d9114e16b1fbe2c4436e296b03c645f73aa369de2baa7b7fb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.121.0-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f20a7e5a63df887c5c769527881557ad51b2495f0e88caf3c9e6dc1771c687bf
MD5 b0051c97525e8a97154872f47700f8cc
BLAKE2b-256 c1b5c433ab8cf44216d47ae1399ae109c64513984fddc04c9231aa7a865193e6

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