Skip to content

Commit

Permalink
Releases v0.12.2 (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjsi authored Jan 3, 2025
1 parent 469343a commit 6f5dbfb
Show file tree
Hide file tree
Showing 57 changed files with 2,020 additions and 1,464 deletions.
14 changes: 10 additions & 4 deletions bin/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import argparse
import datetime
import difflib
import os.path
import re
import subprocess # nosec
Expand Down Expand Up @@ -97,7 +98,8 @@ def main() -> None:
else:
if not no_git_log:
print(
f"No log found with git on '{file_name}' (the next messages will be hidden)."
f"No log found with git on '{file_name}' "
"(the next messages will be hidden)."
)
no_git_log = True
used_year = CURRENT_YEAR
Expand All @@ -118,7 +120,7 @@ def main() -> None:

with open(file_name, "r", encoding="utf-8") as file_obj:
content = file_obj.read()
file_success, content = update_file(
file_success, new_content = update_file(
content,
used_year,
one_date_re,
Expand All @@ -131,9 +133,13 @@ def main() -> None:
)
if not file_success:
success = False
file_diff_lines = difflib.unified_diff(
content.splitlines(keepends=True), new_content.splitlines(keepends=True)
)
file_diff = "".join(file_diff_lines)
with open(file_name, "w", encoding="utf-8") as file_obj:
file_obj.write(content)
print(f"Fixing copyright in '{file_name}'")
file_obj.write(new_content)
print(f"Copyright updated in '{file_name}'.\n{file_diff}")

if not success:
sys.exit(1)
Expand Down
18 changes: 13 additions & 5 deletions docs/source/installation-ext.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,37 @@
`地址 <https://pip.pypa.io/en/stable/installing/>`_ 安装,推荐使用 `阿里云镜像 <http://mirrors.aliyun.com/help/pypi>`_
加快下载速度。

接着确保 setuptools 的版本:
接着升级 pip 和 setuptools 的版本:

.. code-block:: sh
pip install setuptools>=3.0
pip install -U pip setuptools
接着就可以安装 PyODPS:
此后可以安装 PyODPS:

.. code-block:: sh
pip install pyodps
如果安装时出现 `urllib3 v2.0 only supports OpenSSL 1.1.1+` 的报错,需要先安装一个兼容旧版
OpenSSL 的 urllib3 版本

.. code-block:: sh
pip install urllib3\<2.0
此后再安装 PyODPS。

检查安装完成:

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

.. code-block:: sh
/home/tops/bin/python2.7 -m pip install setuptools>=3.0
/home/tops/bin/python2.7 -m pip install -U pip setuptools
其余步骤类似。
550 changes: 58 additions & 492 deletions docs/source/locale/en/LC_MESSAGES/api-def.po

Large diffs are not rendered by default.

48 changes: 32 additions & 16 deletions docs/source/locale/en/LC_MESSAGES/installation-ext.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ msgid ""
msgstr ""
"Project-Id-Version: PyODPS 0.7.16\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-03-15 15:54+0800\n"
"POT-Creation-Date: 2024-12-17 11:11+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"
"Generated-By: Babel 2.16.0\n"

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

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

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

#: ../../source/installation-ext.rst:13
msgid "pip install setuptools>=3.0"
msgid "pip install -U pip setuptools"
msgstr ""

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

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

#: ../../source/installation-ext.rst:23
msgid ""
"如果安装时出现 `urllib3 v2.0 only supports OpenSSL 1.1.1+` 的报错,需要先安装一个兼容旧版 "
"OpenSSL 的 urllib3 版本"
msgstr ""
"If you meet the error `urllib3 v2.0 only supports OpenSSL 1.1.1+` during"
" installation, you need to install an older urllib3 version which is "
"compatible with older OpenSSL versions."

#: ../../source/installation-ext.rst:26
msgid "pip install urllib3\\<2.0"
msgstr ""

#: ../../source/installation-ext.rst:30
msgid "此后再安装 PyODPS。"
msgstr "Then PyODPS can be installed as expected."

#: ../../source/installation-ext.rst:32
msgid "检查安装完成:"
msgstr "Check whether the installation has been completed:"

#: ../../source/installation-ext.rst:25
#: ../../source/installation-ext.rst:34
msgid "python -c \"from odps import ODPS\""
msgstr ""

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

#: ../../source/installation-ext.rst:32
msgid "/home/tops/bin/python2.7 -m pip install setuptools>=3.0"
#: ../../source/installation-ext.rst:40
msgid "/home/tops/bin/python2.7 -m pip install -U pip setuptools"
msgstr ""

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

31 changes: 18 additions & 13 deletions docs/source/locale/en/LC_MESSAGES/options.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@ msgid ""
msgstr ""
"Project-Id-Version: PyODPS 0.8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-27 19:27+0800\n"
"POT-Creation-Date: 2024-11-30 15:32+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"
"Generated-By: Babel 2.16.0\n"

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

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

#: ../../source/options.rst:1
msgid "use_legacy_logview"
msgstr ""

#: ../../source/options.rst:1
msgid "使用旧版 LogView 地址,None 表示自动根据 Endpoint 处理"
msgstr ""
"Use legacy LogView address. If None is specified, LogView will be "
"selected given MaxCompute endpoint."

#: ../../source/options.rst:1
msgid "quota_name"
msgstr ""
Expand All @@ -123,9 +130,7 @@ msgid "local_timezone"
msgstr ""

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

#: ../../source/options.rst:73
#: ../../source/options.rst:74
msgid "DataFrame 配置"
msgstr "DataFrame configurations"

Expand Down
1 change: 1 addition & 0 deletions docs/source/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ PyODPS 提供了一系列的配置选项,可通过 ``odps.options`` 获得,
"default_project", "默认 Project", "None"
"logview_host", "LogView 主机名", "None"
"logview_hours", "LogView 保持时间(小时)", "24"
"use_legacy_logview", "使用旧版 LogView 地址,None 表示自动根据 Endpoint 处理", "None"
"quota_name", "提交任务时使用的计算 Quota 名称", "None"
"local_timezone", "使用的时区,None 表示不处理,True 表示本地时区,False 表示 UTC,也可用 pytz 的时区", "None"
"lifecycle", "所有表生命周期", "None"
Expand Down
4 changes: 2 additions & 2 deletions odps/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2024 Alibaba Group Holding Ltd.
# Copyright 1999-2025 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version_info = (0, 12, 1, 1)
version_info = (0, 12, 2)
_num_index = max(idx if isinstance(v, int) else 0 for idx, v in enumerate(version_info))
__version__ = ".".join(map(str, version_info[: _num_index + 1])) + "".join(
version_info[_num_index + 1 :]
Expand Down
9 changes: 7 additions & 2 deletions odps/accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2024 Alibaba Group Holding Ltd.
# Copyright 1999-2025 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -535,6 +535,8 @@ def sign_request(self, req, endpoint, region_name=None):
url = req.url[len(endpoint) :]
url_components = urlparse(unquote(url), allow_fragments=False)
self._build_canonical_str(url_components, req)
if self.token is None:
raise TypeError("Cannot sign request with None bearer token")
req.headers["x-odps-bearer-token"] = self.token
if self._last_refresh_time:
req.headers["x-pyodps-token-timestamp"] = str(self._last_refresh_time)
Expand All @@ -546,7 +548,7 @@ def __init__(self, credential_provider):
self.provider = credential_provider
super(CredentialProviderAccount, self).__init__(None, None, None)

def sign_request(self, req, endpoint, region_name=None):
def _refresh_credential(self):
try:
credential = self.provider.get_credential()
except:
Expand All @@ -555,6 +557,9 @@ def sign_request(self, req, endpoint, region_name=None):
self.access_id = credential.get_access_key_id()
self.secret_access_key = credential.get_access_key_secret()
self.sts_token = credential.get_security_token()

def sign_request(self, req, endpoint, region_name=None):
utils.call_with_retry(self._refresh_credential)
return super(CredentialProviderAccount, self).sign_request(
req, endpoint, region_name=region_name
)
Expand Down
32 changes: 17 additions & 15 deletions odps/apis/storage_api/storage_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2024 Alibaba Group Holding Ltd.
# Copyright 1999-2025 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
from enum import Enum
from hashlib import md5
from io import BytesIO, IOBase
from typing import List, Union

try:
import pyarrow as pa
Expand Down Expand Up @@ -621,16 +622,21 @@ def __init__(
table: Table,
rest_endpoint: str = None,
quota_name: str = None,
tags: Union[None, str, List[str]] = None,
):
if isinstance(odps, ODPS) and isinstance(table, Table):
self._odps = odps
self._table = table
self._quota_name = quota_name
self._rest_endpoint = rest_endpoint
self._tunnel_rest = None
else:
if not isinstance(odps, ODPS) or not isinstance(table, Table):
raise ValueError("Please input odps configuration")

self._odps = odps
self._table = table
self._quota_name = quota_name
self._rest_endpoint = rest_endpoint
self._tunnel_rest = None

self._tags = tags or options.tunnel.tags
if isinstance(self._tags, str):
self._tags = self._tags.split(",")

@property
def table(self):
return self._table
Expand All @@ -653,14 +659,10 @@ def _get_resource(self, *args) -> str:
url = self._table.table_resource(endpoint=endpoint, force_schema=True)
return "/".join([url] + list(args))

@staticmethod
def _fill_common_headers(raw_headers=None, tags=None):
def _fill_common_headers(self, raw_headers=None):
headers = raw_headers or {}
tags = tags or options.tunnel.tags
if tags:
if isinstance(tags, str):
tags = tags.split(",")
headers["odps-tunnel-tags"] = ",".join(tags)
if self._tags:
headers["odps-tunnel-tags"] = ",".join(self._tags)
return headers

def create_read_session(
Expand Down
Loading

0 comments on commit 6f5dbfb

Please sign in to comment.