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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.112.6-cp313-cp313-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

chalkpy-2.112.6-cp313-cp313-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.112.6-cp312-cp312-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

chalkpy-2.112.6-cp312-cp312-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

chalkpy-2.112.6-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

chalkpy-2.112.6-cp311-cp311-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

chalkpy-2.112.6-cp311-cp311-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

chalkpy-2.112.6-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

chalkpy-2.112.6-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

chalkpy-2.112.6-cp310-cp310-manylinux_2_28_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

chalkpy-2.112.6-cp310-cp310-manylinux_2_28_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

chalkpy-2.112.6-cp310-cp310-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

chalkpy-2.112.6-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.112.6.tar.gz.

File metadata

  • Download URL: chalkpy-2.112.6.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.112.6.tar.gz
Algorithm Hash digest
SHA256 7fac4c42f924ae1c2f8fddfe9da4c87880bca0566df81e7e404f936d3cd2d020
MD5 36d11bffd00e5a38a7a0ae2c3345cff5
BLAKE2b-256 4c90707b4e9351f36175cb526c7a4474ecaed204667ca5147a8b34bd9d674785

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.6-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.112.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 250710a4ee2d0581cfaa86d28e86d4fdfa898eb7cef2ff1f6559655cd628fc19
MD5 0a563028b5e8b6eb0f2a475905ae9882
BLAKE2b-256 8e37fc2994bf0d30eb2d0d4d63aaf417852f9d5574e28145969d8b067c89e3d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 55ceffa34e37aadcd2880904c4c0e45833c46b6713c81dc44919badbe0fdaada
MD5 267bddee472178ba10b26138fea1b9be
BLAKE2b-256 055d21941d6a478ebbf81f783334290af3572c113dda7d093146a150cfcb45f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8221313bcdb24c971dc60f05025a54ec93626f853e73bcf891496b6a7801fd0d
MD5 4e03254974b7753938896a2e5a577347
BLAKE2b-256 6e6dbf80288a9aeb361eaa1087db1e5d818b32b16e4ecd504b3883ab0bb5cce6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f18d8ff8c8362e6c4d96748296521131f4eed491064dfc0949745935f6a46a0
MD5 e32729ea87ad02b1da8af412f787be6f
BLAKE2b-256 51d18acc49c724e30431b76a5d0e983c863676982b63874d2f94550f77495d0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 60e8d080d49a5202f8f82e673b3afc576f218ec2eb1b7c453ae8f8cc99f0d117
MD5 b39d8c8dcd84187311ccc85f02d0a57d
BLAKE2b-256 b182c3d831b857310e4779e9727b73bcbf4593ccbd2aedec5777c34a1d84c872

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.6-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.112.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5caae3b77b6e599358292fda0868b3f7e2f4a3faef5e42463129cba59b06332f
MD5 3f2627838eb68f59af8fd3811c89df4d
BLAKE2b-256 a4a0144d1153365254c357ad3144df1f77efc7b3888ae7af9fdd2e6f11bd9f29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f398674f6257db0525e6ddc88b01f9f8fa75c3b6695b37a71f12adab34f0c595
MD5 99aef11a9483ae1f80108ea1dfc13b68
BLAKE2b-256 566fed24c00eb03c25f050070c01a8a593ee68c4fb31d514357ab6ec82d104ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2400193a65c3c521c6f063d34ea9c0a78e7faa813d31eda83c35a30f7bd0ab6e
MD5 453c077af753d134c31705f9e2cde9aa
BLAKE2b-256 f97aa9b69da9369df480e70e1c385779abe9b3bfc62b304f340a1d910e594a6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b30818f70bda76254d798840584d8e280bdaf771874d0684d8d3922682d4de29
MD5 1ad6722711761cea3da0cccee0aa7b13
BLAKE2b-256 dbd58bc51dad71059bc7ffc017912979c6de3ab2a8c62ff7cd3fa6a5a8c52d9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 36bab54a9f1c5144960dc69b01bbf0985eae4dc00f472936a125ecfd7f1c2592
MD5 a799cce48893963dabacdc8b122011cd
BLAKE2b-256 1a5cd3eefd704517f8260f2da98c75ce1245dad60fd63db8a90f55154d3ccaaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 df04c87999703a6b657ca26d20005d282806364af8ede5e64a30837947d3889f
MD5 31b31f4d6c41db0dc6b7a119195433ee
BLAKE2b-256 4c924cbdcaf6fe765a98399c690242689cbb621e04b73b203dfd03181bc7837c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 77695ac76edb92b0e914257b775ca49144c502d4d31828528a377ddd12409dc1
MD5 84f324780f348cfc9c3aff2761dc163e
BLAKE2b-256 c75e93ed0d98593ccdd57ab6b73d18217f15c9f22e9b242b0b9a8d052ad60e17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 351dfbf2cf8605fa36cb08b5e15d8175eefea35c5b345c1a30105629af5f2f1e
MD5 422ff648b2566d70902a6144d3186063
BLAKE2b-256 480e5deb552b813816e69bde4e16f5e6a6c29ab24705f7f3e9e492928c4d6fec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e67b65a6c9418cb199c72a3e18a5cb3d98083f9b8ce4927d8b56191377aceac2
MD5 c38a74af0e0ce9836907d5bc14b6a708
BLAKE2b-256 f6dc758023a643ce07d92d61366273e7268cab645d2e02218c755a5e21c7e567

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 be49c4b8c6253f94fe14abbe86d7df2653ceb9365b8a415eb6fadd0878079542
MD5 c47d76f9bf34f3a70fd82ebdd348911b
BLAKE2b-256 32a8b85b4871e6247ea61d8648d9fe70e6287d41812809036ccebb0cd54dbc80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.112.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.3 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.112.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f5cf0c1cc16f37cd0f67f03c0e1dde328ac35c4bf26d436dfb3618416ddcfade
MD5 1174c7d253548afa864ee109805cc8c0
BLAKE2b-256 d453706018f39f7a2864578d050ed19169c9b8efd96bf86b8f86be21115f91ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 30178a068b0f174d5c537ddffa59980b9a93e9774778dfa64fbeb6465aa2f036
MD5 5e6994f58c044b454ccbb3b83438413f
BLAKE2b-256 659ca9052de3b600778dda0fe5d566929d917fc6e6366f6da0ec7275332b84c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 12a0e80cb710eda09a6fa3c085e138d8b608416aba4cf149c43403c46c659990
MD5 83f509af17306be3c63d159482f1b4b6
BLAKE2b-256 c3321b513e18552233822e5821ba2bf4e902b7df86eb17405b0d7fb231b7c88d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d372a83ba1005c43f6b2c22aff96efce90e053036e2584befb2f5e067b500d79
MD5 692956f1ace1ebc0542541097bcf8c5c
BLAKE2b-256 66ddeb80ae269da42ada9cbdd914f64e2e91cc2df24c7e83ce8f301dbbfbd919

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.112.6-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3849b1f75fa92ce59aa2e363d454d3e2b6ab65092e8c2b4207f8b7b7cf5c499c
MD5 c811e0994d9449395f7fcaa2f94693e2
BLAKE2b-256 ebfd5a97b5a17c82827fea123560f84048fb290a631f46ed83272dc4b2e3e335

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