Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a5ea13d

Browse files
committedApr 18, 2025·
Releases v0.12.2.2
1 parent 82ee2a3 commit a5ea13d

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed
 

‎odps/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
version_info = (0, 12, 2, 1)
15+
version_info = (0, 12, 2, 2)
1616
_num_index = max(idx if isinstance(v, int) else 0 for idx, v in enumerate(version_info))
1717
__version__ = ".".join(map(str, version_info[: _num_index + 1])) + "".join(
1818
version_info[_num_index + 1 :]

‎odps/models/tasks/maxframe.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 1999-2024 Alibaba Group Holding Ltd.
1+
# Copyright 1999-2025 Alibaba Group Holding Ltd.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717

1818
from ... import serializers
19-
from ...compat import enum
19+
from ...compat import enum, six
2020
from ...config import options
2121
from .core import Task
2222

@@ -63,5 +63,14 @@ def serial(self):
6363
if "settings" in self.properties:
6464
settings.update(json.loads(self.properties["settings"]))
6565

66-
self.properties["settings"] = json.dumps(settings)
66+
final_settings = OrderedDict()
67+
for k, v in settings.items():
68+
if isinstance(v, six.string_types):
69+
final_settings[k] = v
70+
elif isinstance(v, bool):
71+
final_settings[k] = str(v).lower()
72+
else:
73+
final_settings[k] = str(v)
74+
75+
self.properties["settings"] = json.dumps(final_settings)
6776
return super(MaxFrameTask, self).serial()

‎odps/models/tasks/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def collect_sql_settings(value, glob):
2929

3030
settings = OrderedDict()
3131
if options.default_task_settings:
32-
settings = options.default_task_settings
32+
settings.update(options.default_task_settings)
3333

3434
if utils.str_to_bool(os.environ.get("PYODPS_SUBMIT_CLIENT_VERSIONS") or "true"):
3535
settings["PYODPS_VERSION"] = __version__

‎odps/models/xflows.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
# Copyright 1999-2024 Alibaba Group Holding Ltd.
3+
# Copyright 1999-2025 Alibaba Group Holding Ltd.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import json
18+
import logging
1719
import time
1820
from collections import OrderedDict
1921

@@ -23,6 +25,8 @@
2325
from .instance import Instance
2426
from .xflow import XFlow
2527

28+
logger = logging.getLogger(__name__)
29+
2630

2731
class XFlows(Iterable):
2832
marker = serializers.XMLNodeField("Marker")
@@ -139,15 +143,31 @@ def run_xflow(
139143
self, xflow_instance=None, project=None, hints=None, parameters=None, **kw
140144
):
141145
project = project or self.parent
142-
hints = hints or {}
146+
props = kw.get("properties") or OrderedDict()
147+
props.update(hints or {})
143148
if options.ml.xflow_settings:
144-
hints.update(options.ml.xflow_settings)
145-
if hints:
146-
kw["properties"] = hints
149+
props.update(options.ml.xflow_settings)
147150
if options.biz_id:
148-
if kw.get("properties") is None:
149-
kw["properties"] = OrderedDict()
150-
kw["properties"]["biz_id"] = str(options.biz_id)
151+
props["biz_id"] = str(options.biz_id)
152+
153+
if options.default_task_settings:
154+
settings = options.default_task_settings.copy()
155+
exist_settings = json.loads(
156+
props.get("settings") or "{}", object_pairs_hook=OrderedDict
157+
)
158+
settings.update(exist_settings)
159+
str_settings = OrderedDict()
160+
for k, v in settings.items():
161+
if isinstance(v, six.string_types):
162+
str_settings[k] = v
163+
elif isinstance(v, bool):
164+
str_settings[k] = "true" if v else "false"
165+
else:
166+
str_settings[k] = str(v)
167+
props["settings"] = json.dumps(str_settings)
168+
169+
if props:
170+
kw["properties"] = props
151171
if parameters:
152172
new_params = OrderedDict()
153173
for k, v in six.iteritems(parameters):
@@ -158,11 +178,15 @@ def run_xflow(
158178
else:
159179
new_params[k] = v
160180
parameters = new_params
161-
return project.instances.create(
162-
xml=self._gen_xflow_instance_xml(
163-
xflow_instance=xflow_instance, parameters=parameters, **kw
164-
)
181+
182+
inst_xml = self._gen_xflow_instance_xml(
183+
xflow_instance=xflow_instance, parameters=parameters, **kw
165184
)
185+
try:
186+
return project.instances.create(xml=inst_xml)
187+
except:
188+
logger.error("Failed to create xflow instance. Job XML:\n%s", inst_xml)
189+
raise
166190

167191
class XFlowResult(XMLRemoteModel):
168192
class XFlowAction(XMLRemoteModel):

0 commit comments

Comments
 (0)
Please sign in to comment.