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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.110.2-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.2.tar.gz.

File metadata

  • Download URL: chalkpy-2.110.2.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.2.tar.gz
Algorithm Hash digest
SHA256 38775a8aa9f79729b4e5f21371b09a7fa95875cff2093ff923bfb0113c64cafe
MD5 4623caf91642e053a0c0115599a827f6
BLAKE2b-256 5d20218c42fef5de71f209280c91c74dbc08d31d44cda73ea8c8b47ac7d02f07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.2-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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d5fad801b4e7c965d73fb94cf43cea32e62586bc5ae621bf666ec45a7e355e15
MD5 8cc08035498a6b6f521dda720e6d5456
BLAKE2b-256 23cbe2e7493ccf6a27c20c02592874d6f8f35ce6a1640302e2e1c44a7a4692d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 29f6733a90b0b59e797a16d7b2434618f61a7cfeaf2b4e363b628b66f3937e00
MD5 217e5da583ff09924a1c4a1a6fe288f5
BLAKE2b-256 94b5d6e775674d427099fe1d1affb9cc7d55b4eecaaa3a40696540f99de5e6ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3a9996472fce27b770117d85b4d329cdb3122aa40207dac379a2b872f0cc8d2a
MD5 ef3998060f74fc4bbe08017a03f1563c
BLAKE2b-256 7e5a2a11e31f25bc8b79ac95c2911cbe2759c656ee21326cf305a919835e4e07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35e1e071ba5f5e09ca3108c92731c11a5961de3ad6256962bb3c491853d3564e
MD5 4c243b31c011bb32bdf8d2622a150aeb
BLAKE2b-256 6a7e68ef6e13708e5039bce940d0ea2e754de69f69fc3bcb40a98a2a4391c50e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 04be4f7cb49dd940f54731f0afbcd0da05cd5ac6a5bafaa466608fd3e09f0eca
MD5 d7551af5d6337b4c3bd591bef15442fe
BLAKE2b-256 98a1eb2da60936abd98caf4fa71a5649cdef325ca4e3f898f6b3987e1077bf8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.2-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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8685ee8872676cfd5eb1c825e18a2eefcc0f6e890871bb59d76532eef2bcd96b
MD5 bf7d03c6617f761eb1b9fff933e141ca
BLAKE2b-256 1545f6a967ae66b53a11e5385fef3dcdd48649254711e2654aa052d40ef401aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a66029454d00e167bcf9dee54f24458e72164b3a7dff2d6a46fc5ae166dfbfe7
MD5 64481f9c6b71ae38a3aa68df1175258e
BLAKE2b-256 364c4f71e18a3f48b0c50786c72b1638d2f1fdc2cf2c63010664116ab8dbd83c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fe95c19c41b3c833f4495c2b4bdec57f2a5851efb0fe48ef1decac1cc62b1e09
MD5 76de9492565d0ddc59ae425cafd3d5f9
BLAKE2b-256 f4ea0bddf52575cfe7066ed927bd43f715b1ef4182b0324f8a5f14892a1c0bf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90e927e5c71770be90221c0b28d79a3bfb76ecb6d5d71dced5b57181128ee45d
MD5 90df6581ec907b88c2118ea910af64fe
BLAKE2b-256 347f66a94237e2d47a185a542b6acf7c4de3b30f77bf5e237731713bdcc1f7ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 34c145b65807c90f083ad63695578cda535c073d2f5719cc1ee45e172c199417
MD5 be24c56ff3b6393f1ef0d24c9d97a937
BLAKE2b-256 b2654a5e0273124ee072b3b1b133c6364f46d56713773caa6fcce7f78bf3df6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.2-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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b1ccfaf1aeae9fef63b20d6d15393225172fe7017161c32d5d6982125c3d8ed8
MD5 5a8e09f6d47466cb5e16bc028bc5cf2b
BLAKE2b-256 7f8d5666a3babd1741d6e974deb486d5d561bd15bc8cfc586f245f26f135c4bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4edefe720a86f9b91b745497c884da467a7bb7bafc4e3cd68a811d58be5f3b3d
MD5 107fff73efac9a0faf617cb31cf4abf0
BLAKE2b-256 109de449c3abfbde475c61293b6cb1d52153ecbdb1056746c033dbaf4274b436

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1ae872519d29149074b2cb5be80f3212de103c1aa167caef614374bc4c067e60
MD5 8d92b643f92764b93fa56ce5b44efe35
BLAKE2b-256 f1f2680b96dfb3d85141a98d246c147b1c3b012a3a54d19995e9cc9a52613ba8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8667dc002614a9c945e4766d2893894e6133a14178d49e296026c0866ec8676
MD5 678480857fc48bf8799023fbac9a7c1f
BLAKE2b-256 46b3345a01f88306d6582343fc6f76703bd7314bfd49439026a3088b0afaee68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 82b95c785110dedc51f9aafb4e6f23c13be04cfd0c4b3a68986e9a527f359a49
MD5 fb051ee978c2e27b22e9bab71d2743e4
BLAKE2b-256 e164dadff72bc3ff6fc59d81e38bfe7aaf436089bfb25712890503b0bc1c5239

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.110.2-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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b23ae88ac2e9a805f6f236c51361206c8cfc6d7efa5f4b2ea54cebf7de8eb968
MD5 bebcee62b5776f4a127c58b80af079e2
BLAKE2b-256 f2ca30b5ad3758c1715111c3afe6cb01ea6e428ff347c6fd29bac0409c7a0af6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 02764f4b24fdee95f473a0f6e7681015eb2f8da98d9ed2c6ae3a1ec959a9365b
MD5 34ce3e500268a5ceff5adc69b05c32dd
BLAKE2b-256 255156d8e1869562b946de98f21ec66d5df64114a560b4f4479c8516872032a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 40b7079abfac34e5afa549fe0151dc0bc1e8a9cbdd60a127de9d54b83481d18b
MD5 1ab906ccc763f40d1b13b8e997bd2a13
BLAKE2b-256 0e05db110175e3e195b575ccdc855a2c562f216cfbc772259bb93e536e13dacb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 efbc505e79c23d8a3948c1afa3d5c0d7ea0fb1b078ee7f1ece4e769375efe4e3
MD5 c671361057fbf3f7b3f74a2216231bb7
BLAKE2b-256 044fd460440c5f253c030406de72fc5ab65945d54ec8d879604f40575d038d30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.110.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0821a7661541bf4a5c0deda56adc94eb23e219bab8089e84dbe46f3adc510e10
MD5 c69720d699b23487a06043065a2b2480
BLAKE2b-256 3b5d659b37b5c27b6f4cf825f1a64e885927943bdbd804f3c085394169360470

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