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.113.13.tar.gz (1.4 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.113.13-cp313-cp313-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.13-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.113.13-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.113.13-cp313-cp313-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.113.13-cp313-cp313-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.113.13-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.13-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.113.13-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.113.13-cp312-cp312-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.113.13-cp312-cp312-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.113.13-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.13-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.113.13-cp311-cp311-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.113.13-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.113.13-cp311-cp311-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.113.13-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.13-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.113.13-cp310-cp310-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.113.13-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.13-cp310-cp310-macosx_10_13_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

Details for the file chalkpy-2.113.13.tar.gz.

File metadata

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

File hashes

Hashes for chalkpy-2.113.13.tar.gz
Algorithm Hash digest
SHA256 63eb344971e406c0acdf78275baa4d7c73d6eda2a96b69e736b01ac80a9b8fb2
MD5 35b360f557ac2b84e049a07c21d2f6a9
BLAKE2b-256 feebe0a1fe8285a9c408659571a43196ee4a1c2806af4754ee3f96197be77a77

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.13-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3c09e6a0d83ca0fbed429bc2e485367601b1d3815c09b2c6d0b4036fbf5b4798
MD5 9719999c07d7a4be6a8df21eea6e400e
BLAKE2b-256 116d63e9b0e7eb1b010f3bc21cc3c1921e8c4c16fc71ec38e7cccbc1ac75cae6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e47608ba6f3772780b20cf5f00632882cacaa572f4e5d3ec5beb5054e2ff47d
MD5 06ef2d862660c03f31b75f73870e9e85
BLAKE2b-256 75a953d6954eb7c166310e97e8de477d72b030b9469d119ac45413a1caa25bfc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 63af2c040f64726aea264a329a01330467234c9733c7ff1ddd7e2c630ca3c0df
MD5 d283b05eaaaf0da0f27373c68f67d4e3
BLAKE2b-256 5f420f4ae9546c21b9c32977375c2e449cd998a3d8e5117cf1f2b91ee414ab53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32f6e13bee452cac3bf46ec8cc46b5197e5aa4054ea36b8e5ac8ebe45c764bd4
MD5 148f7f4a365867b8eca7ce7f4f56b44c
BLAKE2b-256 030b4b8e2f1b310b0afbec215daa12a41e681d6772d0a05d2ded4e7bad5de4ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 69ab3d89ae50f507e07edc28a0a8af083719f15835fc91cfc4ab2808f7d2aa22
MD5 358b90f8ce035bcb0e58bff7c5facb1b
BLAKE2b-256 2da5799c3d0c00ecfa7f9e750e32c8c0d4515b62c936cf6ba01f59f6c93e98a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.13-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.13-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 cc3e1d2c0465550bea5c120589493bf350785165cc6530cc517e9b2b940ba217
MD5 bd64d5df7545cd8426e46d15bb29b932
BLAKE2b-256 baf0416749d5e7d3fbb4e13df0678eac908de887680fd2482960c9e70dae7d2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8a8477566949f20b140c05c177ce7b6ebdbd2ec6137098a06a8f25e29daad6e9
MD5 87c3bf8de6dcb69f8c6d0453628049d8
BLAKE2b-256 bc217175155da5050258c169291989240dd66bf455435fae5f02ac7e5cf64f24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ffd6ffd0a847dc77d4e037dfc2569e1c6f85f39d122c1635469590daf2462c7a
MD5 73a46cf4e2a45e2a63c4f8015a9db082
BLAKE2b-256 a57b696ac12e6bf08fb123cedbd7d442ff0250ff1588730860795293681aa586

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e2ad4b5e718a47d09368796327540c83b63609914ab382f9393670fc66a03e6d
MD5 625dc81c5187a9ac28d86d12eef988bf
BLAKE2b-256 c3fb721b17fd18f069a0f6356166f71c406bd4b3135b3be911d5ba4179a332d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 af41cf133b2dce2f77ebba15231999dbfeaf8591e1bb4df7ebb45057a7830983
MD5 2e2e706958fce28b2da346ee37eae48d
BLAKE2b-256 f786eef0b91545e4446fc5edd6a0d742a31c78d20adae3c5b1720afc40e5f8e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.13-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.13-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 41ace075784588f396dafb2af98f0cf6c8af1b681ad94277bf4944eae2c994c0
MD5 b1dafac57b14e5a33308295e64fd2c8d
BLAKE2b-256 e9c9b6fd0483822372e83b1e9a40b0cc859201d1e89b2d53116bfb12b54ed4df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0fe2b90744968d7255f823f4b660ddceb1f3ae2cc6e108661bb054442b845fe
MD5 24f8116574bbf0f52907be0b0f0883e4
BLAKE2b-256 76f4e2bcf223020117e20afeb8568f205bcb479b2cf9e5cf9039e8a63adff23b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a7a0a93da1926da13c88f2064ac52790052ef1d0ffc68e9fe375826aff094449
MD5 77e054aad66f181bfaf2d357b1d94111
BLAKE2b-256 99305864849250633c8a8574bcdb7857914d13edb99cbd2743c7ffc07b2cfc13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74a422fa168ccec266d212feac077e6c6de9ef899ad04b32bc6b38716ab2d277
MD5 01d0d1fee50426a76a4b35aebcdd8f57
BLAKE2b-256 038efcd9a57985cbbcbf3f675b94d338f578e348fa64cd9263627ab1d44e2774

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ddf02e49cd8f90f41b173884f85ab973a484c4dcae5a9798fd0de7566a2f126e
MD5 3b9aab9d991fcaef98376d17091e24cc
BLAKE2b-256 5be06be27881b9abc6d2e42ae6c51b5003809b1a40bb49e522785586571d0be3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.13-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.113.13-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c218cc9b5a29cd6d38c5f12510b2dd401b44a42008440be763461ff843e29e62
MD5 a8aafe2e5a2bd800ddf593300b2b4dae
BLAKE2b-256 a97889d3898e99927d942446455a665d6a9b5a55b8689f1ca8a31694b5681d95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f49052d38fc4630b931e8681b68583ac914e8a3ed2417454348cff4a6eda455f
MD5 19283a44e0c334ca72efed563ab1ce27
BLAKE2b-256 f6fd15a4db601f12bce9c893de656d83e2c3682f6ffc08f0a640cca36428eb76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f9cfb7e9aa2a0b252870ea168c8974c5426ca94f157dbf9eb18b729170190ead
MD5 d5b361806227ce94bc2b28dea6604a35
BLAKE2b-256 4851c16bf8fb92f6b982282bdf734ec32e1b666778c7b5f8aaccb0187337b307

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 138881e50f0a0fec44d1aaf7bfe535ce7353dde23612aec645ca6ea8f7d9ff38
MD5 de354df63ce71fc64e0117379460bd95
BLAKE2b-256 2998f537ac673606761e0f8764c4135a2aba5b528f01f4fc2219b5bc2d4c5daf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.13-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 cf3a295bec4915d0c85ce455ce03a279b8aae2b4393e4f04126a62a76175540d
MD5 0e559ccc224cfd08529e06f16581a859
BLAKE2b-256 de895e14a2c043a0e2a797177b6ae0b806502117296d4a58061aefff00062be4

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