Migration Guide¶
This document is intended for users who are migrating from the old version of these bindings.
1. Naming changes¶
To conform with PEP 8 the following renames have been completed.
rl_client.live_model ->
rl_client.LiveModel()
rl_client.ranking_response ->
rl_client.RankingResponse()
rl_client.configuration ->
rl_client.Configuration()
rl_client.rl_exception ->
rl_client.RLException()
2. Error Callback¶
The error callback no longer needs to be a class that inherits from rl_client.error_callback. Now it should simply be a function which has a signature of void(int, string), and can include closure values.
class my_error_callback(rl_client.error_callback):
def on_error(self, error_code, error_message):
print("Background error:")
print(error_message)
# ...
error_callback = my_error_callback()
client = rl_client.live_model(_, error_callback)
Changes to:
def on_error(self, error_code, error_message):
print("Background error:")
print(error_message)
# ...
client = rl_client.LiveModel(_, on_error)
3. Init¶
init no longer needs to be called.
client = rl_client.live_model(config)
client.init()
Changes to:
client = rl_client.LiveModel(config)
4. choose_rank return value¶
choose_rank no longer returns a tuple, but now returns a rl_client.RankingResponse()
object that contains the same information as was contained in the tuple.
model_id, chosen_action_id, actions_probabilities, event_id = model.choose_rank(context)
Changes to:
response = model.choose_rank(context)
response.model_id
response.chosen_action_id
response.actions_probabilities
response.event_id