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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.113.19-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.19-cp313-cp313-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.113.19-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.19-cp312-cp312-manylinux_2_28_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.113.19-cp311-cp311-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.113.19-cp311-cp311-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.113.19-cp311-cp311-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.113.19-cp310-cp310-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.113.19-cp310-cp310-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.113.19-cp310-cp310-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.113.19-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.19.tar.gz.

File metadata

  • Download URL: chalkpy-2.113.19.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.19.tar.gz
Algorithm Hash digest
SHA256 65b91666c36907a0133c2df5b793d2c8d65b406b24ef3cfbc13ff5704f8b9c86
MD5 063c503ee4cd7af3b3101e01047e085c
BLAKE2b-256 ce9be0725070567dc51caff99d81f8cf0e572b0a5eb4ebf761e0429d7cc76f92

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.19-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.19-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0ce4d90ceaa58ddfc2f27fed8529444d186e26f3f199057be83e48f7dca5801c
MD5 944a536114005bad5dcc4fcbbaf129fb
BLAKE2b-256 c92f2889c1e1dbd0f829517975fa6bcbed78c3233e8f96d835d0b60fc93d51bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c34a498c1bcfde4b9fcb0aae186168c0bcd63c728815eebaa8e29a1e96d9a741
MD5 35ad98dce1ca3d7f7db078b401855593
BLAKE2b-256 9499b82c96582a62495b3d0d483b49652543fbb69c6bb23021af1234b4365b28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 295daa64fa5ca2814ace5e0b7ab36103c791e3f76b660b8f2e379d124d91b3e5
MD5 37590709fa28a2bb60dda7c3886b9172
BLAKE2b-256 a56439886f7674034166dc814716436dbddea3488ae0153d2114efdaf167e899

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18dd5cec8e41e02207800d952db892af9302ff8716c4fdda8cd70a670a172a46
MD5 ba4bc3460f0106da6b868f88b155c542
BLAKE2b-256 40e29e5d6eed939bdb7f9a75936fdf06e2199ff61e2834aef34285464b299deb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b18be34383c94a17196809c1ad3376e5c26d045aa1acfc6d2eb0618e78577e18
MD5 2761b350f11a45b708f7d044bb2b4ed8
BLAKE2b-256 4d29165381f376bbf8e26385e6f30b6646caa9cbfe76665b5e9145e2172ea017

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.19-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.19-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2924290726677bfae3bb0adfd47369c930040088933ee6e38a28be97e00655ce
MD5 47f9ddcd19c738a05fe3dc7b83ff8455
BLAKE2b-256 b59196c4e19803e205098ddb6b0ef428cb4988c8376816efb0ebba4276d4d1ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a23aa253143e2edc7cfee14f79e3dc3dd2832e6ebb81083cd6645b0574126774
MD5 ca0c2d1a2c51a818604c3367c7431b36
BLAKE2b-256 5d2dfc3334bc4fb28618628f3316672cd858b6475f7a0afa59a13a76a5cd80af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 75bc3762b6a78f9b07bbc19be3103af01c5fc8505c00af41e3167fc4ef2103f2
MD5 8b55682e6bc685585bc0f3e8c92d7905
BLAKE2b-256 2cd74a2bc1fc157d5a244aa9dda590b1b56a61d5749601dec8259c852619da46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0889ac7124050c323f05fb010da3188a6ea785806e2599055ab0447b59a677e
MD5 c7c228ca0e4fd03e993f0971db097217
BLAKE2b-256 193abe0441fe0477985d16b6829902f2f2324c4c5a0b272b0ad99f5e491edc1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fc8b8c943938fdf62af5b5f9f64e359d7865b76d24fd9a1637e4dedad6f9b498
MD5 387e254bad8f3b14836dc362462de51d
BLAKE2b-256 0acfab8acf9baf8f1c217455dec08246761402b9fb23014ee3c10ec2fa024786

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.19-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.19-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bc1d6cbd358787dd2e230387ef9e0a752ac80531708da113ac556ba150310ab7
MD5 acb50a05274cb295101db49df0fa98dc
BLAKE2b-256 1e057378b8a955ac3b28e251ee3db0a113db0a011412cbe9c5458b7b864e704c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a89551276f959a5963dfc7b21eb1c784ebb3acd6a090662fdd08eaa2e3362cdb
MD5 d767d225230af1ce3daaf77cc693b495
BLAKE2b-256 83e0481adc3b20cb9585f1e539fbe4ca5d786fdbfc823e3a44bb1b3b988e1d92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9b2c6c190812534361b86b9ddf64293aa18f9887110db6bd535eead142c3c2c0
MD5 eda401a689e576d9c4564d292200b0e8
BLAKE2b-256 5b6ac02c786016c5569e5fcdf55813181b35c2c87589e235f9bc9dac6641b318

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26f1d7803d108f6806e432985e66ee0b25ef25b082c3af9199c90208d00258a8
MD5 29859630e372410822d4a9488b33db1f
BLAKE2b-256 629c49f14ce416f7a1a3f52184311f32627833e1464f9a7674638c14b1990fb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 68cf41b58fb8b65a4e32478ef19f09f199c040e8ea7b4b9d09701506de6b4ba8
MD5 fb76f02d2e00849b4d31f59e427d4b83
BLAKE2b-256 748f7eca6d18485c21b81dd58a9a8722bd2e5dad4cda62b49532158d3b81c5d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.113.19-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.19-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3f609cfcd95b52cf2ae5cc256c85985332861a31e984b589f8d3b2c4f2af3149
MD5 afe04a6e7b6295ee7103bdad4214c214
BLAKE2b-256 8fea17955569965a938e89f46e59d46d815127756d1b596173ef18fa9a1cb614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4cdc960f94ac88876ad9e32083d4334215bfa40aaadb1e0ae509fafa503f4d9b
MD5 73237e6cc239d72d727d2b4053e5b894
BLAKE2b-256 405bb0ed6d8882e235b9f5410f86d47b7a1beafaed3632b4a7e372f0eb13db0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5a4bde7fea452f8c5f9149df2a603d02eb7b250deed840417b3d087fae8bed70
MD5 31d710818ec55d2a0beea45bc644601d
BLAKE2b-256 70950120d2ca335e3e9f1a298842a57ede08de4f7bf30c0cc02bf72e2699d9c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abde1c90a303e2f84d546a0134664cfeb197980cc3919cbb5c17c2efb0570251
MD5 101cc476f9a601ef3c6d83cf67be9be1
BLAKE2b-256 799cda75cfb25a527fa2c75581d75b1547d6f1e172d1da078efe5e289fb51df9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.113.19-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f3dc77ba3932f0c5cffaf2278d39c6dc20fe1cc4c647b6ebffa17ab248c374da
MD5 b23b2720a52fd85b77112362395f893e
BLAKE2b-256 73984b2b1fad6ff44e943c4697221ee7255eec1a10786043ea37e5873b7a30d0

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