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.3.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.123.3-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.123.3-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.3.tar.gz.

File metadata

  • Download URL: chalkpy-2.123.3.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.123.3.tar.gz
Algorithm Hash digest
SHA256 cb801630ef039bb93a01be1c006c16b21dfc41016953023be25b36c97353737a
MD5 bc010e7b941787c19de82972056e8096
BLAKE2b-256 dc157781de19fa7fc5c6f74fc674c932c78574483e89442da88f7f0258c7b86f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.3-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.123.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fd6ec243f9597a9b415e390aee9e34379f579002518561d45afa16bc1a26be03
MD5 17ef85ab548ccfbe1e85f7f08fa07258
BLAKE2b-256 2e490cd49e7b648b47217173c4381db2e0485b7d108060599c026dfe78228382

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7a9c323ec46b74c93156231529837349edbe878b8e7ff1c5c474e264dd6de239
MD5 0b97572327edf7c56320649410e34b54
BLAKE2b-256 585db2a34a1851c45c7bba7e559f8667221b9ab3712ec4095cb9ec041a8a0bcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 0e631f6f5c50e427c8f3cc583f55ae59515b99631e77b86ec47ff3e654cdd09d
MD5 3e802ed13165ca2b134ba8fd197cde7f
BLAKE2b-256 1e14ebaa0a1dde0c4d90634bdc6348920941373ccd93c95d5abafa4b6cc8607c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1399cb3fc33395576f915439a1e9b3661466d5616f197944fa3024ce6c03d45
MD5 5e385b3f592f80f5363e0bebc572b947
BLAKE2b-256 b7bb8d2054b8bd099429858438403bc2f2219ac488123d7af88e5e39601f21ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7ab24aafd57afaa541e316eb78d3e10d1ec3e7e28ef50a32d622f1dd537126b5
MD5 8ef1ab5d9b6c0d5ed190840298e8e96b
BLAKE2b-256 e8e03acec373df365d1b04c0ef7860b4d47db86960f2dbc4f969ca853ddee32d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.3-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.123.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c82f704a6b7878d8d7334c0c6efe2d9656f70c94c1819c9224df88f305cac90d
MD5 388c6448797460c9b5dbdcbde8e70f78
BLAKE2b-256 160ef9f2be910f958d56c34f701fac5b2133f30add65e1f4df22cc431f4cbc5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 545f975088dac47dc2ca27f39cb84b3f8376333204d0c79fa9d954c091278f2a
MD5 c9a22e23b7c428318062027a28b0cdc4
BLAKE2b-256 3751bbd0ee280297b3c155409eb8dabc46af352560122707a693f33a5e342fee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cdab67a5a3e2f68af1c9ed57f83890236506d4933bc7f818f143fe067201dd8e
MD5 7b7675f001e0dd0559b46c8276c7cebb
BLAKE2b-256 b2ee2e20b7d9fb8296d68b0950ad7027c87394b6a9916d583fb57d17de062590

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed08d2492321b0cf5eef3200c933c3c76e674b452b8286abfc5c27de2d8fa473
MD5 49dc367a9ce590e59591d320535f21a0
BLAKE2b-256 f584a38db35472531e67c8409e46dc34718225f4231987386eb5159693c9fe05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 35ccd7a722b18a4349e050a0cde1a6527ae4bdfdee83c3544338d540e6989765
MD5 8ee38006d8ea29d1ca40682b5b14032f
BLAKE2b-256 66f27e90a2248c67d4416c310ee62859c244ceda12b262d11884734acd743ed8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.3-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.123.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6f7efefa0779713ab0e2ae753576f1d8f738d61109b2058ce72720ce37d40bc8
MD5 030ff8b1caeca120869664a87d5d2b0b
BLAKE2b-256 d750684cea4ed3d013cf49c9ae547d560408d624fea18edfd2675c8a31d993bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6725d361b5871ca65c0fd28416c7f9a7735da8eb7f9fc375ff9d171a0490ddca
MD5 ea468f2aa8ea5953630637467302ea19
BLAKE2b-256 d62e4298f387fe7284082f0ee8fbda87e5ef27bcd5a17b10eface43bdd103602

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ee0532337467d06384a0b7225867965cf7ef083a3196691411505bd97ded63ce
MD5 8f6f316d947994653b877c86c1959e9a
BLAKE2b-256 01724d3509901d1e50eb4d52d181248e2cdfd149ae73015e9e8449df54d6bdff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 10f8b4a208ad36094d27bc3a98b022ff44e898de99d046c57501f9dad55be910
MD5 267074781d0c46442a537abe75d634ae
BLAKE2b-256 69d5adcebadb2b8595b43a5932c8dfca9fd029bef9e879dc4bd04720efc5604c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 503ab1a01bfe473538c5028d78c5eac85d856d08580e78cc250626a5fbc42e98
MD5 e85c9b3334286a089bbeebb2958f9f3b
BLAKE2b-256 fb0b46aecc75e9e389ae3a355261c7759995a6c726e10f2ca01c22ec3678ae44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.123.3-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.123.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2c740461414b2293517a55e72c8c7d82adb72b11185432faba9b3b7cf7900992
MD5 adbbaeb1f7c4fdfeee833c571442d7ef
BLAKE2b-256 219ff0a6974ac88549558fc48af53b7c39c041c12015aa5df74ebd58f57a70e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cb91b0d87e7be87b10ed0dcbf233b9eb8be5ceac899b710c7e50335707d68c36
MD5 5bee745395347c17dbaabe6776a08dde
BLAKE2b-256 18980652fcb6e13c3677ad97686c866a8f771e53e473571c474ba8159de6c535

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b4b05fba60355abcbb8e374618558de4a035ad09d38121a861d0efae183ec36a
MD5 86ec67dc3ca522f427ced76b5ad81747
BLAKE2b-256 8b7fbf8521c0a033b89c3dad96e97e06b5c456f1f7d1c927c1d631ebe6d33531

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a621bd9f196fe474cc4085a560ce5b2244b5ce05934f95f084b489bf808ec71e
MD5 db3f8913d3ee5c09879802113fc60a60
BLAKE2b-256 500e40021a2f958d7f5f7f2b67405b34bd0188ecb7926bc46e3580abe615971d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.123.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0d1f05f7e4b4264e237423c8fcead82b47d5e3f04e2c9f74a6da9959d7b094cc
MD5 d375d6acd4c35d9776e90600464cb771
BLAKE2b-256 84435e391f1e52810a253b498ffeacfc9840589568c43b87d20eab306be82063

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