我有一个 Airflow DAG,有两个任务:
他们自己工作得很好。我故意在 pandas Dataframe 中创建了一个拼写错误,以了解on_failure_callback
其工作原理并查看它是否被触发。从日志来看似乎没有:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1197, in handle_failure
task.on_failure_callback(context)
TypeError: on_failure_callback() takes 0 positional arguments but 1 was given
Run Code Online (Sandbox Code Playgroud)
为什么不on_failure_callback
工作?
以下是 DAG 的直观表示:
这是代码:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 1197, in handle_failure
task.on_failure_callback(context)
TypeError: on_failure_callback() takes 0 positional arguments but 1 was given
Run Code Online (Sandbox Code Playgroud) 我按照 Next.js 文档中的说明使用 Docker 启动服务器: https: //nextjs.org/docs/deployment#docker-image
使用 http 加载站点可以工作,但 https 返回 SSL 协议错误。
我详细做了什么:
在我的 DigitalOcean Ubuntu 22.4 服务器上配置了 NGINX 和 cerbot(请注意,该指南适用于 Ubuntu 20)https://certbot.eff.org/instructions?ws=nginx&os=ubuntufocal
复制Dockerfile
并.dockerignore
从文档中链接到我的项目的示例项目:https://github.com/vercel/next.js/tree/canary/examples/with-docker
构建图像并将其上传到服务器。
在服务器上启动镜像:docker run -p 80:3000 -p 443:3000 my_image
HTTP 工作得很好 ( https://mysite.mydomain
)。使用 HTTPS 时,我会遇到错误,例如ERR_SSL_PROTOCOL_ERROR
在 Chrome 和SSL_ERROR_RX_RECORD_TOO_LONG
Firefox 上。
有任何想法吗?
我正在使用 Python 标准日志配置,并结合yaml
使用以下dictConfig()
功能加载配置文件:
import logging
import yaml
with open('logging.yaml','r') as f:
logConfig = yaml.safe_load(f.read())
logging.config.dictConfig(logConfig)
Run Code Online (Sandbox Code Playgroud)
由于python中的增量日志配置限制了功能,因此每个日志文件都必须包含最少量的信息,如下所示:
version: 1
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: simple
loggers:
my_module:
level: ERROR
root:
level: INFO
handlers: [console]
Run Code Online (Sandbox Code Playgroud)
这要么迫使人们记住这一点,将其存储在某处,要么每次都查找。由于这些都不适合我,我想找到一种方法来生成它。这让我想到了一个问题:
有没有办法将当前(或基本)日志配置作为字典获取?
通过运行以下代码,这将使创建初始配置文件变得容易,只需删除/编辑您想要的内容:
import logging
import yaml
logConfig = logging.get_current_config_as_a_dictionary()
with open('logging.yaml','w') as f:
f.write(yaml.dump(logConfig))
Run Code Online (Sandbox Code Playgroud)
Yaml 当然只是我个人的喜好,同样的问题可以针对 JSON 之类的内容发布。
我想在我的requirements.txt
for中设置依赖项tensorflow~=2.5.0
。截至撰写本文时,tensorflow==2.5.0
尚未发布。可用的最新版本是候选版本tensorflow==2.5.0rc3
。我如何简洁地告诉pip
“安装最新的tensorflow
2.5.x 版本,包括候选版本”?
到目前为止我尝试过的:
tensorflow~=2.5.0
ERROR: Could not find a version that satisfies the requirement tensorflow~=2.5.0 (from versions: 2.5.0rc0, 2.5.0rc1, 2.5.0rc2, 2.5.0rc3)
ERROR: No matching distribution found for tensorflow~=2.5.0
Run Code Online (Sandbox Code Playgroud)
tensorflow>2.4.1
ERROR: Could not find a version that satisfies the requirement tensorflow>2.4.1 (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 1.15.5, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, …
Run Code Online (Sandbox Code Playgroud) 这是How to set DEFAULT ON UPDATE CURRENT_TIMESTAMP in mysql with sqlalchemy? 的姐妹问题?,但专注于 Postgres 而不是 MySQL。
假设我们要创建一个表users
,datemodified
其中的一列在更新行时默认更新为当前时间戳。MySQL的姐妹PR中给出的解决方案是:
user = Table(
"users",
Metadata,
Column(
"datemodified",
TIMESTAMP,
server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
),
)
Run Code Online (Sandbox Code Playgroud)
如何使用 Postgres 后端获得相同的功能?
CSS 函数如何clamp()
与 TailwindCSS 一起使用以fontSize
在最小值和最大值之间进行线性缩放?
对与 Next.js 集成特别感兴趣。