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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.13+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.13+ x86-64

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

Uploaded CPython 3.11Windows x86-64

chalkpy-2.118.1-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.1-cp311-cp311-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.11macOS 10.13+ x86-64

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

Uploaded CPython 3.10Windows x86-64

chalkpy-2.118.1-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.1-cp310-cp310-manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

  • Download URL: chalkpy-2.118.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ed3748da6924c2cc683c7fc81b377ec007f6fcbfeba5464d86ca9351854c19a2
MD5 57fec11e66331348c07a0ee3cb5694fe
BLAKE2b-256 bcd64e32c08d7c31eb3bb64d969b40c507cecce5dbeae2afaac8926aa83630d9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.1-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.118.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 486ca865d966c961084b8916796d634f3c8691a5c3632ec9d00f33f96d9cc374
MD5 11cadd9337fed6ae4ebf8dcd3d56d71c
BLAKE2b-256 0e94d82259af4b6c449e08ae44d2599373c3cf1560969321dbce651c264b9666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5c44c05387e3f4c2c4d4245ace941a81789e56e1662ab4677f1fd88405c72bb6
MD5 252a8ce1f67db4d30799ef78bd898bf3
BLAKE2b-256 1446b1f7a3846b1df417dc3d0e872a306d5f3270ac70df6a0fecd472450ae64b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4d261ea536186a0a7e2044e806ecb30dfd472f544371adf0356f52e12f0ae7b1
MD5 ac0beb174170a08de79f7b4da1c6d6ad
BLAKE2b-256 a3c3cbdf4ffc524cc52dece04ed65bcae8f534a959827f1dae6a8ad2b66d2205

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b512221700c1244a17488412a571739c038d9114651eb2a54b732c4b40160641
MD5 9b670cc90d6f36df7e03d49f5211f46c
BLAKE2b-256 b25c5c2535592318dd647cb5ab527eed1de583b27aa1449d5c2c1e0beee6df14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 42f2f2d993ee2e4e7b0a0b8ee7c58c848525d653edfb62a2bce84d670af31f96
MD5 c65dd0a0dc88f4e7a5ee880967ca8663
BLAKE2b-256 6a654e3da7a82e43ad1d307b0577abf28577fe41b9ff6da6606b8c51700376d7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.1-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.118.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e7209096c804ba4b8778717718705af085db04b8e561066746093fa38992d2d7
MD5 b8e22d3a1430212e08303d89a04e5885
BLAKE2b-256 3d82d7920ac296acb251287debe1ec0965a64d8ab460dcdca457621bfaca7e76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 37e62f59292727d4210fe3719031f3ab923ff05e13e0524c8a1079a9e9d6e346
MD5 ea2332939bae80e79ad6404fee5b2272
BLAKE2b-256 b213a7bc0c262d08d336274c47c1fc4dd77e99d03cc462d434056cc91d730ac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 83a2c61b4619bb81481e201a6e83124ec11fc0db01ff2f7b562c49d1d4234c8c
MD5 6fcb3b82b02926c3d5d77e0be46f3943
BLAKE2b-256 09af84f74a4d3514d9c28f6f1462df6b396e5208ad655880cbb381fe857ec98a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9056e54f101be994a650bf1fc4df9b3815d1fc79d62f4cf0b181d3ddb3d7b8b7
MD5 05eb26632dc31a5be9073e999c1b7492
BLAKE2b-256 7b96b55681d2f6f1b5a29b2815ec8ce81a206e5cf7133605d26bd4d4bd89d32c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d7cf95416093dd7693ce726da3878f7102502b206983f11b1f036056fc9e48d0
MD5 cf734bc38a4901b3cf864b295f408cae
BLAKE2b-256 0ca109300c9097b3bc2287758dce2cd1fcfb78eb57b2aeedc3ae8c0a82ba29e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.1-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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5c556375042860ddf9011e5211934eb452c45d0c03ed567b66565ef8c864f59e
MD5 62431ea10afbee5917fcae7da9b4401f
BLAKE2b-256 b296c0e1d2f2960d1a7cca18faff7ffa4c39b671757a5b67aa6f817030aeb16b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 465dd04653dc07de68f281a2e1b925a6866209da9bbd13f8679bff19581fbcb4
MD5 0e2e2cf744b81b048f1e073602583e06
BLAKE2b-256 6174cc04bc1cc12800e5ba31fbba25429843a95d046ae4282edcaab5fc53ef77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ccaec96329ee0b3f53c7ad069c684c47243f2af92c4c7412bb42409f14b4a400
MD5 c0537037c36e7f9c0122195fc86f4cd6
BLAKE2b-256 5783f7c1e6dc36bfa7b8a60b179c45b98277043aaf3bceef2486e34ecacb3b69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 445f732eaa420e04765503a7a2d090e1856f815f1daa90ead4ee39e0bab57355
MD5 a8cc46dcbf72642ab766c470e88a2fc0
BLAKE2b-256 90477b8d0c4981dc8b382b28f92ec711c8eea47bae7d0772ddee6c6833687c8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 8593d0efe50eab9ef0914efd8ac274c260e22f5e0a1da66205addb59199e415d
MD5 66a53c9798c7daf0dd5ffa883ab53f77
BLAKE2b-256 873d8ed7958c78d2306079c7bf4af3af9f647069dacb86b5626699b5230af306

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chalkpy-2.118.1-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.118.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36a388c3dfe685dc8241b175aa880298b14071b9102f7cb15c93ac029545b84c
MD5 27b25017cbe72e6328318a86fb33cd51
BLAKE2b-256 0910bbe33505ab318148c5b012199136a460e49910a7dcf61414a6d93f27ccbe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5e6947d747eb3fbad983ac9e2c93787211477b11918cb9776e73baadbe68cb3b
MD5 85657bd8fd1288cfa61021b048004936
BLAKE2b-256 951b87137ad6980fb95da6ba0bad6368c07b4dc2f5555e1d9c6ef84778ec3cd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 88102fc58abf26127250eb7deeebce8dff419c0c02f9bd34b94affd42e68c93b
MD5 0117c167fb57a2c1c4e610eb445e3008
BLAKE2b-256 cfce91037802351edc57991942ff703cd3d9fdae1bd6210bb97b8081a3836186

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09242ad8d966ce86c80989a1b40ae5bd37a9fe5c8df2eff112f8c3519150f0a3
MD5 f14301493b1889ff37c9aed46dc906dd
BLAKE2b-256 20eac61067476f081d00899f131c0d9bc33ab27fd458e8e93672cd42c79b8c80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chalkpy-2.118.1-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 fcd6f6e26a60621cfc4f93b7b68cd40cdfcefb7a6f69edd8ea59ec0d91d8726e
MD5 42c36fdc4a386563f7122b1da8eb2002
BLAKE2b-256 5ddbb332705381de539e7e1a77a2f8478d103250a5931d01de84242b598abcbc

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