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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.110.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.110.5.tar.gz.

File metadata

  • Download URL: chalkpy-2.110.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.110.5.tar.gz
Algorithm Hash digest
SHA256 6cb68d5d948cbb80ee9793708b280ff3312839592551840762d7f54cc0146c76
MD5 dcbf42be028e2566c0cd3a1c519b2dff
BLAKE2b-256 daa27635aad0221c2b9d8a1674311175c307f0aa5c4172d50c636b8ce7620a97

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.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.110.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 72f12c34f82f4a1dd31ea216e8b6efc559e5fc6115906de126e1dde403716a1c
MD5 c9e816a43232a2b10a22cdab566e5f77
BLAKE2b-256 f13b88d2150cc26f101ce2840b6a48722043d8e71b10fddbcfb770c95500935c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae3379db8deb506aa59a9afcb1b989f84a0e9f40f7857603745ea74cba654030
MD5 7a0b12f83e23e0bd53f5b7c1a77cb0a5
BLAKE2b-256 fb6d2e50f6a1b6eabc81b02ad4a52d77a2060517cb1b22d7a1a542c445b85620

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d91c5a055849b31c4eff794319fb5269b669a314dff62543d889493fe31d71b9
MD5 9b4385c31ebae2f38e002b0298dd1b12
BLAKE2b-256 3330dec9a4ebf4da09bab5dc2e8bbb05e3e92af69968a085977e98945ae9e379

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20fad30fe943f6203983d98b997e7700e7071fa56059bd6770816ce534299653
MD5 9eccee6f3424984cd37ea3f792b80061
BLAKE2b-256 55aee5965c96a89e825c9dc649c06badb84ccf697505a967c5562e0203c34ac5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e99a9a2a1030966e812557cc3748cf608d1c07b381af248daa6f14383ef92911
MD5 0081b2a3a14ef5ef87b0e1895e6f2a14
BLAKE2b-256 8f7df318df447dc5c57ba1eb950b124375bc889740c86f1c83f4a2b6748c14b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.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.110.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 74176bbf370c014e26ea11b4eb0381e947ac58bdbafa3f209f2452e66fe7aa17
MD5 bcc914773cd572058a9b1aba256b634b
BLAKE2b-256 b763a342aeb19b462f0268b9af1f23aacd22209a2dd69bc469902ce4464e5a3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cae78ceb03564bd37af8682b4596d7df3801a0ec97eff57070b26a8d585f2193
MD5 84db736631a6f3c63d8cfae178b810fd
BLAKE2b-256 fe84b24337aae69e6f528455d15b1d8136741c81cbfbef46e7602a1da6d09729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 83e8e0752870ee0ac4471a458ac3179791b9f8cd52b51760612c11a6d38165b4
MD5 98587550ed8f4851aef033e01e284deb
BLAKE2b-256 54d6d50122e235ad5d4ddce4ccc5cdce8ab6403ddaad41cc55ae5ce0532cf51d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b13d2a2d1670c8a63a29e8caa05c42517adab4275ab0ba50a1549c3eac78b16a
MD5 86c18f46becab2c4bf28ed34c832f10f
BLAKE2b-256 57a6510cea0bd5d42b6a0f814923789a1d372f2175ad2624b16838fda605ff3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8843e56e82be21d4937a9214a832993cb7ecfbccad5943e398f03fa6490058dc
MD5 0824c4e7149d35f918609d3508f387ad
BLAKE2b-256 3e0acdfa22b5cee6e6fb8a5ab50c4dd0358f29be48e0dddd39dfe28ef9070c4f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.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.110.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7f4cb569a5a93a9190dabefd69e4d6f58ac3953cae9affc05a9f5ea1b1fae195
MD5 08d1a215b7cd2d451312c0924e8d9bec
BLAKE2b-256 839d10ffa186c3a64c92b80764b535b2985453b8a6ef7b36e1ad766575ec6ef4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2fc13ef91fbd982b8ab9eef2e0418c41d6652b3bb675a2cc7aa750765f0a9f46
MD5 8775e21d9652fb8c72862c03c3e7a5c8
BLAKE2b-256 316fbc23e310fc038c65024a3f079539cbb44ad9d904dfcc574eabb6809979f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1bdd1f50166d6af6c89ae8337d4bff965db3b58e6e7fcdc8e5525fe80d815403
MD5 5d4266a59be2d7e91597fd1df2ad879a
BLAKE2b-256 5dcba839d870fe1eafb4861e4cfec8a812e739d4ff35e5ac6f0b9b2733d3bcc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 879e873199872856f545c0f4dae83e0b5eebb8416ea5c95b8912fda37c6d0f0e
MD5 7192a6575e80e7258415360b9bfd36ac
BLAKE2b-256 8c55992690db70232a0f825d6b775d881518120869099b7a0716e6625b3ed358

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8f107a3877484c95a3057009b0e2bae0adf1e3cb09615e48ec3f54df7ce85207
MD5 be15befc4f75feccafd4788c5f4f775a
BLAKE2b-256 259f20f0ec7a89db844fd023570a445291b028bbef81ec5f8231b2c63412cb09

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.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.110.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fc69d990647b6cad04765c49252134ca73dc7675c80fea98001c3c0358565987
MD5 1e8b55678c73b034ed372fc1fc914659
BLAKE2b-256 8161589b2f3dba4288b96907f372c022e2518d90374a19ededcb869b0194f4e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 35f79ea20f08fe77b8be0ea03bd53ef120088766f0166a4e5e9073e5f1ea40a7
MD5 1cd220a396b0a05065934e3487b89321
BLAKE2b-256 d4c740ae5ad9f31229afa3f5a6d4c0efaacf95f5e0436558f1c837976958ae72

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d977f473bac240358f74e65d6b70a02bf76bd284c1ace13d135cf44139adc791
MD5 e0b43c21fe21c4950648d4bf7072d1ba
BLAKE2b-256 03f82b0557ee2334a2c290f02f22711b2f788628f780c04a1d71935abbb7d94d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa3662758b2955720f6f21ff7773efd7efb03602d5c0b88fa3507c3c04a35282
MD5 418785d88ce68703646a4516c2b5f493
BLAKE2b-256 0c5b654fce911739a7139cbb705f323e047263e80758618800f10d425b841dd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cfbf33e81021797cd0daf58cadd40a4182197f8f87f586d978cf47879664144f
MD5 9115852af6b0f7e8c0e357996758a812
BLAKE2b-256 153dd026ee607685c3deec5904cb321552ce5b2a5b72797924b337e7dd951c4e

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