SeaTable 3.3 版 Python 运行器升级说明

脚本运行环境版本说明

seatable 升级到 3.3,与之对应的划分的功能版本为

  • faas-scheduler: 2.2.2
  • python runner 服务:2.0.5
  • python runner 镜像: 始终使用最新版本(latest), 目前是 2.6.2, 该版本中包含最新版的SeaTable Python SDK

升级步骤

Faas-scheduler

因为不涉及数据库升级,所以直接拉最新的镜像重启即可,具体详见文档

Python runner 服务

在此链接中直接按版本下载解压升级,配置详见此处

Python runner 镜像

直接拉取最新的或者按版本拉取 seatable/python-runner:<tag/version> 镜像,在 python runner 服务中配置使用

升级内容

可以设置脚本超时时间

在 faas-scheduler 服务 和 python-runner 服务中分别增加同一个配置

SUB_PROCESS_TIMEOUT = 60 * 15  # 单位为秒,脚本最长运行 15 分钟

运行脚本时可以使用部分 docker run 参数

在 python-runner 服务中运行脚本时候可能需要挂载机器上某个目录,可能需要连接某个网络,现支持配置参数来为启动脚本时满足这些需求。

例如需要本地目录挂载

OTHER_OPTIONS = [
    "--volume=/home/seatable:/data"  # 宿主机 /home/seatable 挂载到容器内 /data
]

类似的,如果需要其他参数,可以参照 docker 官方文档

Python SDK 相关升级说明

dateutils 中增加 Quarter 类

Python runner 镜像中的 seatable SDK 支持 Quarter 类 以便更好支持用户使用

seatable_api.date_utils.DateQuarter

Base 增加 toast 通知的 API

Python runner 镜像中的 seatable SDK 支持向用户界面弹出 toast 通知的接口

Base.send_toast_notification(user_id, msg, toast_type=‘success’)

  • user_id: the email of related user, who will recieve message
  • msg: message content
  • toast_type: success/danger/warning, default success

贡献一个示例代码:

from seatable_api import Base, context

server_url = context.server_url
api_token = context.api_token
user_id = context.current_user_id

# 获取表格授权
base = Base(api_token, server_url)
base.auth()
base.send_toast_notification(user_id, '通知消息', toast_type='success')

版主的代码引号是中文的,会报错。 :blush: