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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.18-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.123.18.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.18.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.123.18.tar.gz
Algorithm Hash digest
SHA256 d7d526bbaea482619e3a3f7af533e4d24831763222c68c699dc956c1e6ce3a53
MD5 03c4771fa3c05ea195ce180c6f25325c
BLAKE2b-256 dd8530cb6cc44d50a2f22c14fee70b3c7878590c6dd92d03f0827e397d6b281b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.18-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.123.18-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0d727b2b3cfc5314377368248ac7b9f95789a1c049edab35410091d06ba8aed7
MD5 3f77b4f745c9d3833006eb467d2f7ae6
BLAKE2b-256 548641b86c2d52879886ab329319b90c415d5fb34640c93fd8952f3af0624398

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bd5bf6b452aa87eee1bc7b08248a4774dcd357a998b2302ff28c61b4f62b294c
MD5 b576a132844dfe6243318137db599ecd
BLAKE2b-256 d6a03a723a324835201a5c1d77c031eca7e8f0d1833e6b941851a977106b3b6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eb627e3e53db66433a064717fd7fb5ca641f89444770ca3d72c5cbe69206a9c5
MD5 4697450f2c2dec17515f337c7df5136e
BLAKE2b-256 40eac95231949d429596920788c3628c57123201733ed56d2edb399987b41cc3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f59c1fc09e8354a197539827b487136dba8591779a281195fa375b5132743d86
MD5 9b81cd57d56685651de80ae1aa147ebf
BLAKE2b-256 1442ac66f9b37e1a5832007882609683efb4f34b4289d0ed61dbfd17c2e45bc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f416763838b78caa96a83060c26cbb29a4237d2d593fd41385f9a5227a09a58c
MD5 8a518f414ba93b73260af6089c3590f1
BLAKE2b-256 d849b88afe588c00e929e976c5b8bec3decbb5d3593386e33a16905fbb6e40b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.18-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.123.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fcc0237e1f42844c5cb0247a81fa9cb2cac0fde74dc8c810630514249963d0e7
MD5 7d0e9248803284994855ff657d21746c
BLAKE2b-256 c1de3066253b72d8f4a69cd52a6e7d945a3682aec69a133204bd523a0d282d76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eff8caef190f2e3f72cb687ff071fa3c992c140aed17271c49317a5df850bdd6
MD5 b1ab86739ba6d86b67f72d0f101f7c74
BLAKE2b-256 46566222503b48885feececf42784e23ae7d4b4ad9ca9566b460f9cb9c1ce862

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5e37df0d163df41fb3fde1838bc12a15d6bab7d9d198286b2c16fcbdb53f8863
MD5 4ce118b86b8502178219e3a8866ae0e7
BLAKE2b-256 51252fbdd96403a3f60aedcf7fca6aa6414a6aeba16c1211ebab4e6b2eca03c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6aa79778dec68156e3de41e1f135b50a07e21da13d15736fe38c8a922b1e2962
MD5 306c888fb2fe1381dcc408a491dc46a6
BLAKE2b-256 ed2414b86dbf40d85b69037d3b7ee4b4393ba1dde8c7fb88196c7e2d580ed8ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a465681aedbfd590f239d159b0dd3692bea0d23b4c6468e5e6bc0837b22e38e8
MD5 f4298b250139a7ed0007b940e7ef4b6a
BLAKE2b-256 c34f1ac38543ec3632e54bcdb74e4df272c489465ef3f640373370da8b88219f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.18-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.123.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 262cece4324b5d382554b903ce0212d769d0141175e2c0fe3618814d45e3baff
MD5 44eeedde7cd7f9a8332be7003d60552c
BLAKE2b-256 dc947e60d0b84eed6d09daaf445e5ffd0b74801e5008ada24e33f1752f4e4407

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8c50a5f6276f1e3bb0e3d89b904975be1b6704cd2241e8701f6eb170811deb5d
MD5 4d9760db78e8f1c83181da7963863316
BLAKE2b-256 b1f4b29d29440870a7621ae322c9f27916fe3f222eea421ddb422097a2955276

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ec131ac59e21756b70c114ed7f4c60f030ded09c6ef26799d22029d892fcb8e9
MD5 4f9a5cb7661fbf1bec86106629258262
BLAKE2b-256 1437b8467ecb53bc7f840170f1cb57bc5a51f02713def4ec704db384f1d3596f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 490c46f12e97e7e916bb7fdff3d5d152936c101fb46d7ada27ed6531aaefefc0
MD5 195c8336e836878a48a258380ac34c08
BLAKE2b-256 980b3a9878441cf3c0a44b9f0333ea0ce6970bd39e10f6c66aeb109388e26b34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8bf89e257bae52fa0d82c4f61f142faf50b8c05128bb926d4e4b7e6ad74284ee
MD5 d1626aefed38a7cbe3f52e91776e35b2
BLAKE2b-256 20fea6533f3689c133aeb019786daaf256ffebac142ca90c0b5714e070fb5e42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.18-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.123.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 eba43e37552bda00dc2dd16b453de6f6c0dd464520fe32d4bf34afac5d3ffee6
MD5 4acbb1ab62c83a47bbce4a54dcb0e703
BLAKE2b-256 a3e91cb347b04a4397e023891b587b7774b17d0650c371fcfae2d82a09e6d1f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4e8149456ee4443e38ad933f28e1c576d1f5f262df277535c23b38150227f8da
MD5 ab44f11253a113633624819ff68b06e3
BLAKE2b-256 f4de311117a3e324aa662b4f97da8a95905919e2f23027dc78fd975348b73752

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 421fe3c8a24cb49bd5c80c91e75f7db04fea2ac8c14bd2e8e5248929056e45cd
MD5 cd1a5e87baa636883294197f63e80ffb
BLAKE2b-256 9cbbedae6f161ce3c1a334fb78beca9b62cbb0373ab01258269be301b772d5f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 387dfee80b93c4ec97694cc68d2817d37db173b16477682daae8420062adb300
MD5 7a03bb1d59bd495facfc02c7634852cb
BLAKE2b-256 4d862f5dea1852dbc640caa542b72441c1fefe643b3aa3d65e7cf728460ad55d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.18-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c93f509a4ebf7206c2e47526c8834400a5edde7607cd6e4a68368e5bc36d75f8
MD5 0edfefc3e865de19ed31120997a2cd39
BLAKE2b-256 06a0f1b5be23979c051de936f5bc8919e91e8a5e16e5d51cdc7c0d8bf2eff87e

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