Skip to content

Commit 6f5dbfb

Browse files
authored
Releases v0.12.2 (#256)
1 parent 469343a commit 6f5dbfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2020
-1464
lines changed

bin/copyright.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import argparse
88
import datetime
9+
import difflib
910
import os.path
1011
import re
1112
import subprocess # nosec
@@ -97,7 +98,8 @@ def main() -> None:
9798
else:
9899
if not no_git_log:
99100
print(
100-
f"No log found with git on '{file_name}' (the next messages will be hidden)."
101+
f"No log found with git on '{file_name}' "
102+
"(the next messages will be hidden)."
101103
)
102104
no_git_log = True
103105
used_year = CURRENT_YEAR
@@ -118,7 +120,7 @@ def main() -> None:
118120

119121
with open(file_name, "r", encoding="utf-8") as file_obj:
120122
content = file_obj.read()
121-
file_success, content = update_file(
123+
file_success, new_content = update_file(
122124
content,
123125
used_year,
124126
one_date_re,
@@ -131,9 +133,13 @@ def main() -> None:
131133
)
132134
if not file_success:
133135
success = False
136+
file_diff_lines = difflib.unified_diff(
137+
content.splitlines(keepends=True), new_content.splitlines(keepends=True)
138+
)
139+
file_diff = "".join(file_diff_lines)
134140
with open(file_name, "w", encoding="utf-8") as file_obj:
135-
file_obj.write(content)
136-
print(f"Fixing copyright in '{file_name}'")
141+
file_obj.write(new_content)
142+
print(f"Copyright updated in '{file_name}'.\n{file_diff}")
137143

138144
if not success:
139145
sys.exit(1)

docs/source/installation-ext.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,37 @@
88
`地址 <https://pip.pypa.io/en/stable/installing/>`_ 安装,推荐使用 `阿里云镜像 <http://mirrors.aliyun.com/help/pypi>`_
99
加快下载速度。
1010

11-
接着确保 setuptools 的版本:
11+
接着升级 pip 和 setuptools 的版本:
1212

1313
.. code-block:: sh
1414
15-
pip install setuptools>=3.0
15+
pip install -U pip setuptools
1616
17-
接着就可以安装 PyODPS:
17+
此后可以安装 PyODPS:
1818

1919
.. code-block:: sh
2020
2121
pip install pyodps
2222
23+
如果安装时出现 `urllib3 v2.0 only supports OpenSSL 1.1.1+` 的报错,需要先安装一个兼容旧版
24+
OpenSSL 的 urllib3 版本
25+
26+
.. code-block:: sh
27+
28+
pip install urllib3\<2.0
29+
30+
此后再安装 PyODPS。
31+
2332
检查安装完成:
2433

2534
.. code-block:: sh
2635
2736
python -c "from odps import ODPS"
2837
29-
3038
如果使用的python不是系统默认的python版本,安装完pip则可以:
3139

3240
.. code-block:: sh
3341
34-
/home/tops/bin/python2.7 -m pip install setuptools>=3.0
42+
/home/tops/bin/python2.7 -m pip install -U pip setuptools
3543
3644
其余步骤类似。

docs/source/locale/en/LC_MESSAGES/api-def.po

Lines changed: 58 additions & 492 deletions
Large diffs are not rendered by default.

docs/source/locale/en/LC_MESSAGES/installation-ext.po

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PyODPS 0.7.16\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2024-03-15 15:54+0800\n"
11+
"POT-Creation-Date: 2024-12-17 11:11+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
18-
"Generated-By: Babel 2.12.1\n"
18+
"Generated-By: Babel 2.16.0\n"
1919

2020
#: ../../source/installation-ext.rst:5
2121
msgid "安装指南"
2222
msgstr "Installation instructions"
2323

2424
#: ../../source/installation-ext.rst:7
2525
msgid ""
26-
"如果能访问外网,推荐使用 pip 安装。较新版本的 Python 通常自带 pip。如果你"
27-
"的 Python 不包含 pip,可以参考 `地址 <https://pip.pypa.io/en/stable/"
28-
"installing/>`_ 安装,推荐使用 `阿里云镜像 <http://mirrors.aliyun.com/help"
29-
"/pypi>`_ 加快下载速度。"
26+
"如果能访问外网,推荐使用 pip 安装。较新版本的 Python 通常自带 pip。如果你的 Python 不包含 pip,可以参考 `地址 "
27+
"<https://pip.pypa.io/en/stable/installing/>`_ 安装,推荐使用 `阿里云镜像 "
28+
"<http://mirrors.aliyun.com/help/pypi>`_ 加快下载速度。"
3029
msgstr ""
3130
"We recommend that you use pip to install Python on MaxCompute (PyODPS) "
3231
"when you have access to the Internet. pip is often installed with latest "
@@ -36,42 +35,59 @@ msgstr ""
3635
"<https://pip.pypa.io/en/stable/installing/>`_ ."
3736

3837
#: ../../source/installation-ext.rst:11
39-
msgid "接着确保 setuptools 的版本:"
38+
msgid "接着升级 pip 和 setuptools 的版本:"
4039
msgstr ""
41-
"Make sure that you install the correct versions of setuptools by the "
42-
"following command."
40+
"Make sure that you upgrade your pip and setuptools to the latest version "
41+
"by the following command."
4342

4443
#: ../../source/installation-ext.rst:13
45-
msgid "pip install setuptools>=3.0"
44+
msgid "pip install -U pip setuptools"
4645
msgstr ""
4746

4847
#: ../../source/installation-ext.rst:17
49-
msgid "接着就可以安装 PyODPS:"
48+
msgid "此后可以安装 PyODPS:"
5049
msgstr "Install PyODPS by using the following code:"
5150

5251
#: ../../source/installation-ext.rst:19
5352
msgid "pip install pyodps"
5453
msgstr ""
5554

5655
#: ../../source/installation-ext.rst:23
56+
msgid ""
57+
"如果安装时出现 `urllib3 v2.0 only supports OpenSSL 1.1.1+` 的报错,需要先安装一个兼容旧版 "
58+
"OpenSSL 的 urllib3 版本"
59+
msgstr ""
60+
"If you meet the error `urllib3 v2.0 only supports OpenSSL 1.1.1+` during"
61+
" installation, you need to install an older urllib3 version which is "
62+
"compatible with older OpenSSL versions."
63+
64+
#: ../../source/installation-ext.rst:26
65+
msgid "pip install urllib3\\<2.0"
66+
msgstr ""
67+
68+
#: ../../source/installation-ext.rst:30
69+
msgid "此后再安装 PyODPS。"
70+
msgstr "Then PyODPS can be installed as expected."
71+
72+
#: ../../source/installation-ext.rst:32
5773
msgid "检查安装完成:"
5874
msgstr "Check whether the installation has been completed:"
5975

60-
#: ../../source/installation-ext.rst:25
76+
#: ../../source/installation-ext.rst:34
6177
msgid "python -c \"from odps import ODPS\""
6278
msgstr ""
6379

64-
#: ../../source/installation-ext.rst:30
80+
#: ../../source/installation-ext.rst:38
6581
msgid "如果使用的python不是系统默认的python版本,安装完pip则可以:"
6682
msgstr ""
6783
"If your version of Python is not the default version, run the following "
6884
"code after installing pip:"
6985

70-
#: ../../source/installation-ext.rst:32
71-
msgid "/home/tops/bin/python2.7 -m pip install setuptools>=3.0"
86+
#: ../../source/installation-ext.rst:40
87+
msgid "/home/tops/bin/python2.7 -m pip install -U pip setuptools"
7288
msgstr ""
7389

74-
#: ../../source/installation-ext.rst:36
90+
#: ../../source/installation-ext.rst:44
7591
msgid "其余步骤类似。"
7692
msgstr "Repeat these steps to install your version of Python."
7793

docs/source/locale/en/LC_MESSAGES/options.po

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PyODPS 0.8.0\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2024-07-27 19:27+0800\n"
11+
"POT-Creation-Date: 2024-11-30 15:32+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
1515
"MIME-Version: 1.0\n"
1616
"Content-Type: text/plain; charset=utf-8\n"
1717
"Content-Transfer-Encoding: 8bit\n"
18-
"Generated-By: Babel 2.12.1\n"
18+
"Generated-By: Babel 2.16.0\n"
1919

2020
#: ../../source/options.rst:5
2121
msgid "配置选项"
2222
msgstr "Configuration"
2323

2424
#: ../../source/options.rst:8
25-
msgid ""
26-
"PyODPS 提供了一系列的配置选项,可通过 ``odps.options`` 获得,如下面的例子"
27-
":"
25+
msgid "PyODPS 提供了一系列的配置选项,可通过 ``odps.options`` 获得,如下面的例子:"
2826
msgstr ""
2927
"PyODPS provides a series of configuration options, which can be obtained "
3028
"through ``odps.options``. Here is a simple example:"
@@ -34,11 +32,10 @@ msgid ""
3432
"from odps import options\n"
3533
"# 设置所有输出表的生命周期(lifecycle 选项)\n"
3634
"options.lifecycle = 30\n"
37-
"# 使用 Tunnel 下载 string 类型时使用 bytes(tunnel.string_as_binary 选项"
38-
")\n"
35+
"# 使用 Tunnel 下载 string 类型时使用 bytes(tunnel.string_as_binary 选项)\n"
3936
"options.tunnel.string_as_binary = True\n"
40-
"# PyODPS DataFrame 用 ODPS 执行时,参照下面 dataframe 相关配置,sort "
41-
"设置 limit 到一个比较大的值\n"
37+
"# PyODPS DataFrame 用 ODPS 执行时,参照下面 dataframe 相关配置,sort 时设置 limit 到一个比较大的值"
38+
"\n"
4239
"options.df.odps.sort.limit = 100000000"
4340
msgstr ""
4441
"from odps import options\n"
@@ -110,6 +107,16 @@ msgstr "LogView holding time (hours)"
110107
msgid "24"
111108
msgstr ""
112109

110+
#: ../../source/options.rst:1
111+
msgid "use_legacy_logview"
112+
msgstr ""
113+
114+
#: ../../source/options.rst:1
115+
msgid "使用旧版 LogView 地址,None 表示自动根据 Endpoint 处理"
116+
msgstr ""
117+
"Use legacy LogView address. If None is specified, LogView will be "
118+
"selected given MaxCompute endpoint."
119+
113120
#: ../../source/options.rst:1
114121
msgid "quota_name"
115122
msgstr ""
@@ -123,9 +130,7 @@ msgid "local_timezone"
123130
msgstr ""
124131

125132
#: ../../source/options.rst:1
126-
msgid ""
127-
"使用的时区,None 表示不处理,True 表示本地时区,False 表示 UTC,也可用 "
128-
"pytz 的时区"
133+
msgid "使用的时区,None 表示不处理,True 表示本地时区,False 表示 UTC,也可用 pytz 的时区"
129134
msgstr ""
130135
"Used time zone. None indicates that PyODPS takes no actions, True "
131136
"indicates local time, and False indicates UTC. The time zone of pytz "
@@ -387,7 +392,7 @@ msgstr ""
387392
msgid "配置使用 Tunnel 所需的标签"
388393
msgstr "Tags when calling tunnel service"
389394

390-
#: ../../source/options.rst:73
395+
#: ../../source/options.rst:74
391396
msgid "DataFrame 配置"
392397
msgstr "DataFrame configurations"
393398

docs/source/options.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ PyODPS 提供了一系列的配置选项,可通过 ``odps.options`` 获得,
3030
"default_project", "默认 Project", "None"
3131
"logview_host", "LogView 主机名", "None"
3232
"logview_hours", "LogView 保持时间(小时)", "24"
33+
"use_legacy_logview", "使用旧版 LogView 地址,None 表示自动根据 Endpoint 处理", "None"
3334
"quota_name", "提交任务时使用的计算 Quota 名称", "None"
3435
"local_timezone", "使用的时区,None 表示不处理,True 表示本地时区,False 表示 UTC,也可用 pytz 的时区", "None"
3536
"lifecycle", "所有表生命周期", "None"

odps/_version.py

Lines changed: 2 additions & 2 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.
@@ -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, 1, 1)
15+
version_info = (0, 12, 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/accounts.py

Lines changed: 7 additions & 2 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.
@@ -535,6 +535,8 @@ def sign_request(self, req, endpoint, region_name=None):
535535
url = req.url[len(endpoint) :]
536536
url_components = urlparse(unquote(url), allow_fragments=False)
537537
self._build_canonical_str(url_components, req)
538+
if self.token is None:
539+
raise TypeError("Cannot sign request with None bearer token")
538540
req.headers["x-odps-bearer-token"] = self.token
539541
if self._last_refresh_time:
540542
req.headers["x-pyodps-token-timestamp"] = str(self._last_refresh_time)
@@ -546,7 +548,7 @@ def __init__(self, credential_provider):
546548
self.provider = credential_provider
547549
super(CredentialProviderAccount, self).__init__(None, None, None)
548550

549-
def sign_request(self, req, endpoint, region_name=None):
551+
def _refresh_credential(self):
550552
try:
551553
credential = self.provider.get_credential()
552554
except:
@@ -555,6 +557,9 @@ def sign_request(self, req, endpoint, region_name=None):
555557
self.access_id = credential.get_access_key_id()
556558
self.secret_access_key = credential.get_access_key_secret()
557559
self.sts_token = credential.get_security_token()
560+
561+
def sign_request(self, req, endpoint, region_name=None):
562+
utils.call_with_retry(self._refresh_credential)
558563
return super(CredentialProviderAccount, self).sign_request(
559564
req, endpoint, region_name=region_name
560565
)

odps/apis/storage_api/storage_api.py

Lines changed: 17 additions & 15 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.
@@ -20,6 +20,7 @@
2020
from enum import Enum
2121
from hashlib import md5
2222
from io import BytesIO, IOBase
23+
from typing import List, Union
2324

2425
try:
2526
import pyarrow as pa
@@ -621,16 +622,21 @@ def __init__(
621622
table: Table,
622623
rest_endpoint: str = None,
623624
quota_name: str = None,
625+
tags: Union[None, str, List[str]] = None,
624626
):
625-
if isinstance(odps, ODPS) and isinstance(table, Table):
626-
self._odps = odps
627-
self._table = table
628-
self._quota_name = quota_name
629-
self._rest_endpoint = rest_endpoint
630-
self._tunnel_rest = None
631-
else:
627+
if not isinstance(odps, ODPS) or not isinstance(table, Table):
632628
raise ValueError("Please input odps configuration")
633629

630+
self._odps = odps
631+
self._table = table
632+
self._quota_name = quota_name
633+
self._rest_endpoint = rest_endpoint
634+
self._tunnel_rest = None
635+
636+
self._tags = tags or options.tunnel.tags
637+
if isinstance(self._tags, str):
638+
self._tags = self._tags.split(",")
639+
634640
@property
635641
def table(self):
636642
return self._table
@@ -653,14 +659,10 @@ def _get_resource(self, *args) -> str:
653659
url = self._table.table_resource(endpoint=endpoint, force_schema=True)
654660
return "/".join([url] + list(args))
655661

656-
@staticmethod
657-
def _fill_common_headers(raw_headers=None, tags=None):
662+
def _fill_common_headers(self, raw_headers=None):
658663
headers = raw_headers or {}
659-
tags = tags or options.tunnel.tags
660-
if tags:
661-
if isinstance(tags, str):
662-
tags = tags.split(",")
663-
headers["odps-tunnel-tags"] = ",".join(tags)
664+
if self._tags:
665+
headers["odps-tunnel-tags"] = ",".join(self._tags)
664666
return headers
665667

666668
def create_read_session(

0 commit comments

Comments
 (0)