in frauddetector/frauddetector.py [0:0]
def deploy(self, rules_list=None, rule_execution_mode='FIRST_MATCHED'):
"""Deploy a detector-version with associated rules for a particular model version
Args:
:rules_list: Optional: if a list of rules is supplied, call the create_rules method, otherwise work with existing rules
pass in list of (rule_name, expression, [outcomes]) tuples
"""
# Check model-version is ACTIVE
if self.model_status != 'ACTIVE':
lh.warning("deploy: Model is not active; wait until model is active before deploying")
raise EnvironmentError("Model not active")
# create rules, if supplied, then get all the rules associated with this detector instance
if rules_list:
response = self.create_rules(rules_list)
active_rules = self.rules
# create a rules list of dicts to pass in to create detector version
rules_payload = []
for r in active_rules:
rules_payload.append({'detectorId': self.detector_name, 'ruleId': r['ruleId'], 'ruleVersion': r['ruleVersion'] })
# deploy the detector-version with rules and model
response = self.fd.create_detector_version(
detectorId=self.detector_name,
rules=rules_payload,
modelVersions=[{
'modelId': self.model_name,
'modelType': self.model_type,
'modelVersionNumber': self.model_version
}],
ruleExecutionMode=rule_execution_mode
)
return response