8000 GitHub - chalk-ai/chalk-ruby: Ruby client for working with Chalk
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chalk-ai/chalk-ruby

Repository files navigation

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.

About

Ruby client for working with Chalk

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 7

0