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.118.6.tar.gz (1.6 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.118.6-cp313-cp313-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.13Windows x86-64

chalkpy-2.118.6-cp313-cp313-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

chalkpy-2.118.6-cp313-cp313-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

chalkpy-2.118.6-cp313-cp313-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

chalkpy-2.118.6-cp312-cp312-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.12Windows x86-64

chalkpy-2.118.6-cp312-cp312-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

chalkpy-2.118.6-cp312-cp312-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

chalkpy-2.118.6-cp312-cp312-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.118.6-cp311-cp311-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.118.6-cp311-cp311-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.118.6-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chalkpy-2.118.6-cp311-cp311-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.118.6-cp310-cp310-win_amd64.whl (3.5 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.118.6-cp310-cp310-manylinux_2_28_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.118.6-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.118.6-cp310-cp310-macosx_10_13_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

File details

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

File metadata

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

File hashes

Hashes for chalkpy-2.118.6.tar.gz
Algorithm Hash digest
SHA256 231feac72d4423dd8ed7c900f7be163e157ae48f691b8e19dcacd4b3ad944b40
MD5 44fd1e495db6fb3f3e1b15291f0f98f4
BLAKE2b-256 0529107b68c992d01fa020dcad6fb8890bff7eaac0cf93674012f1e49843700d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7043da2c3251c5aaa96402928b90969ae4a6e603fb98a3e02d91947fbb8bb13a
MD5 15297eb9205032c5e2def627983c5b8e
BLAKE2b-256 9fff8fc33ff42a071bce922cb1c74a983cfe373a832185978f68c6c521f87969

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 371a2359c782f4bc77fa66427a408b7b6e0998fa6f30ec4fe193eb981623fada
MD5 31e5cc7dee9ee809df670dc6964844f8
BLAKE2b-256 864b886686c820ac24f2b8d82ae3176acc222af779f1ce4a6501915180c15958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ecc9e85e783dc41412bb8e7e6e97e31fe3401497a0689c89d21b0044916c5ee7
MD5 9ea60e80ad7ced03dd56c4efd9de5a2d
BLAKE2b-256 c162bc50c63c5daa05711e8727cef9656dbca22b3604438b5a1ab37cb83b3816

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4a7a9d4506c6d87d705010b904e754519534fa760c19b4aaaf28742e406ba0d
MD5 766eb0c2f8e2c0a7134cdc6ef65d9819
BLAKE2b-256 2f2afeb160aaa18f637073a7d7cb162c628794dbc10350f07e57412dfbb10689

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 300dcbe77d28ea07868d362ff69b443559a704c3ac5e70f68b02a8e2a9aaeab6
MD5 64c8785b5671ed5c53f87b17daa4da47
BLAKE2b-256 10765bbf62f414de3c8e3675b890fce87d74adb427ae039f63c38138f74517e3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 838a50dec595afda3414c96fc18003b53c6f27a58f80eaed709b8640bf709b16
MD5 e7facbcd92cc1be1ad51419234f3ce7d
BLAKE2b-256 12c3d2e5dda1d788871b8a28dc20648de55ec89d007368ca6c42867bbf137229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c122d3e7c943f2fa86a20a26d7ed0dfbbc0f7d21c57a3379aa9d054b4100106d
MD5 17fdb4200b8536d44999a9599e90afea
BLAKE2b-256 844d6fbc652e77823e971e103a9f62bf9a2a6cab44d7bee602cbf9579d141eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 869ba2296149dfa7a7d2faaa135472f80defdb1f027bf63cb5250668969df8b8
MD5 541e4375ce41cf8fe43f9f6ad4566db3
BLAKE2b-256 2dc5ffb5e75f2db7db98e9f1a977d01542494c7e47fd861117ffd6149abd71c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e343116d2e33a64f880dcb8193dfed65c09832fac579f6839084bdc32486bb4
MD5 acb4340847f685a102274918a82bc058
BLAKE2b-256 d959c725f546ccd5c4df16d6fabb7602092f0afc157bad54c4d29737c2f8f087

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b7ebef388305c8ecb2c2c1432c1bb7dbf5f4fdd93a3e9fad230e57c7d4beca0a
MD5 40281acb49f5d1fa4434116e7110ea8c
BLAKE2b-256 dfae1fc299e24ba5ade705e20c6e694afb79f6d121f23b0c61a4957a8009010c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4573d5e66a45ba24a288984f87e01e7c76d8bc65c037b7b0a567153d2faada8f
MD5 05bb962e6ce81a32a217c1b12f7066d4
BLAKE2b-256 5dbdfa0b868654c50e08ccbe414d50af5e983f8eff5d28015118fe18edd80510

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d66e8adea8440be08b1f1daf3b3964b15c187a9c60bca05e2c211fc67fad2b6f
MD5 bf4c2af5c18b08ddc985874ebfb009a2
BLAKE2b-256 a1515ab3b3970a39f2165595d083665f88efcf8fd052303b6067653434c7f3ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d6806bed6b5f61b944ed302b9ce38a84bb349dfa67306647c36985add2ce7888
MD5 512df3896f8cd33e1e5426d4f2276a73
BLAKE2b-256 990f7ddb2675ee3715afc1e37f37599a6b0274eaf9f93eb3ad5bd0824dc4872e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5c04594adbe28cecbbbfd93978df3630bcf25af9715ce84fd43a948acc4f5d5
MD5 d1fc81956e8631e7ce68eff10e970697
BLAKE2b-256 b02248a19ab87105a8973962f411a270fb122647724a6076fba237d0de3fb496

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6ba769dd321a86b0f4f93122a5c033b80339445ca242397a8b3e8d021e50e526
MD5 7eaf4439b91c4d27638d72a050bbe644
BLAKE2b-256 3c37eb0f0da60fc06e8722fc2c27cb9ee93e549683ff4799e1ee23b02723999c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.5 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.118.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b24a39309ee12cee8e6e2630b78b93c1f790365a59c652e792c11adbf5421bf7
MD5 7b9be7b9be6ed280df37fdc2ade5a207
BLAKE2b-256 41a8fbba511110649aef7bafa77e7cad4e3f0ad3a747e77553b50e7675e0f4aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d6244af047a5d82fc88ab760fad3fb3367fda2c3f6dcf47d854483341b4f5f7
MD5 241786b56af586c1c2f25303b347bdc2
BLAKE2b-256 b8e1363182b39e3ac74977f34b241d45aef0c29c5f8a9ffffecd09831a8f9f6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 66909c97abb5a9c2da6599dbaa033d13beabb34ef636114cc30f8a8ae2995d0e
MD5 b2983b0e938e286986b7f8cbd2095e0b
BLAKE2b-256 d2cafbda7aaa7f86d14a5282411ee93dcb194e6ae23d37cc46f55015be3d6f37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0942200719884fba2eaf0f7116fa51ea9c472096e2d0d412f623fe81bd6260a2
MD5 8bdbfe47faee6aff63986350ddd0a64f
BLAKE2b-256 41b6acfa8fdd09ef0e5a46fb5a0fe7c595cc7632a0a659fadd842ee2539d22ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.6-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8a8f1493cb91ab6137956b1282403501961a5480f13107f0be5a416b64f7e2b9
MD5 3fa20bba3066404ea42152e7c2346196
BLAKE2b-256 85f2c9400150b452041ebd44470cac86973fff42b113ccc9877801047d7aa54e

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