Skip to content

Commit c604a58

Browse files
committed
Merge pull request #20 in ODSC/oci-data-science-ai-samples from merge_to_github2021-07-15-15-39-59 to github
* commit 'e5f6febcd6f2cadbd337bfd7c88463a0f5ecb7ed': Releasing version
2 parents 1d4d5bc + e5f6feb commit c604a58

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed
Binary file not shown.

model_catalog_examples/artifact_boilerplate/artifact_introspection_test/model_artifact_validate.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
PYTHON_VER_PATTERN = "^([3])(\.[6-9])(\.\d+)?$"
2626
PAR_URL = "https://objectstorage.us-ashburn-1.oraclecloud.com/p/q0qASrU7L7G1-BIVtoXOmvcEPMwYKoSVnp4Uum-31MwCYoSAahFLnHG8nA7AdLci/n/ociodscdev/b/service_conda_packs/o/service_pack/index.json"
2727
TESTS = {
28-
'score_py': {'key': 'score_py', 'category': 'Mandatory Files Check', 'description': 'Check that the file "score.py" exists and is in the top level directory of the artifact directory', 'error_msg': 'File score.py is not present.'},
29-
'runtime_yaml': {'category': 'Mandatory Files Check', 'description': 'Check that the file "runtime.yaml" exists and is in the top level directory of the artifact directory', 'error_msg': 'File runtime.yaml is not present.'},
30-
'score_syntax': {'category': 'score.py', 'description': 'Check for Python syntax errors', 'error_msg': 'Syntax error in score.py: '},
28+
'score_py': {'key': 'score_py', 'category': 'Mandatory Files Check', 'description': 'Check that the file "score.py" exists and is in the top level directory of the artifact directory', 'error_msg': 'The file \'score.py\' is missing.'},
29+
'runtime_yaml': {'category': 'Mandatory Files Check', 'description': 'Check that the file "runtime.yaml" exists and is in the top level directory of the artifact directory', 'error_msg': 'The file \'runtime.yaml\' is missing.'},
30+
'score_syntax': {'category': 'score.py', 'description': 'Check for Python syntax errors', 'error_msg': 'There is Syntax error in score.py: '},
3131
'score_load_model': {'category': 'score.py', 'description': 'Check that load_model() is defined', 'error_msg': 'Function load_model is not present in score.py.'},
3232
'score_predict': {'category': 'score.py', 'description': 'Check that predict() is defined', 'error_msg': 'Function predict is not present in score.py.'},
33-
'score_predict_data': {'category': 'score.py', 'description': 'Check that the only required argument for predict() is named "data"', 'error_msg': 'Function predict in score.py should have argument named "data".'},
34-
'score_predict_arg': {'category': 'score.py', 'description': 'Check that all other arguments in predict() are optional and have default values', 'error_msg': 'All other arguments in predict function in score.py should have default values.'},
35-
'runtime_version': {'category': 'runtime.yaml', 'description': 'Check that field MODEL_ARTIFACT_VERSION is set to 3.0', 'error_msg': 'In runtime.yaml field MODEL_ARTIFACT_VERSION should be set to 3.0'},
36-
'runtime_env_python': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_PYTHON_VERSION is set to a value of 3.6 or higher', 'error_msg': 'In runtime.yaml field MODEL_DEPLOYMENT.INFERENCE_PYTHON_VERSION is set to a value of 3.6 or higher'},
37-
'runtime_env_type': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is set to a value in (published, data_science)', 'error_msg': 'In runtime.yaml field MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE should be set to a value in (published, data_science)', 'warn': ""},
38-
'runtime_env_slug': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG is set', 'error_msg': 'In runtime.yaml field MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG should be set.'},
39-
'runtime_env_path': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_PATH is set', 'error_msg': 'In runtime.yaml field MODEL_DEPLOYMENT.INFERENCE_ENV_PATH should be set.'},
40-
'runtime_path_exist': {'category': 'conda_env', 'description': 'If MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is data_science and MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG is set, check that the file path in MODEL_DEPLOYMENT.INFERENCE_ENV_PATH is correct.', 'error_msg': "In runtime.yaml field MODEL_DEPLOYMENT.INFERENCE_ENV_PATH doesn't exist."},
41-
'runtime_slug_exist': {'category': 'conda_env', 'description': 'If MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is data_science, check that the slug listed in MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG exists.', 'error_msg': "In runtime.yaml the value of the fileld INFERENCE_ENV_SLUG doesn't exist in the given bucket."}
33+
'score_predict_data': {'category': 'score.py', 'description': 'Check that the only required argument for predict() is named "data"', 'error_msg': 'The predict function in score.py must have a formal argument named \'data\'.'},
34+
'score_predict_arg': {'category': 'score.py', 'description': 'Check that all other arguments in predict() are optional and have default values', 'error_msg': 'All formal arguments in the predict function must have default values, except that \'data\' argument.'},
35+
'runtime_version': {'category': 'runtime.yaml', 'description': 'Check that field MODEL_ARTIFACT_VERSION is set to 3.0', 'error_msg': 'In runtime.yaml, the key MODEL_ARTIFACT_VERSION must be set to 3.0.'},
36+
'runtime_env_python': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_PYTHON_VERSION is set to a value of 3.6 or higher', 'error_msg': 'In runtime.yaml, the key MODEL_DEPLOYMENT.INFERENCE_PYTHON_VERSION must be set to a value of 3.6 or higher.'},
37+
'runtime_env_type': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is set to a value in (published, data_science)', 'error_msg': 'In runtime.yaml, the key MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE must be set to published or data_science.'},
38+
'runtime_env_slug': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG is set', 'error_msg': 'In runtime.yaml, the key MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG must have a value.'},
39+
'runtime_env_path': {'category': 'conda_env', 'description': 'Check that field MODEL_DEPLOYMENT.INFERENCE_ENV_PATH is set', 'error_msg': 'In runtime.yaml, the key MODEL_DEPLOYMENT.INFERENCE_ENV_PATH must have a value.'},
40+
'runtime_path_exist': {'category': 'conda_env', 'description': 'If MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is data_science and MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG is set, check that the file path in MODEL_DEPLOYMENT.INFERENCE_ENV_PATH is correct.', 'error_msg': "In runtime.yaml, the key MODEL_DEPLOYMENT.INFERENCE_ENV_PATH does not exist."},
41+
'runtime_slug_exist': {'category': 'conda_env', 'description': 'If MODEL_DEPLOYMENT.INFERENCE_ENV_TYPE is data_science, check that the slug listed in MODEL_DEPLOYMENT.INFERENCE_ENV_SLUG exists.', 'error_msg': "In runtime.yaml, the value of the key INFERENCE_ENV_SLUG is `slug_value` and it doesn't exist in the bucket `bucket_url`. Ensure that the value INFERENCE_ENV_SLUG and the bucket url are correct."}
4242
}
4343

