-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_loadmod_op.yaml
64 lines (64 loc) · 4.09 KB
/
generate_loadmod_op.yaml
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
64
name: Load model
description: Loads the vw model file and Hybrid class object
outputs:
- {name: clf, type: String}
- {name: index_tag_mapping, type: String}
- {name: tag_index_mapping, type: String}
- {name: index_label_mapping, type: String}
- {name: label_index_mapping, type: String}
implementation:
container:
image: zongshun96/load_model_s3:0.01
command:
- sh
- -ec
- |
program_path=$(mktemp)
printf "%s" "$0" > "$program_path"
python3 -u "$program_path" "$@"
- "def _make_parent_dirs_and_return_path(file_path: str):\n import os\n \
\ os.makedirs(os.path.dirname(file_path), exist_ok=True)\n return file_path\n\
\ndef load_model(clf_path, index_tag_mapping_path, tag_index_mapping_path, index_label_mapping_path,\
\ label_index_mapping_path):\n '''Loads the vw model file and Hybrid class\
\ object '''\n import boto3\n import os\n import time\n # time.sleep(5000)\n\
\n s3 = boto3.resource(service_name='s3', \n region_name='us-east-1',\
\ \n aws_access_key_id=\"AKIAXECNQISLIBBXAMLV\", \n \
\ aws_secret_access_key=\"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\"\
,)\n\n model_localpath = '/pipelines/component/src/model.json'\n index_tag_mapping_localpath\
\ = '/pipelines/component/src/index_tag_mapping'\n tag_index_mapping_localpath\
\ = '/pipelines/component/src/tag_index_mapping'\n index_label_mapping_localpath\
\ = '/pipelines/component/src/index_label_mapping'\n label_index_mapping_localpath\
\ = '/pipelines/component/src/label_index_mapping'\n\n s3.Bucket('praxi-model-xgb-02').download_file(Key='model.json',\
\ Filename=model_localpath)\n os.popen('cp {0} {1}'.format(model_localpath,\
\ clf_path))\n s3.Bucket('praxi-model-xgb-02').download_file(Key='index_tag_mapping',\
\ Filename=index_tag_mapping_localpath)\n os.popen('cp {0} {1}'.format(index_tag_mapping_localpath,\
\ index_tag_mapping_path))\n s3.Bucket('praxi-model-xgb-02').download_file(Key='tag_index_mapping',\
\ Filename=tag_index_mapping_localpath)\n os.popen('cp {0} {1}'.format(tag_index_mapping_localpath,\
\ tag_index_mapping_path))\n s3.Bucket('praxi-model-xgb-02').download_file(Key='index_label_mapping',\
\ Filename=index_label_mapping_localpath)\n os.popen('cp {0} {1}'.format(index_label_mapping_localpath,\
\ index_label_mapping_path))\n s3.Bucket('praxi-model-xgb-02').download_file(Key='label_index_mapping',\
\ Filename=label_index_mapping_localpath)\n os.popen('cp {0} {1}'.format(label_index_mapping_localpath,\
\ label_index_mapping_path))\n\nimport argparse\n_parser = argparse.ArgumentParser(prog='Load\
\ model', description='Loads the vw model file and Hybrid class object')\n_parser.add_argument(\"\
--clf\", dest=\"clf_path\", type=_make_parent_dirs_and_return_path, required=True,\
\ default=argparse.SUPPRESS)\n_parser.add_argument(\"--index-tag-mapping\",\
\ dest=\"index_tag_mapping_path\", type=_make_parent_dirs_and_return_path, required=True,\
\ default=argparse.SUPPRESS)\n_parser.add_argument(\"--tag-index-mapping\",\
\ dest=\"tag_index_mapping_path\", type=_make_parent_dirs_and_return_path, required=True,\
\ default=argparse.SUPPRESS)\n_parser.add_argument(\"--index-label-mapping\"\
, dest=\"index_label_mapping_path\", type=_make_parent_dirs_and_return_path,\
\ required=True, default=argparse.SUPPRESS)\n_parser.add_argument(\"--label-index-mapping\"\
, dest=\"label_index_mapping_path\", type=_make_parent_dirs_and_return_path,\
\ required=True, default=argparse.SUPPRESS)\n_parsed_args = vars(_parser.parse_args())\n\
\n_outputs = load_model(**_parsed_args)\n"
args:
- --clf
- {outputPath: clf}
- --index-tag-mapping
- {outputPath: index_tag_mapping}
- --tag-index-mapping
- {outputPath: tag_index_mapping}
- --index-label-mapping
- {outputPath: index_label_mapping}
- --label-index-mapping
- {outputPath: label_index_mapping}