Skip to content

Commit

Permalink
Rename MaxCompute env variables to be consistent with SQLFlow (#1609)
Browse files Browse the repository at this point in the history
* Rename MaxCompute env variables to be consistent with SQLFlow

Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>

* Fix test

Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>

* Fix env var name

Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
  • Loading branch information
terrytangyuan committed Jan 3, 2020
1 parent f1ab88d commit 3fd0b12
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Expand Up @@ -47,7 +47,7 @@ jobs:
if [ "$ODPS_ACCESS_ID" == "" ] || [ "$ODPS_ACCESS_KEY" == "" ]; then if [ "$ODPS_ACCESS_ID" == "" ] || [ "$ODPS_ACCESS_KEY" == "" ]; then
echo "Skipping ODPS related unit tests since either ODPS_ACCESS_ID or ODPS_ACCESS_KEY is not set" echo "Skipping ODPS related unit tests since either ODPS_ACCESS_ID or ODPS_ACCESS_KEY is not set"
else else
docker run --rm -it -e ODPS_PROJECT_NAME=$ODPS_PROJECT_NAME -e ODPS_ACCESS_ID=$ODPS_ACCESS_ID -e ODPS_ACCESS_KEY=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c "make -f elasticdl/Makefile && K8S_TESTS=False pytest elasticdl/python/tests/odps_* elasticdl/python/tests/data_reader_test.py" docker run --rm -it -e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT -e MAXCOMPUTE_AK=$ODPS_ACCESS_ID -e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c "make -f elasticdl/Makefile && K8S_TESTS=False pytest elasticdl/python/tests/odps_* elasticdl/python/tests/data_reader_test.py"
fi fi
# Run integration tests # Run integration tests
- kubectl apply -f elasticdl/manifests/examples/elasticdl-rbac.yaml - kubectl apply -f elasticdl/manifests/examples/elasticdl-rbac.yaml
Expand All @@ -66,17 +66,17 @@ jobs:
else else
echo "Running ElasticDL job: ${JOB_TYPE}" echo "Running ElasticDL job: ${JOB_TYPE}"
if [[ "$JOB_TYPE" == "odps" ]]; then if [[ "$JOB_TYPE" == "odps" ]]; then
export ODPS_TABLE_NAME="odps_integration_build_${TRAVIS_BUILD_NUMBER}_$(date +%s)" export MAXCOMPUTE_TABLE="odps_integration_build_${TRAVIS_BUILD_NUMBER}_$(date +%s)"
docker run --rm -it -e ODPS_TABLE_NAME=$ODPS_TABLE_NAME -e ODPS_PROJECT_NAME=$ODPS_PROJECT_NAME -e ODPS_ACCESS_ID=$ODPS_ACCESS_ID -e ODPS_ACCESS_KEY=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c 'python -c "from elasticdl.python.tests.test_utils import *; create_iris_odps_table_from_env()"' docker run --rm -it -e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE -e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT -e MAXCOMPUTE_AK=$ODPS_ACCESS_ID -e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c 'python -c "from elasticdl.python.tests.test_utils import *; create_iris_odps_table_from_env()"'
fi fi
PS_NUM=2 PS_NUM=2
WORKER_NUM=1 WORKER_NUM=1
docker run --rm -it --net=host -e ODPS_TABLE_NAME=$ODPS_TABLE_NAME -e ODPS_PROJECT_NAME=$ODPS_PROJECT_NAME -e ODPS_ACCESS_ID=$ODPS_ACCESS_ID -e ODPS_ACCESS_KEY=$ODPS_ACCESS_KEY -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kube:/root/.kube -v /home/$USER/.minikube/:/home/$USER/.minikube/ -v $(pwd):/work -w /work elasticdl:ci bash -c "scripts/client_test.sh ${JOB_TYPE} ${PS_NUM} ${WORKER_NUM}" docker run --rm -it --net=host -e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE -e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT -e MAXCOMPUTE_AK=$ODPS_ACCESS_ID -e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.kube:/root/.kube -v /home/$USER/.minikube/:/home/$USER/.minikube/ -v $(pwd):/work -w /work elasticdl:ci bash -c "scripts/client_test.sh ${JOB_TYPE} ${PS_NUM} ${WORKER_NUM}"
if [[ "$JOB_TYPE" != "local" ]]; then if [[ "$JOB_TYPE" != "local" ]]; then
python3 scripts/validate_job_status.py ${JOB_TYPE} ${PS_NUM} ${WORKER_NUM} python3 scripts/validate_job_status.py ${JOB_TYPE} ${PS_NUM} ${WORKER_NUM}
fi fi
if [[ "$JOB_TYPE" == "odps" ]]; then if [[ "$JOB_TYPE" == "odps" ]]; then
docker run --rm -it -e ODPS_TABLE_NAME=$ODPS_TABLE_NAME -e ODPS_PROJECT_NAME=$ODPS_PROJECT_NAME -e ODPS_ACCESS_ID=$ODPS_ACCESS_ID -e ODPS_ACCESS_KEY=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c 'python -c "from elasticdl.python.tests.test_utils import *; delete_iris_odps_table_from_env()"' docker run --rm -it -e MAXCOMPUTE_TABLE=$MAXCOMPUTE_TABLE -e MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT -e MAXCOMPUTE_AK=$ODPS_ACCESS_ID -e MAXCOMPUTE_SK=$ODPS_ACCESS_KEY -v $PWD:/work -w /work elasticdl:dev bash -c 'python -c "from elasticdl.python.tests.test_utils import *; delete_iris_odps_table_from_env()"'
fi fi
fi fi
done done
Expand All @@ -92,4 +92,4 @@ env:
# Secure tokens for ODPS-related environment variables # Secure tokens for ODPS-related environment variables
- secure: kr79IltMhuW+pmmdP0KBMY87+iePGBGiaOUYTZhxx3zW3a1t2xK5wJnxJvrOwgBipqxLvIQnYUu20Lwfo0I2bwPRVvZAExb1vFBDQgzCaXEj+DHanE0XR1nivMzUcI3iHiBNRo5GalAUuiCzc/8fTx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rNw27+Dti3kCD59FphlRnxMzC7OoANJdFHMDBmruQIdq4/0UfPrFp7ZubwM3k+DFuZkRohyPeup8L0GYTwIt+PzuEC1+1rhIy7kxinwCn0jc/DK7hSEduxxr+CbPSBV60oqi+eZSahLFZYG26xsNUR5q7B2n36pYj0eK8d54ionHqsqP39ure10T+mRZS/SF9KPcpo+ZeEJaPTP41s3/5i3r5BlKfGr9GaA1yVtsbOwTx4McwJfW7Vd/HN+++swP+x1pPsC6iJ8KluZ6iSx6andHGnLyzvltaPqXxR8KNmfhDKXCcX8U/OPN1v22irdyAqWrZe7geNNVZJF1BRMEby1UYmAVZyZJ8xfhod/Acpv3Di+ZKSGGhbKvt20J1oYpVsV5lcNGAuCLgd175HHgkpFfjGuw97rRberBgCwzQdrRJjSvgsSp7VPjzOnrAE=
- ODPS_PROJECT_NAME=gomaxcompute_driver_w7u - MAXCOMPUTE_PROJECT=gomaxcompute_driver_w7u
20 changes: 10 additions & 10 deletions elasticdl/README.md
Expand Up @@ -89,14 +89,14 @@ the following:
make -f elasticdl/Makefile && pytest elasticdl/python/tests make -f elasticdl/Makefile && pytest elasticdl/python/tests
``` ```


[ODPS](https://www.alibabacloud.com/product/maxcompute)-related tests require additional environment variables. To run those tests, execute the following: [MaxCompute](https://www.alibabacloud.com/product/maxcompute)-related tests require additional environment variables. To run those tests, execute the following:


```bash ```bash
docker run --rm -it -v $PWD:/edl_dir -w /edl_dir \ docker run --rm -it -v $PWD:/edl_dir -w /edl_dir \
-e ODPS_PROJECT_NAME=xxx \ -e MAXCOMPUTE_PROJECT=xxx \
-e ODPS_ACCESS_ID=xxx \ -e MAXCOMPUTE_AK=xxx \
-e ODPS_ACCESS_KEY=xxx \ -e MAXCOMPUTE_SK=xxx \
-e ODPS_ENDPOINT=xxx \ -e MAXCOMPUTE_ENDPOINT=xxx \
elasticdl:dev bash -c "make -f elasticdl/Makefile && K8S_TESTS=False pytest elasticdl/python/tests/odps_* elasticdl/python/tests/data_reader_test.py" elasticdl:dev bash -c "make -f elasticdl/Makefile && K8S_TESTS=False pytest elasticdl/python/tests/odps_* elasticdl/python/tests/data_reader_test.py"
``` ```


Expand Down Expand Up @@ -171,16 +171,16 @@ All tests will be executed on [Travis CI](https://travis-ci.org/sql-machine-lear
* Integration tests * Integration tests


The unit tests and integration tests also contain tests running on a local Kubernetes cluster via [Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) and tests that The unit tests and integration tests also contain tests running on a local Kubernetes cluster via [Minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) and tests that
require data sources from [ODPS](https://www.alibabacloud.com/product/maxcompute). Please refer to [Travis configuration file](../.travis.yml) for more details. require data sources from [MaxCompute](https://www.alibabacloud.com/product/maxcompute). Please refer to [Travis configuration file](../.travis.yml) for more details.


Note that tests related to ODPS will not be executed on pull requests created from forks since Note that tests related to MaxCompute will not be executed on pull requests created from forks since
the ODPS access information has been secured on Travis and only those who have write access can retrieve it. Developers who the MaxCompute access information has been secured on Travis and only those who have write access can retrieve it. Developers who
have write access to this repo are encouraged to submit pull requests from branches instead of forks if any code related to ODPS have write access to this repo are encouraged to submit pull requests from branches instead of forks if any code related to MaxCompute
has been modified. has been modified.


Also note that two test cases of integration tests involve loading checkpoint. It is not easy to automatically generate checkpoints when doing integration tests. Currently we save a checkpoint file in the [test data folder](python/tests/testdata) of the ElasticDL Github repository and use this checkpoint file for integration tests. Thus you need to re-generate a new checkpoint file if your PR modifies the definition of Model protocol buffer. Also note that two test cases of integration tests involve loading checkpoint. It is not easy to automatically generate checkpoints when doing integration tests. Currently we save a checkpoint file in the [test data folder](python/tests/testdata) of the ElasticDL Github repository and use this checkpoint file for integration tests. Thus you need to re-generate a new checkpoint file if your PR modifies the definition of Model protocol buffer.


If you want to trigger Travis builds without submitting a pull request, you can do so by developing on a branch and add this If you want to trigger Travis builds without submitting a pull request, you can do so by developing on a branch and add this
branch name to the list in `branches` section in [Travis configuration file](../.travis.yml). Note that you can also trigger branch name to the list in `branches` section in [Travis configuration file](../.travis.yml). Note that you can also trigger
Travis builds from forks but it requires additional work such as activating Travis for the forked repo and ODPS related tests Travis builds from forks but it requires additional work such as activating Travis for the forked repo and MaxCompute related tests
will be skipped as mentioned earlier. will be skipped as mentioned earlier.
10 changes: 5 additions & 5 deletions elasticdl/python/common/constants.py
Expand Up @@ -11,11 +11,11 @@ class InstanceManagerStatus(object):
FINISHED = "Finished" FINISHED = "Finished"




class ODPSConfig(object): class MaxComputeConfig(object):
PROJECT_NAME = "ODPS_PROJECT_NAME" PROJECT_NAME = "MAXCOMPUTE_PROJECT"
ACCESS_ID = "ODPS_ACCESS_ID" ACCESS_ID = "MAXCOMPUTE_AK"
ACCESS_KEY = "ODPS_ACCESS_KEY" ACCESS_KEY = "MAXCOMPUTE_SK"
ENDPOINT = "ODPS_ENDPOINT" ENDPOINT = "MAXCOMPUTE_ENDPOINT"




class JobType(object): class JobType(object):
Expand Down
8 changes: 4 additions & 4 deletions elasticdl/python/data/odps_io.py
Expand Up @@ -10,7 +10,7 @@
from odps import ODPS from odps import ODPS
from odps.models import Schema from odps.models import Schema


from elasticdl.python.common.constants import ODPSConfig from elasticdl.python.common.constants import MaxComputeConfig
from elasticdl.python.common.log_utils import default_logger as logger from elasticdl.python.common.log_utils import default_logger as logger




Expand Down Expand Up @@ -51,9 +51,9 @@ def is_odps_configured():
return all( return all(
k in os.environ k in os.environ
for k in ( for k in (
ODPSConfig.PROJECT_NAME, MaxComputeConfig.PROJECT_NAME,
ODPSConfig.ACCESS_ID, MaxComputeConfig.ACCESS_ID,
ODPSConfig.ACCESS_KEY, MaxComputeConfig.ACCESS_KEY,
) )
) )


Expand Down
20 changes: 10 additions & 10 deletions elasticdl/python/data/reader/data_reader_factory.py
@@ -1,6 +1,6 @@
import os import os


from elasticdl.python.common.constants import ODPSConfig, ReaderType from elasticdl.python.common.constants import MaxComputeConfig, ReaderType
from elasticdl.python.data.odps_io import is_odps_configured from elasticdl.python.data.odps_io import is_odps_configured
from elasticdl.python.data.reader.csv_reader import CSVDataReader from elasticdl.python.data.reader.csv_reader import CSVDataReader
from elasticdl.python.data.reader.odps_reader import ODPSDataReader from elasticdl.python.data.reader.odps_reader import ODPSDataReader
Expand All @@ -17,11 +17,11 @@ def create_data_reader(data_origin, records_per_task=None, **kwargs):
if reader_type is None: if reader_type is None:
if is_odps_configured(): if is_odps_configured():
return ODPSDataReader( return ODPSDataReader(
project=os.environ[ODPSConfig.PROJECT_NAME], project=os.environ[MaxComputeConfig.PROJECT_NAME],
access_id=os.environ[ODPSConfig.ACCESS_ID], access_id=os.environ[MaxComputeConfig.ACCESS_ID],
access_key=os.environ[ODPSConfig.ACCESS_KEY], access_key=os.environ[MaxComputeConfig.ACCESS_KEY],
table=data_origin, table=data_origin,
endpoint=os.environ.get(ODPSConfig.ENDPOINT), endpoint=os.environ.get(MaxComputeConfig.ENDPOINT),
records_per_task=records_per_task, records_per_task=records_per_task,
**kwargs, **kwargs,
) )
Expand All @@ -34,15 +34,15 @@ def create_data_reader(data_origin, records_per_task=None, **kwargs):
elif reader_type == ReaderType.ODPS_READER: elif reader_type == ReaderType.ODPS_READER:
if not is_odps_configured: if not is_odps_configured:
raise ValueError( raise ValueError(
"ODPS_ACCESS_ID, ODPS_ACCESS_KEY and ODPS_PROJECT_NAME ", "MAXCOMPUTE_AK, MAXCOMPUTE_SK and MAXCOMPUTE_PROJECT ",
"must be configured in envs", "must be configured in envs",
) )
return ODPSDataReader( return ODPSDataReader(
project=os.environ[ODPSConfig.PROJECT_NAME], project=os.environ[MaxComputeConfig.PROJECT_NAME],
access_id=os.environ[ODPSConfig.ACCESS_ID], access_id=os.environ[MaxComputeConfig.ACCESS_ID],
access_key=os.environ[ODPSConfig.ACCESS_KEY], access_key=os.environ[MaxComputeConfig.ACCESS_KEY],
table=data_origin, table=data_origin,
endpoint=os.environ.get(ODPSConfig.ENDPOINT), endpoint=os.environ.get(MaxComputeConfig.ENDPOINT),
records_per_task=records_per_task, records_per_task=records_per_task,
**kwargs, **kwargs,
) )
Expand Down
10 changes: 5 additions & 5 deletions elasticdl/python/tests/data_reader_test.py
Expand Up @@ -9,7 +9,7 @@
import tensorflow as tf import tensorflow as tf
from odps import ODPS from odps import ODPS


from elasticdl.python.common.constants import ODPSConfig from elasticdl.python.common.constants import MaxComputeConfig
from elasticdl.python.common.model_utils import load_module from elasticdl.python.common.model_utils import load_module
from elasticdl.python.data.odps_io import is_odps_configured from elasticdl.python.data.odps_io import is_odps_configured
from elasticdl.python.data.reader.csv_reader import CSVDataReader from elasticdl.python.data.reader.csv_reader import CSVDataReader
Expand Down Expand Up @@ -104,10 +104,10 @@ def _parse_data(record):
) )
class ODPSDataReaderTest(unittest.TestCase): class ODPSDataReaderTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.project = os.environ[ODPSConfig.PROJECT_NAME] self.project = os.environ[MaxComputeConfig.PROJECT_NAME]
access_id = os.environ[ODPSConfig.ACCESS_ID] access_id = os.environ[MaxComputeConfig.ACCESS_ID]
access_key = os.environ[ODPSConfig.ACCESS_KEY] access_key = os.environ[MaxComputeConfig.ACCESS_KEY]
endpoint = os.environ.get(ODPSConfig.ENDPOINT) endpoint = os.environ.get(MaxComputeConfig.ENDPOINT)
self.test_table = "test_odps_data_reader_%d_%d" % ( self.test_table = "test_odps_data_reader_%d_%d" % (
int(time.time()), int(time.time()),
random.randint(1, 101), random.randint(1, 101),
Expand Down
10 changes: 5 additions & 5 deletions elasticdl/python/tests/odps_io_test.py
Expand Up @@ -6,7 +6,7 @@


from odps import ODPS from odps import ODPS


from elasticdl.python.common.constants import ODPSConfig from elasticdl.python.common.constants import MaxComputeConfig
from elasticdl.python.data.odps_io import ( from elasticdl.python.data.odps_io import (
ODPSReader, ODPSReader,
ODPSWriter, ODPSWriter,
Expand All @@ -23,10 +23,10 @@
) )
class ODPSIOTest(unittest.TestCase): class ODPSIOTest(unittest.TestCase):
def setUp(self): def setUp(self):
self._project = os.environ[ODPSConfig.PROJECT_NAME] self._project = os.environ[MaxComputeConfig.PROJECT_NAME]
self._access_id = os.environ[ODPSConfig.ACCESS_ID] self._access_id = os.environ[MaxComputeConfig.ACCESS_ID]
self._access_key = os.environ[ODPSConfig.ACCESS_KEY] self._access_key = os.environ[MaxComputeConfig.ACCESS_KEY]
self._endpoint = os.environ.get(ODPSConfig.ENDPOINT) self._endpoint = os.environ.get(MaxComputeConfig.ENDPOINT)
self._test_read_table = "test_odps_reader_%d_%d" % ( self._test_read_table = "test_odps_reader_%d_%d" % (
int(time.time()), int(time.time()),
random.randint(1, 101), random.randint(1, 101),
Expand Down
18 changes: 9 additions & 9 deletions elasticdl/python/tests/test_utils.py
Expand Up @@ -16,7 +16,7 @@
from elasticdl.python.common.constants import ( from elasticdl.python.common.constants import (
DistributionStrategy, DistributionStrategy,
JobType, JobType,
ODPSConfig, MaxComputeConfig,
) )
from elasticdl.python.common.grpc_utils import build_channel from elasticdl.python.common.grpc_utils import build_channel
from elasticdl.python.common.model_utils import ( from elasticdl.python.common.model_utils import (
Expand Down Expand Up @@ -510,22 +510,22 @@ class BIGINT);




def get_odps_client_from_env(): def get_odps_client_from_env():
project = os.environ[ODPSConfig.PROJECT_NAME] project = os.environ[MaxComputeConfig.PROJECT_NAME]
access_id = os.environ[ODPSConfig.ACCESS_ID] access_id = os.environ[MaxComputeConfig.ACCESS_ID]
access_key = os.environ[ODPSConfig.ACCESS_KEY] access_key = os.environ[MaxComputeConfig.ACCESS_KEY]
endpoint = os.environ.get(ODPSConfig.ENDPOINT) endpoint = os.environ.get(MaxComputeConfig.ENDPOINT)
return ODPS(access_id, access_key, project, endpoint) return ODPS(access_id, access_key, project, endpoint)




def create_iris_odps_table_from_env(): def create_iris_odps_table_from_env():
project = os.environ[ODPSConfig.PROJECT_NAME] project = os.environ[MaxComputeConfig.PROJECT_NAME]
table_name = os.environ["ODPS_TABLE_NAME"] table_name = os.environ["MAXCOMPUTE_TABLE"]
create_iris_odps_table(get_odps_client_from_env(), project, table_name) create_iris_odps_table(get_odps_client_from_env(), project, table_name)




def delete_iris_odps_table_from_env(): def delete_iris_odps_table_from_env():
project = os.environ[ODPSConfig.PROJECT_NAME] project = os.environ[MaxComputeConfig.PROJECT_NAME]
table_name = os.environ["ODPS_TABLE_NAME"] table_name = os.environ["MAXCOMPUTE_TABLE"]
get_odps_client_from_env().delete_table( get_odps_client_from_env().delete_table(
table_name, project, if_exists=True table_name, project, if_exists=True
) )
Expand Down
10 changes: 5 additions & 5 deletions model_zoo/cifar10_functional_api/cifar10_functional_api.py
Expand Up @@ -2,7 +2,7 @@


import tensorflow as tf import tensorflow as tf


from elasticdl.python.common.constants import Mode, ODPSConfig from elasticdl.python.common.constants import MaxComputeConfig, Mode
from elasticdl.python.common.log_utils import default_logger as logger from elasticdl.python.common.log_utils import default_logger as logger
from elasticdl.python.data.odps_io import ODPSWriter, is_odps_configured from elasticdl.python.data.odps_io import ODPSWriter, is_odps_configured
from elasticdl.python.worker.prediction_outputs_processor import ( from elasticdl.python.worker.prediction_outputs_processor import (
Expand Down Expand Up @@ -163,10 +163,10 @@ class PredictionOutputsProcessor(BasePredictionOutputsProcessor):
def __init__(self): def __init__(self):
if is_odps_configured(): if is_odps_configured():
self.odps_writer = ODPSWriter( self.odps_writer = ODPSWriter(
os.environ[ODPSConfig.PROJECT_NAME], os.environ[MaxComputeConfig.PROJECT_NAME],
os.environ[ODPSConfig.ACCESS_ID], os.environ[MaxComputeConfig.ACCESS_ID],
os.environ[ODPSConfig.ACCESS_KEY], os.environ[MaxComputeConfig.ACCESS_KEY],
os.environ[ODPSConfig.ENDPOINT], os.environ[MaxComputeConfig.ENDPOINT],
"cifar10_prediction_outputs", "cifar10_prediction_outputs",
# TODO: Print out helpful error message if the columns and # TODO: Print out helpful error message if the columns and
# column_types do not match with the prediction outputs # column_types do not match with the prediction outputs
Expand Down
4 changes: 2 additions & 2 deletions scripts/client_test.sh
Expand Up @@ -93,9 +93,9 @@ elif [[ "$JOB_TYPE" == "odps" ]]; then
--image_base=elasticdl:ci \ --image_base=elasticdl:ci \
--model_zoo=model_zoo \ --model_zoo=model_zoo \
--model_def=odps_iris_dnn_model.odps_iris_dnn_model.custom_model \ --model_def=odps_iris_dnn_model.odps_iris_dnn_model.custom_model \
--training_data=$ODPS_TABLE_NAME \ --training_data=$MAXCOMPUTE_TABLE \
--data_reader_params='columns=["sepal_length", "sepal_width", "petal_length", "petal_width", "class"]; label_col="class"' \ --data_reader_params='columns=["sepal_length", "sepal_width", "petal_length", "petal_width", "class"]; label_col="class"' \
--envs="ODPS_PROJECT_NAME=$ODPS_PROJECT_NAME,ODPS_ACCESS_ID=$ODPS_ACCESS_ID,ODPS_ACCESS_KEY=$ODPS_ACCESS_KEY,ODPS_ENDPOINT=" \ --envs="MAXCOMPUTE_PROJECT=$MAXCOMPUTE_PROJECT,MAXCOMPUTE_AK=$MAXCOMPUTE_AK,MAXCOMPUTE_SK=$MAXCOMPUTE_SK,MAXCOMPUTE_ENDPOINT=" \
--num_epochs=2 \ --num_epochs=2 \
--master_resource_request="cpu=0.2,memory=1024Mi" \ --master_resource_request="cpu=0.2,memory=1024Mi" \
--master_resource_limit="cpu=1,memory=2048Mi" \ --master_resource_limit="cpu=1,memory=2048Mi" \
Expand Down

0 comments on commit 3fd0b12

Please sign in to comment.