Skip to content

class OptimizeClient

Bases: Client

Extension to GraphQL Client to access methods specific to Sumatra Optimize.

Humans: First, log in via the CLI: sumatra login

Bots: Set the SUMATRA_INSTANCE and SUMATRA_SDK_KEY environment variables

Functions

__init__(instance=None, branch=None, workspace=None)

Create connection object.

Parameters:

Name Type Description Default
instance Optional[str]

Sumatra instance url, e.g. yourco.sumatra.ai. If unspecified, the your config default will be used.

None
branch Optional[str]

Set default branch. If unspecified, your config default will be used.

None
workspace Optional[str]

Sumatra workspace name to connect to.

None

create_audience(name, description=None, rule=None, audience_type=None)

Create new Audience.

Parameters:

Name Type Description Default
name str

Human-readable name for the audience.

required
description Optional[str]

Optional description of the audience.

None
rule Optional[dict]

JSON object representing the audience rule.

None
audience_type Optional[str]

Either 'SumatraAI' or None

None

Returns:

Type Description
str

slug of the created audience

create_experience(optimization_id, name, audience='everyone')

Create new Experience.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required
name str

Human-readable name for the experience.

required
audience str

Audience slug

'everyone'

Returns:

Type Description
str

id of the created experience

create_optimization(name, rootPage, holdout_percentage=0, description=None)

Create new Optimization.

Parameters:

Name Type Description Default
name str

Human-readable name for the optimization.

required
rootPage str

Base URL for the optimization.

required
holdout_percentage float

Percentage of traffic to hold out for the optimization.

0
description Optional[str]

Optional description of the optimization.

None

Returns:

Type Description
str

id of the created optimization

delete_audience(slug)

Delete Audience by slug.

delete_experience(optimization_id, experience_id)

Delete Experience by id.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required
experience_id str

Experience id

required

delete_optimization(id)

Delete Optimization by id.

Parameters:

Name Type Description Default
id str

Optimization id

required

get_audience(slug)

Get Audience by slug.

Parameters:

Name Type Description Default
slug str

Audience slug

required

Returns:

Type Description
dict

Audience details

get_audience_inputs()

Get list of available audience input features.

Returns:

Type Description
list[dict]

List of scowl feature names and corresponding operators

get_experience(optimization_id, experience_id)

Get Experience by id.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required
experience_id str

Experience id

required

Returns:

Type Description
dict

Experience details

get_goals(optimization_id)

Get Goals for an Optimization.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required

Returns:

Type Description
list[dict]

List of Goals, including details

get_optimization(id)

Get Optimization by id.

Parameters:

Name Type Description Default
id str

Optimization id

required

Returns:

Type Description
dict

Optimization details

list_audiences()

List all Audiences.

Returns:

Type Description
list[dict]

List of Audiences, including details

list_experiences(optimization_id)

List all Experiences for an Optimization.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required

Returns:

Type Description
list[dict]

List of Experiences, including details

list_optimizations()

List all Optimizations.

Returns:

Type Description
list[dict]

List of Optimizations, including details

refresh_active_experiments()

Refresh Athena query results for all active experiments.

update_experience(optimization_id, experience_id, status=None, audience=None)

Update Experience by id.

Parameters:

Name Type Description Default
optimization_id str

Optimization id

required
experience_id str

Experience id

required
status Optional[str]

New status for the experience. One of {'draft', 'running', 'stopped'}

None
audience Optional[str]

Audience slug

None

Returns:

Type Description
dict

Experience details