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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.111.5-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.5-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.111.5-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.5-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.111.5-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.5-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.111.5-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.5-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.111.5-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.5.tar.gz.

File metadata

  • Download URL: chalkpy-2.111.5.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.5.tar.gz
Algorithm Hash digest
SHA256 27ce84c07f7f498da2c34c9ec5c380854b413fa8e264820362d23a7eafdd2350
MD5 6f94010d2c2af6f97b50be8c55b8e279
BLAKE2b-256 66ea0d11197cc2f32ef013019222546dce47560fcc2e9b7c0b314512448ab255

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.5-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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 db3d58856322b3f86bc1b4acbcf4a1837a3edb199704ea620a6626879921def6
MD5 0eac61d2a1b3831be72e379d52b6e8f3
BLAKE2b-256 2c6778bd43c141d96edfc55ba23a82c61f9be0002d0a79e2f0e378c807974ba5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d7a31a21f26c6d541ee7bebd6e19bef5e1e0c05b9c162e55157d3e51f8af2008
MD5 24b993f50aacae57c961feda4044123b
BLAKE2b-256 787d9b40660b1887a18b090dfde9bb9f94b08eb6d6c7288275243c9f5d72b353

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 02f17b2fb54965afc05cc8056851bcb40f8de5c09a07b57087add9503d5f7f24
MD5 6c884b670a44fb777c8ad12e397e408b
BLAKE2b-256 7d5241d41c6bb5ef713e7b265c336baa0baaf13bf2aba2aa41f224ee37bffa4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 012f7a083b048ce3a51eae9ec21cf2539ee42ca7b7020ad71f52a41abd5d63bd
MD5 bab792272a2d7180dc6aebe9cc078e45
BLAKE2b-256 2b5956efe16af8ac5b9c1132f9121ec1531755e3f1d3dfabe59d70fc89716f76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 2f86a5926b22034cceeba7268f49bba830307cd242919a18b4af79c0297e824c
MD5 7fbebe22cee1ddb277e93d87f4f84340
BLAKE2b-256 612ba8f732d3b46bc3536b5bb92c591d47148c7064f8376d55ef5f5eade44fe1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.5-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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6a85c1ee44e7145dae7c693acd4caaca518ac3669d3551be010201a35eaabe3d
MD5 486bc3dbcfeb99c7e7a8f79250771b69
BLAKE2b-256 80877f63e9b04fa510b775632d7b6256809ac55baf0f64436deaf017aa33ee9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f52dbefdd81a09d259210180d1c03076dabf41771a3a67cae972aa6e5164651f
MD5 d96205ff343d9503823065a71a23b916
BLAKE2b-256 8f32ed86bc045eba85c44eeae1e49489acfa8472225082d3a1a325a99c997b1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 35fdd066df4f5b112f218cb24d98a5cbb356db562609dd03827aaff87f353a06
MD5 8c01a3640efa58c92aad0d8793f5bdb1
BLAKE2b-256 5187f9ec458a9b83e4c87f240e010e4c22baa3690b8bb08e78faf29af22d7652

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cf85c9f33012f5d7f46bb13864d7e4e6148bed0fc216e9487db715ceaaad8ef6
MD5 1a13f1c384ff3fec3144b9a8fdb85a2e
BLAKE2b-256 636f8007051863cbd1e99d2fab5bcd87f84b7f0dae6695d8840072b23e20d36f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 57066c7274ed66607d42622e300975a89ae78899e8f7dd9c8c783f1c8e38141a
MD5 a8c33e2963344c9cdebce99a35d7266f
BLAKE2b-256 647f00f5cdc6f378cadfa0cc47cdbe5daf4bf06f8a2b06fd5ed1c13e342ce702

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4191a64b5c1524b941ea09378457eed73a69871e14d804256df73f2fd4147dd0
MD5 342e5c73915d09b7e7dd21a92bc1594e
BLAKE2b-256 76629ca61d736a64171b3e47f1a9d1e223dc405f39794fcb38082bdc9c3b64c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 743fbb3073e67dda642586d53213d63450d500ef1bca4b0e6f81156924e496f6
MD5 d06d48c9b913dc7aeafcf60df0353725
BLAKE2b-256 c8745bc3dd6810ad71fa7fb2f77ae2fe1997cc04ebe3e48e08b13c7d43bc03b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5ebc3d925e45b67d6a37b2b6c746525ff0d713892203499796f0ebe17f004bd7
MD5 45cebbd2cc9a0f04d0b18478db37f241
BLAKE2b-256 15b6106cc0e1b15ce433e2ae1b10906a827f9d2d2cca7d1712412905640b55a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24e8299f26455daa74cd45b1c4e785d61c861441e3263f32c39700437c93af37
MD5 7d92d5e2bfe97ffb719840dcd7b245fc
BLAKE2b-256 47e5d014b14a6753e9a12cdef14802dcf25319cb1bc15af0716b24d62ecf6b36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5e787826af1cf64dabcde3046684470887343673ff11fa64bf0ab1b0c8b54676
MD5 c60b9b5dea4b22e730cf91717d6a0d08
BLAKE2b-256 d3c9d0d251a132810d6e66c22f0c69174099b2b0f889a4bdebde9218da1141b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.5-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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aa7863d09bc7ccbb98c9f38d6bce4a7270d38da6694d3bb664b3acd4deb386ab
MD5 5d2ec8481950dcc048a4fd1fc2231f63
BLAKE2b-256 4564fc9c6b5b88043a98b4ba081eb2911e18b32ed7b425372d10b116cba4c1be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae6013daacba28befc208f19b0791dfc02c35f8c39e9a441745f7ea3185d2a45
MD5 9bf8618414c7e02e6677a4f69c182916
BLAKE2b-256 5c803efd602f24b65be2cba46c7a661cc1ad014802a9262c5bd063903eb12521

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d2c033b7cce3dc8bd537b70c5f7479427d831270d294d90588b5286ccedc6877
MD5 21156748ac35d2ce3a33846efaacb8e3
BLAKE2b-256 8f3bb5263235e40ed97684b112633b88da0c25c25ed8ad04097eec55001f9959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 532891b5dd62bda2336c8230f03c9a4e73321232ee74f079107516ffbfc47f50
MD5 8956bc5555805474d3a9ca9005fa2e87
BLAKE2b-256 56b7b7273cd199f294ad43886906065d00de93f1729cf572f5e1eb5969bf280f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 576b3816e00da3759a24ed2c8f5a0b0f6f9cbe91fc3af35bd330cffef6dba7a7
MD5 82c68040cc0b39251647e1d0d6fe2054
BLAKE2b-256 30cbdf833e0f38441da2ae39008479162eb1e58dc3acb16fcb7c28cc0148fa98

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