Skip to content

Commit d766138

Browse files
More consistent uses of Maxcompute environment variables (#725)
* More consistent uses of Maxcompute environment variables Signed-off-by: terrytangyuan <terrytangyuan@gmail.com> * Also change it in elasticdl template Signed-off-by: terrytangyuan <terrytangyuan@gmail.com>
1 parent a62de8d commit d766138

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

cmd/sqlflowserver/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func TestEnd2EndMaxCompute(t *testing.T) {
311311
if err != nil {
312312
t.Fatalf("prepare test dataset failed: %v", err)
313313
}
314-
caseDB = "gomaxcompute_driver_w7u"
314+
caseDB = os.Getenv("MAXCOMPUTE_PROJECT")
315315
caseTrainTable = "sqlflow_test_iris_train"
316316
caseTestTable = "sqlflow_test_iris_test"
317317
casePredictTable = "sqlflow_test_iris_predict"

scripts/test_maxcompute.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
export SQLFLOW_TEST_DB=maxcompute
1616
export MAXCOMPUTE_ENDPOINT="service.cn.maxcompute.aliyun.com/api?curr_project=gomaxcompute_driver_w7u&scheme=https"
17+
export MAXCOMPUTE_PROJECT="gomaxcompute_driver_w7u"
1718
if [ "$MAXCOMPUTE_AK" = "" ] || [ "$MAXCOMPUTE_SK" == "" ]; then
1819
echo "skip maxcompute test because the env MAXCOMPUTE_AK or MAXCOMPUTE_SK is empty"
1920
exit 0

sql/sql_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ func testHiveDatabase() *DB {
7373

7474
func testMaxcompute() *DB {
7575
cfg := &gomaxcompute.Config{
76-
AccessID: os.Getenv("ODPS_ACCESS_ID"),
77-
AccessKey: os.Getenv("ODPS_ACCESS_KEY"),
78-
Project: os.Getenv("ODPS_PROJECT"),
79-
Endpoint: os.Getenv("ODPS_ENDPOINT"),
76+
AccessID: os.Getenv("MAXCOMPUTE_AK"),
77+
AccessKey: os.Getenv("MAXCOMPUTE_SK"),
78+
Project: os.Getenv("MAXCOMPUTE_PROJECT"),
79+
Endpoint: os.Getenv("MAXCOMPUTE_ENDPOINT"),
8080
}
8181

8282
db, e := NewDB(fmt.Sprintf("maxcompute://%s", cfg.FormatDSN()))
8383
assertNoErr(e)
84-
// TODO(weiguo): Popularize
84+
// Note: We do not popularize the test data here intentionally since
85+
// it will take up quite some time on Maxcompute.
8586
return db
8687
}
8788

sql/template_elasticdl.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package sql
1616
const elasticdlDataConversionTemplateText = `
1717
import os
1818
19-
from elasticdl.python.common.constants import ODPSConfig
2019
from elasticdl.python.common.odps_io import ODPSReader
2120
from elasticdl.python.common.odps_recordio_conversion_utils import (
2221
write_recordio_shards_from_iterator,
@@ -26,10 +25,10 @@ from elasticdl.python.common.odps_recordio_conversion_utils import (
2625
COLUMN_NAMES = {{.FeaturesList}}
2726
2827
reader = ODPSReader(
29-
os.environ[ODPSConfig.PROJECT_NAME],
30-
os.environ[ODPSConfig.ACCESS_ID],
31-
os.environ[ODPSConfig.ACCESS_KEY],
32-
os.environ[ODPSConfig.ENDPOINT],
28+
os.environ["MAXCOMPUTE_PROJECT"],
29+
os.environ["MAXCOMPUTE_AK"],
30+
os.environ["MAXCOMPUTE_SK"],
31+
os.environ["MAXCOMPUTE_ENDPOINT"],
3332
table = "{{.ODPSTableName}}",
3433
partition = None,
3534
num_processes = {{.NumProcesses}},
@@ -140,17 +139,17 @@ class PredictionOutputsProcessor(BasePredictionOutputsProcessor):
140139
if all(
141140
k in os.environ
142141
for k in (
143-
ODPSConfig.PROJECT_NAME,
144-
ODPSConfig.ACCESS_ID,
145-
ODPSConfig.ACCESS_KEY,
146-
ODPSConfig.ENDPOINT,
142+
"MAXCOMPUTE_PROJECT",
143+
"MAXCOMPUTE_AK",
144+
"MAXCOMPUTE_SK",
145+
"MAXCOMPUTE_ENDPOINT",
147146
)
148147
):
149148
self.odps_writer = ODPSWriter(
150-
os.environ[ODPSConfig.PROJECT_NAME],
151-
os.environ[ODPSConfig.ACCESS_ID],
152-
os.environ[ODPSConfig.ACCESS_KEY],
153-
os.environ[ODPSConfig.ENDPOINT],
149+
os.environ["MAXCOMPUTE_PROJECT"],
150+
os.environ["MAXCOMPUTE_AK"],
151+
os.environ["MAXCOMPUTE_SK"],
152+
os.environ["MAXCOMPUTE_ENDPOINT"],
154153
table = "{{.PredictOutputTable}}",
155154
columns=["pred_" + str(i) for i in range({{.OutputShape}})],
156155
column_types=["double" for _ in range({{.OutputShape}})],

0 commit comments

Comments
 (0)