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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.115.4-cp313-cp313-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.115.4-cp313-cp313-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.115.4-cp313-cp313-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.115.4-cp313-cp313-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.115.4-cp312-cp312-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.115.4-cp312-cp312-manylinux_2_28_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.115.4-cp312-cp312-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.115.4-cp312-cp312-macosx_11_0_arm64.whl (3.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.115.4-cp312-cp312-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.115.4-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.115.4-cp311-cp311-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.115.4-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.115.4-cp310-cp310-macosx_10_13_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: chalkpy-2.115.4.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.115.4.tar.gz
Algorithm Hash digest
SHA256 de13899b85eaa6bd74a15aab5d8925888e06eeb74f36e402fb094ee14cea9fe9
MD5 5446e9dafb32267d4a8170f9f0a25451
BLAKE2b-256 13921c9c9b02d2e2d199c8384fd8742fd83c96d9e8a040a34b6e2ceba04a9289

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ddfc272cd88afb89891cf9e4611ae1e317c18caa3ef57db046ccc5d5a5d56bbb
MD5 89644e9d1bd5860cc90c8ab90f7d6e22
BLAKE2b-256 67399879c6631367d7001dd3abd7e1eee57bb66f382e1d6416c5f2f9876b420e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eec3db7c6365c9b7610295b8fefdb725d4be3de0b5bc7f83b547a802fa9a8fdf
MD5 a4d3ce72469453c0811dd4caa36913aa
BLAKE2b-256 98c6b0f615a77061d7bb383e411e65b9b559428862db07d843d5458b1cf94425

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 f236ad8b9e530c7cb2b9e8c046cfa412cacd1917a11086d7b0c026f241d9eba4
MD5 54430d05c03aaac65573743afa5a02de
BLAKE2b-256 787250174d14ec0cb87caa6f928a224ba6a48a1450b7425c68e04c4c888bcc8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de4a8d9d7faf9fe9be28cce2784261473e83a2ea6390b43b6f97b987cbafbc2a
MD5 49b0d066ea40fffb85fc3daef908a4de
BLAKE2b-256 72ada80b24dc23e513f2f6338e010a46e5a368cc389ce16488634fdfadf67643

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0ec707b492fe46ecc6ddc6c87c149a2a1812ba908da9b2a534b91076fbc037bd
MD5 4350e5747369a73fbbec367cd1ce4930
BLAKE2b-256 46aba2ce97a489ae88271e888492197fbaf577767d4552d9ad11e0cdacef0233

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.4 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.115.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3a016a30ff3ce3718ba39fdcea71c46f3bfde7a3929d02327f510d80079a19b5
MD5 c3247a16a36c2f79e64182e4add22b44
BLAKE2b-256 8270a06244e75ae9280a051273cf2f346ad0b3aeb0604b000c202556f903bb85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 89773c040cfe07c0b09706aab1f0857215c033d29537198cde50df7954ab5e5c
MD5 ed8f1be81b04abf751bb7505d45adc3e
BLAKE2b-256 8ae9880622b8ccd69860ce55175d654fe721187203e419b1910b6520d152df39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5ffb093ef000443c6055a345e53703e290ecb02dae07532f6c59758348293e78
MD5 814cc628a23933e58ad42aaf0f94fd7c
BLAKE2b-256 e8f61f02bf7a0724e79b5783a455a6cb95513b3cf3070cbc7eff453c72692710

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 729bf94070e409694ee0e79d9b3b1086ec47a88614bc0776b85b5ffc8da3c51d
MD5 75da74466120d73ab4c5875a47b088a7
BLAKE2b-256 0938fc919940ca29499a2fff6839361cc00df180c21081cb039f41a89c2ef471

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 724b2458576ec77fcb9d4ae3a7c01293a7f755dfbca3adf70f62f474262b0d6c
MD5 2e48ec3e787ac9b3211f982860280d01
BLAKE2b-256 3fed0b946c8d3953be08dc434f9c8285b70bcf86c8ce6fe4681841dd81a7df27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.4-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.115.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e156816ed6e26b575805fa1efef69dfbf2e548672d122ab3838b5ae473ab676f
MD5 7809d4638325a8f5cbb9e428e50270fe
BLAKE2b-256 f9a95e118ca989aa17f9a1c3a0dd6e65bec4e63cb65495b2f48a7de85c12acc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85d3d3f90ff9a00981836e70c241d013d494aaba53b6731a167125d2bb4916cc
MD5 ed7e59c1cbc33c668b0171b80c30d5f7
BLAKE2b-256 0f6eec6fe9b4664ef5d4a21e23d38091ef72cb638ef63e8fdb167d30bb126f05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7189daa2c7d45ac6f3de1533b3c350cf5068b6aee63553affdbbf1438a258281
MD5 686ada9c1e94dfcb6d3184f843412292
BLAKE2b-256 b7e3226c964095585dc58ebe7e6702c64c23758609221eb766ceb4d2a4dec6d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3ba20b272e28b308276dcccfa9ce6fc710939ea9a7bbbebed9e391bfdd8b29d5
MD5 7cc100a44a9fe9b57bff52f192c0f258
BLAKE2b-256 3549cb1ab0bcb0c0684f5e33c5170d7f0630c679773246d5dfdaa123c2ccdc2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6b9f55b1e12c01edd97c55fae7be4f21ee088a13a36fceb71b5babe318117f99
MD5 2e7f3a2b00a2294d3167b25aa4589794
BLAKE2b-256 96580d82430c2c420f6a692b259f4bfb5a660c4d957866e79ce8db464d54a35c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.115.4-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.115.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e31b5303e89e2827fceb7bd978c7040cd47a3c2b5db8b8bc44359ccd80724930
MD5 11f6734c6081aa6dc2c3ad50ace2ac89
BLAKE2b-256 2b831693fc13b223a0215c195155d1d205c07046377a8f28315b0dbea379f5fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ffd4066b2ad4c6bc98029a0ede14207d9322f10679b66a1766a72197ed4daae0
MD5 c781769ff98a61d61ba1113660969c3f
BLAKE2b-256 4a3f806c6c5f7e4a87e6e31aaa7f29646a52448022435dc2bec46098ae201a20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 002fba0dee3f9cf98c7f3973820c0a40fb4083246193c5e76258daf8617f2855
MD5 7dd70408af69e91332d1dee83271158b
BLAKE2b-256 10501727a10a0fe8c8f7e781840c054fd18f551aaec55491801a945bb41a1aa2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9aa4709b6501ef4ac6d404fd5936442d8e6003058cbc59ca019bb856c9f5f0f8
MD5 b91cb44ff90cf2abf584a8fb584a50e4
BLAKE2b-256 b45f3fb587db8805f6ff4f9f35d20a66b0e69f4ebcc9ecd99abccab1c9b5922f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.115.4-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 87e46736287b24d10d844f5f7127e0d38c67e4b19162d5a9d885186b6078d137
MD5 4f4e68af61f83bd363fac3b9de50679b
BLAKE2b-256 a72d0f236c8ba21b7db971addcb8d782d477dbaa6bd692a148edc2908bdaf58f

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