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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.111.4-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.4.tar.gz.

File metadata

  • Download URL: chalkpy-2.111.4.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.4.tar.gz
Algorithm Hash digest
SHA256 16824c947b219e58b0f6f0caf136fbd38b234fce1cd79d9d880f0c156464ab7b
MD5 5b45c906ccafd9c5c3ed38d5e9e6fc46
BLAKE2b-256 4e8c6f37c9641a7c9b0e91b314a16d3d092fb80ddc0caeda0aaf77bdf9089ceb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 851aaef5c244a58301e29946ee27aac8167d57d323bdb82501414886d2051cf0
MD5 9c31809be74cc78dce71791224d1cbf5
BLAKE2b-256 c42e6e37225ca4f3f409b9d2e4f5218566e63edbae89284814eb9ac5fcef3d50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f24b9c20380ddc9d1343a5f775727a31d2ca6366618b23e7cf1008d5f1e24b6
MD5 175b362c366b8b6aa210f69163583992
BLAKE2b-256 ff06fc10090b13889a8c4f60f0564e6dfb8c9b6324c925ed17ed9dd569114729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 c6cb8e4af5a3faf109c90fd3967236ff3d24c8a7502b926be959d428eb729a67
MD5 020bb17939985ca9a274b56721b250e9
BLAKE2b-256 96cc1f00f75bb95c556aab1e3c4508c2bde38bce89faf66d75565f3aa4bf2428

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 12a2dfe91b5e05567319ea076331c6b87c8fc0a25b81bbf9363562a9ba3b6c13
MD5 34117247251998957b64a0f1a653c6da
BLAKE2b-256 bf8eaae8fd97b264e9029bd60287d29f47b0debc9568170422e41947b559cedf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3e80dc9a2238ed6e4d605b7dee915a6b10a0e5be70c6f0382f6fc8784d17399f
MD5 bf01240a408629e721d78e9fa34805cf
BLAKE2b-256 0859ca545af174a3bd4fa8824e91a1225ed5c83fa8e4f1dbab410c83b9102d72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 088a14e78d22e96eed10dfad4588d89d8a7860274ec2ceb6825ec65cef620701
MD5 e0180fce448a0491c7289827220753a7
BLAKE2b-256 b2b3ba35419c52627b89ce9171d59b64cde83443cd082d3ed8da0b69ae81491c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d98750e1ddc11a1b87277b7097e252c392cd652c0365e2754cfc4574991c050
MD5 3ee5caf0e2feadb022a88c88c6858b92
BLAKE2b-256 a2246f5213ffae70c27c1da2c8e10c0b7afc35e8c512d1c912e189c75632a8ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 97e5ffb095b61361cc07f7b82c7d4b3e1ad5715feadf106d89b02f0f5c31a6f5
MD5 559350f32754f8b000681fc9d4d2d6bc
BLAKE2b-256 a8a5ef1918ab6512be1efb6f2a663a915608df9ebb4884c7ce3c6b68c505897d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 73c234b168816638f5599130e0b5fad0b97919c9fd22f6be3f2132ab3a2f659b
MD5 3b1c6755c51d0eb7ad00478af07ec809
BLAKE2b-256 3cf10aa803ddc7c3f8297a239d311621a714556867b5a50af9b8d4ba5eb53498

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 702a33baa079c24acaaabeafc2f7481783cbd87d1684119eaa220cadc50cc84a
MD5 9d7fad7fd76056fea8f0370ddc9239a0
BLAKE2b-256 1901cb818b49b3f83e5375c01db1bf92facb37192bd34b8abeccd711c551c550

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.4-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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ede0ffaf1c489339c9f36a04a6c00f311193d3e2b320f14cf26ed566174a3b9f
MD5 481b6e682677b05cbb3ff4d68680caa8
BLAKE2b-256 83265df0e0e7604b82c03a0c1997f7a2fd87162625f07725439558f44037ad2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edc469d1533b4e8e3c52f9e5b75461a1db1e6570320fdea052e47f5b41d94b15
MD5 13c7490eb9c4c1cfbef25bd9e5e028ce
BLAKE2b-256 c14bbdb70724dafe0d29d78f6bb05561804f732a87ce25a78e8d9917ba8add73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2e50febf2226a2238688af5d53493fe630e2bea418ad3db56f79f75f9dba2366
MD5 85b57d87e82ed57769795e7ed3ebe306
BLAKE2b-256 dad08dedaa045ca29b9ec38e6730d17b3027c3c2d30d9302bfa75210f670e93f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d893d865448132c4e56debec7e88b4505c9ccf5714247ec8c9587c4b5aa536ee
MD5 d7776538a081292e6a7c59068a8e71a3
BLAKE2b-256 145abfd9379e8b833a6bdf32dbf3721a8c7265e2f88dc31baa6dd69bf2d01548

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f6a6d2ee94bf6b4c9bda3f7326c8a60e11565acb54fcbe4780cb4b154e13d74d
MD5 e53d97458290cd1146dd8dd08741ee67
BLAKE2b-256 9d273bed54e6a305eefe23da91404563e61a8addaa240f52f8f59058da6a1ec1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.111.4-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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 fa1be73e3fd0a2c672541b7a06ed46e0aa9b660989255edeb0038e45b8cadc28
MD5 5a754ad09c55e53daf930a1ae2fd5441
BLAKE2b-256 c790301514ac7b55c6efaeb284cff6454eceaec4515092f716314a0961d7110b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 57b4c5d38622d6d8ad96bfb2c99815c652a3d511f3a69846ed535fe613193f41
MD5 8623aab72f7b0b3e9791f936ea7a70c3
BLAKE2b-256 89775c6214e2c2e2ad5b3e4a177526c4503d9ef712e9ce2c2ff2f434d0b3187c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 da550bfa357feb894f1f74788e4074872d7642e98b762d5a4a2497dd71b1ae74
MD5 a19281461529e011a43c6d758856101c
BLAKE2b-256 295e0d03ced705c064faa5a0da05d8c33c19ae2f1c5b4d32d52d10aed1fd22bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d7b58c3f290a19ae98b7c1f0712b5740e47ca0c5f2f9f7779366ba43d793c86
MD5 2e9abc475cd60764f0dfd1abd84f5a8b
BLAKE2b-256 3eee463679cca1ec96c26ebc6fe1567ec53ecf28834667e291d81d2ffcbd2055

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.111.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 5a39fa9c0fb5a5c00a0560a7fb586c3f5899049e5bc06ee026abb7a4d7a2f7ea
MD5 d03c74f4c578830f2970ebc890347e49
BLAKE2b-256 99067dd14412a2357c2eff5c819dc6d510ba2bd3d6db900f73879a58f46c8adc

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