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

Uploaded CPython 3.13Windows x86-64

chalkpy-2.118.7-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.7-cp313-cp313-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

chalkpy-2.118.7-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.7-cp312-cp312-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.118.7-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.7-cp311-cp311-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.118.7-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.7-cp310-cp310-manylinux_2_28_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.118.7.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.7.tar.gz
Algorithm Hash digest
SHA256 a4f5983cf9e375c636046c69d15e900a1b918d4808efae58972baaf47370a33a
MD5 d9ad8de2fce4f70d8b45c30de7a025cf
BLAKE2b-256 194a552ccdf048b14d792508ad9d2e60389297021f5a924c10a650656973dd08

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.7-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.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 77e9833dacea7ed43ee6c1f7da2a2ae22aadeb412dc2401d42ba8998b838a0ec
MD5 8e31527f6a3601153714f9ae4a08a5f2
BLAKE2b-256 4214b63536d8ee64340be789daf500625dec8c302fcc671016591aafc5c40459

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9688cb368334100daa7c88b125be06fef16b4c97123f9348347276faeb255c72
MD5 d8c5aad572a599923230fe5ae8a6ea22
BLAKE2b-256 df0f4d93c9dcafcc38e4e7db1c9c02ca398e5e7a6a3172907fc789b1bbb88c84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 49466e13f441630b3aa653471e7109845bb86426b490f6da09bf854e0592eaf4
MD5 4c1da4834a438738382a8944740d0c86
BLAKE2b-256 97b9934699d092b61528b231f2fa0d6a42a01d224d8875022ba119b070d37375

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b57f68f22712bbc8cffed2cd3212708a629d5c38f4f4e1f2103c05cf39f65d19
MD5 df15be22f2f021e54d422a87f74fe73c
BLAKE2b-256 315ad787f94bf1f6da5a7714605b4463a1f360bb2416f8abb5b299bcd005e9fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d5870c17b2338c7c19db6e432cdb12a5a84f36ded7b9b8916303c3549f476e7c
MD5 dd69bd4cd7f5fc192d7ff7fe89750c06
BLAKE2b-256 522b2a320beb9dd5b50bf5a3bbd416593f11994342e90fee55259f4bb6204f3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3f249a9a824d6b6e775a6070f3db407790014a220bff0b48fca6e6f843d6759e
MD5 067ce58126b0639671a6a9472328204e
BLAKE2b-256 5db8149e56d023263bf438c860863b79e7335afeb1d1bd41f28bac37c67b8781

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 60d637d47662c24ab63f4c95d83110e6db34523cd7f3fab12414b83b343642da
MD5 cf36dd5e6a4758b350e20fb5c7d5ab8e
BLAKE2b-256 f57df346cc25abda7c352d6375f6e5d252f14418e40d90d96e6602e8901ff0ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d2e58a96b14a842247326054b8ec1a481e407fa61c72470c176bd73deaec72dd
MD5 d0c99d7f461fdd393e5a93b69594ebb4
BLAKE2b-256 ffe2d33d6d432323d52cd66836bf8593c289d3981a52d2caa5a2f2c97e143208

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d42e469f59164a7f7dd9d9d28ec5488b25479c7822d8df4cbca3af07bdfb22bf
MD5 9357397b2a692111eb5ac8724c666013
BLAKE2b-256 a4a47f359f253b8de574a93dc7d5b578e5af6c2cafa97b5490c0ce0b72817197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7ebd4b684ad1de7c4d4e3a497627bf962320b443d5476a871df67f2abd281c07
MD5 7d5862af4629092e59f91d33685c807b
BLAKE2b-256 fe7835fe8aec27f3512d41e9a69abafcb773596f9cce61c061f22d066a78b66f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 65c0a25f6a857d7a07450044950e1130bbf92c83f6fa60b04acfdaedb3a8e6ee
MD5 c13d3dca48a4792e92279983d710adb0
BLAKE2b-256 6fb3eead7a0d8a038aa07695fd991a6e12e3c30270ca3972294c3c2212285d81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 959bd72e33430f6849f1bd000a428ea69ac6c47acef5961e2e98cf49e99910eb
MD5 d78debf79fa5eda9492944e1f583932a
BLAKE2b-256 872470da44aa232891ff205eb99a14a6dabc56ff18cb679c8cc93e4fa15e8974

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 bcb634ec39cf57ec1b5a179840f6fb75e6a14fae9e8a2b845fb8811a2b4100b1
MD5 feec78f7bfb684a94d29887dae5682b4
BLAKE2b-256 b9805461160d23264d35766493d1890a370a4ab9479b99951e44634772ca16e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1635e6e27836d1a53ffafa45240e570ff319173f11338e1cc64de878d59d697
MD5 c3a2de68b698a61a20a1bc6ad781443f
BLAKE2b-256 29be6fbf9de95ca05fee9a38f6ae37fc6e3dc5b755ad7afda4437f83ca4219c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8140a39e99fcc695a70d35d8e56052ca4501623b5f9e0f8cc41aea34ddb76bf1
MD5 ee817bc2465f503b85e5b2cb4d8d6aa8
BLAKE2b-256 80a9d5ccdb3c9b225aaa52187b3a1b9a5e82077c0f20e903488176c529ce125b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.7-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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 09b32e7c92ed356cc8b6ffedc500af6409e344e58857d2f2f7e5725b5454e394
MD5 5f4bbbda163a9d3ee8c8ace6be9ea482
BLAKE2b-256 d0584d4d10ef81d2890f8ae5d30a2ac91e5ce2b3b4dbd6412a84e419230fe057

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca4b2c4ec50172b2b0cae1528b9dfd1f2f0aedc4401819c3c19583a5d0271d57
MD5 ae16b66377b92db6a45b6abd5a2c0bf8
BLAKE2b-256 45daa182715c014f6d675b795a415924a01fde4d731f0f2bb552830eb7de1a56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e7dfa1190f42bc33bccf3fe72c05e495e54a57bb74a56f75470373034bed2b54
MD5 58ce5f34c62b209196c84ef7d420cfb9
BLAKE2b-256 3953425f4fd9fdb42ced14d0920f9c15a24b4f816fea5c2652cc77f3e0ac204c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f5435a36ae2c6f95c8c5e2805e7cf1818d19ce1222564eeaca79e97cb6d148f0
MD5 89e374312bfbc4bb96061a9372036433
BLAKE2b-256 96746733b2f589c29221f6c103469370108ec6eaced70230322f02fb7c3b8b54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.7-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 54ce9c0703a5d5bd94ee20f12206475f9b775b575b41b1942dfbf1dd64f2d4ca
MD5 7b86db80f3ccc0fde925532943f89315
BLAKE2b-256 79184527f4f2a891401f56039b7a42b4d60d1cc2bf84a2f680c4b60702c09748

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