4444
def combine_msgs(test_list) -> str:
@@ -101,8 +101,6 @@ def check_runtime_yml(file_path) -> Tuple[bool, str]:
101101
if msg:
102102
return False, msg
103103
try:
104-
if TESTS['runtime_env_type']['value'] == 'published':
105-
TESTS['runtime_env_type']['warn'] = 'WARNING: Provide the correct access policy as INFERENCE_ENV_TYPE is published'
106104
m = re.match(PYTHON_VER_PATTERN, str(TESTS['runtime_env_python']['value']))
107105
if m and m.group():
108106
TESTS['runtime_env_python']['success'] = True
@@ -182,7 +180,8 @@ def check_score_file(file_path) -> Tuple[bool, str]:
182180

183181
except SyntaxError as e:
184182
TESTS['score_syntax']['success'] = False
185-
return False, TESTS['score_syntax']['error_msg'] + str(e) # error message has ": " e has syntax error details
183+
TESTS['score_syntax']['error_msg'] = TESTS['score_syntax']['error_msg'] + str(e) # error message has ": " e has syntax error details
184+
return False, TESTS['score_syntax']['error_msg']
186185

187186
def check_mandatory_files(files_present) -> Tuple[bool, str]:
188187
'''
@@ -279,9 +278,6 @@ def write_html(output_path) -> None:
279278
result = get_test_result(key)
280279
html_response += f'<tr class="{css_classes[result]}"><th class="{count_classes[count%2]}">{count}</th><td>{key}</td><td>{TESTS[key]["description"]}</td><td>{out_classes[result]}</td>'
281280

282-
if key == 'runtime_env_type' and len(TESTS[key]["warn"]) > 0:
283-
html_response += f'<td>{TESTS[key]["warn"]}</td></tr></body>'
284-
285281
if get_test_result(key) == 1:
286282
html_response += f'<td>{TESTS[key]["error_msg"]}</td></tr></body>'
287283
else:

0 commit comments

Comments
 (0)