Project

chalk_ruby

0.0
The project is in a healthy, maintained state
A simple Ruby client for Chalk
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

>= 0.15, < 3
>= 1.64.3, < 2
~> 18.0.0
 Project Readme

ChalkRuby - Ruby Client for Chalk

Gem Version License

A Ruby client library for Chalk, a feature engineering platform for machine learning and data applications.

Installation

Add this line to your application's Gemfile:

gem 'chalk_ruby'

And then execute:

bundle install

Or install it directly:

gem install chalk_ruby

Quick Start

# Create a client with credentials
client = ChalkRuby::Client.create(
  'my-client-id',
  'my-client-secret',
  'my-environment-id' # Optional, can also use CHALK_ACTIVE_ENVIRONMENT env var
)

# Query features
results = client.query(
  input: { 'user.id': 'my-user-id' },
  output: %w(user.id user.name user.email),
  query_name: 'user_profile' # Optional: for tracking and monitoring
)

# Access feature values
puts results['user.name']

Authentication

Authentication can be provided in multiple ways:

  1. Directly in the client constructor:

    client = ChalkRuby::Client.create('my-client-id', 'my-client-secret')
  2. Using environment variables:

    CHALK_CLIENT_ID=my-client-id
    CHALK_CLIENT_SECRET=my-client-secret
    CHALK_ACTIVE_ENVIRONMENT=my-environment # Optional
    
    client = ChalkRuby::Client.create

Advanced Usage

Query Options

The query method supports several options:

client.query(
  input: { 'user.id': 'my-user-id' },
  output: %w(user.id user.name user.credit_score),
  now: Time.now,                      # Optional: time at which to evaluate the query
  staleness: { 'user.credit_score': '1d' }, # Optional: max staleness for cached features
  tags: { 'environment': 'production' },    # Optional: tags for resolver selection
  branch: 'my-feature-branch',        # Optional: route request to a specific branch
  correlation_id: 'request-123',      # Optional: ID for tracing in logs
  query_name: 'user_profile',         # Optional: semantic name for the query
  timeout: 5.0                        # Optional: timeout in seconds
)

Configuration

Create a client with custom configuration:

config = ChalkRuby::Config.new(
  client_id: 'my-client-id',
  client_secret: 'my-client-secret',
  environment: 'my-environment',
  query_server: 'https://custom-query-server.chalk.ai',
  api_server: 'https://custom-api.chalk.ai',
  additional_headers: { 'X-Custom-Header': 'value' }
)

client = ChalkRuby::Client.create_with_config(config)

Requirements

  • Ruby 2.7 or higher

Version

Current version: 0.2.8

License

The Chalk Ruby Client is open-sourced software licensed under the Apache 2.0 License.