-
Notifications
You must be signed in to change notification settings - Fork 5
/
main_demo_fraud_detector_undeploy.py
executable file
·63 lines (50 loc) · 3.1 KB
/
main_demo_fraud_detector_undeploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ***************************************************************************************
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. *
# *
# Permission is hereby granted, free of charge, to any person obtaining a copy of this *
# software and associated documentation files (the "Software"), to deal in the Software *
# without restriction, including without limitation the rights to use, copy, modify, *
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
# permit persons to whom the Software is furnished to do so. *
# *
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION *
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE *
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
# ***************************************************************************************
import argparse
import logging
import sys
from core.fraud_detector_undeploy import FraudDetectorUndeploy
def undeploy(model_name=None, model_version=None, detector_name=None):
"""
UnDeploys a model with a single scoring rule based on model score
:param model_name:
:param model_version:
:param detector_name:
:return:
"""
undeployer = FraudDetectorUndeploy()
# Delete all detector versions
if detector_name:
undeployer.delete_detector(detector_name)
if model_name is not None and model_version is not None:
# Undeploy specific model version
undeployer.undeploy_model(model_name, model_version)
if detector_name is None and (model_name is None or model_version is None):
raise ValueError(" Model name and model version must be specified or just the detector must be specified")
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--model", help="The name of the model", required=False, default=None)
parser.add_argument("--modelVersion", help="Version of the model", required=False, default=None)
parser.add_argument("--detector", help="The name of the detector", required=False, default=None)
parser.add_argument("--log-level", help="Log level", default="INFO", choices={"INFO", "WARN", "DEBUG", "ERROR"})
args = parser.parse_args()
print(args.__dict__)
# Set up logging
logging.basicConfig(level=logging.getLevelName(args.log_level), handlers=[logging.StreamHandler(sys.stdout)],
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Run
undeploy(model_name=args.model, model_version=args.modelVersion, detector_name=args.detector)