我一直在使用[ml-engine] [1]作为生产环境,现在我希望使用unittest
软件包在其中运行单元测试。
这是我正在运行的脚本(run_tests.py):
import unittest
from fruad_score_other_subpackage.fruad_score_globals import globals
logger = globals['logger']
class Test_all_flow(unittest.TestCase):
def test_supervised_model_has_varianve_in_results(self):
unique_prediction_count=2
self.assert_(unique_prediction_count>0)
if __name__ == '__main__':
logger.info('No Running:') #Just to make sure ml engine is running
unittest.main()
这是运行它的bash脚本:
#!/usr/bin/env bash
export GOOGLE_APPLICATION_CREDENTIALS=".......json"
PROJECT_ID='.....'
BUCKET_ID='machine_learning_datasets/fruad_score'
now=$(date +"%Y%m%d_%H%M%S")
JOB_NAME="fruad_score_testing__$now"
JOB_DIR="gs://machine_learning_datasets/fruad_score"
REGION="us-east1"
PYTHON_VERSION='3.5'
RUNTIME_VERSION='1.12'
TRAINER_PACKAGE_PATH="./trainer/"
PACKAGE_STAGING_PATH="gs://machine_learning_datasets/fruad_score"
CLOUDSDK_PYTHON="/usr/bin/python"
PACKAGES="globalclass-0.1.tar.gz"
MAIN_TRAINER_MODULE="trainer.run_tests"
gcloud ml-engine jobs submit training $JOB_NAME \
--job-dir $JOB_DIR \
--package-path $TRAINER_PACKAGE_PATH \
--packages $PACKAGES \
--module-name $MAIN_TRAINER_MODULE \
--region $REGION \
--runtime-version=$RUNTIME_VERSION \
--python-version=$PYTHON_VERSION \
--config trainer/config/config_train.json \
查看日志,我收到以下错误:
No Running:
.....
run_tests.py: error: unrecognized arguments: --job-dir
哪个表示该进程已运行,但是在激活unittest.main()
为什么它没有运行测试?为什么突然要求job-dir(注意,在--job-dir
标志中传递了工作ID)?还有什么其他方法可以在ML引擎上运行测试?