我postgres:12在 Ubuntu 20.04 下的 AWS 实例上使用 Docker 映像。
postgres-tests:
image: "postgres:12"
restart: always
command: postgres -c 'max_connections=200'
environment:
POSTGRES_DB: "${POSTGRES_DATABASE}"
POSTGRES_USER: "${POSTGRES_USER}"
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
ports:
- "8396:5432"
Run Code Online (Sandbox Code Playgroud)
当运行此容器时,docker-compose up -d它无法启动并出现以下错误:
postgres-tests_1 | popen failure: Cannot allocate memory
postgres-tests_1 | initdb: error: The program "postgres" is needed by initdb but was not found in the
postgres-tests_1 | same directory as "/usr/lib/postgresql/12/bin/initdb".
postgres-tests_1 | Check your installation.
Run Code Online (Sandbox Code Playgroud)
最近的项目部署后突然出现该错误。重要的是,错误仅发生在这个特定的容器上。postgresql:12机器上还有一个容器用于另一个项目,工作正常。
这是我尝试过的:
shmall/ params 相关的建议。shmmax但这些系统参数已经设置为高值: …
我要将数据从 PostgreSQL 数据库迁移到 Yandex 的 ClickHouse。源表中的字段之一是 JSON 类型 - 称为additional_data。因此,PostgreSQL允许我访问JSON属性中如SELECT ...查询与->>和->等。
我需要相同的行为才能在 ClickHouse 存储中的结果表中保留。(即在选择查询和/或使用过滤和聚合子句时解析 JSON 的能力)
这是我CREATE TABLE ...在 ClickHouse 客户端中所做的:
create table if not exists analytics.events
(
uuid UUID,
...,
created_at DateTime,
updated_at DateTime,
additional_data Nested (
message Nullable(String),
eventValue Nullable(String),
rating Nullable(String),
focalLength Nullable(Float64)
)
)
engine = MergeTree
ORDER BY (uuid, created_at)
PRIMARY KEY uuid;
Run Code Online (Sandbox Code Playgroud)
这是如何存储 JSON 可序列化数据的好选择?有任何想法吗?
也许最好将 JSON 数据存储为普通数据,String而不是 …
我正在使用 DigitalOcean Spaces (S3 存储协议),它启用了CDN。
s3 上的任何文件都可以通过给定形式的直接 URL 访问:
https://my-bucket.fra1.digitaloceanspaces.com/<file_key>
Run Code Online (Sandbox Code Playgroud)
如果启用CDN ,则可以通过附加 CDN URL 访问该文件:
https://my-bucket.fra1.cdn.digitaloceanspaces.com/<file_key>
Run Code Online (Sandbox Code Playgroud)
其中fra1是region_name。
当我使用boto3SDK for Python 时,文件 URL 如下(由 boto3 生成):
https://fra1.digitaloceanspaces.com/my-bucket/<file_key>
# just note that bucket name is no more a domain part!
Run Code Online (Sandbox Code Playgroud)
这种格式也可以正常工作。
但是,如果启用 CDN - 文件 url 会导致错误:
EndpointConnectionError: Could not connect to the endpoint URL: https://fra1.cdn.digitaloceanspaces.com/my-bucket/<file_key>
Run Code Online (Sandbox Code Playgroud)
假设端点_url 已更改为
default_endpoint=https://fra1.digitaloceanspaces.com
到
default_endpoint=https://fra1.cdn.digitaloceanspaces.com
如何使用正确的 URL 连接到 CDN 而不会出现错误?为什么 boto3 使用不同的 URL 格式?在这种情况下可以应用任何解决方法吗?
代码:
s3_client …Run Code Online (Sandbox Code Playgroud) Airflow 2.0 在我的开发环境中正在排队但未启动任务。
DAG 和池设置有效,但每个 dag 中的所有任务都是在queued我触发它们时才运行的,并且从未运行。
当我输入 时airflow celery worker,出现以下错误:
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.8/site-packages/airflow/__main__.py", line 40, in main
args.func(args)
File "/usr/local/lib/python3.8/site-packages/airflow/cli/cli_parser.py", line 48, in command
return func(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/airflow/utils/cli.py", line 92, in wrapper
return f(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/airflow/cli/commands/celery_command.py", line 188, in worker
_run_worker(options=options, skip_serve_logs=skip_serve_logs)
File "/usr/local/lib/python3.8/site-packages/airflow/cli/commands/celery_command.py", line 94, in _run_worker
celery_app.worker_main(options)
File "/usr/local/lib/python3.8/site-packages/celery/app/base.py", line 365, in worker_main
return instantiate(
File "/usr/local/lib/python3.8/site-packages/celery/bin/base.py", line 283, in …Run Code Online (Sandbox Code Playgroud) python celery directed-acyclic-graphs airflow airflow-scheduler
我正在致力于sitemap.xmlDjango + Wagtail 项目的生成。
我xml通过重写方法实现了文章的生成get_sitemap_urls。但问题是Wagtail 站点地图生成器不会“看到”博客标签 url(不会将它们添加到站点地图中)。
...
from taggit.models import TaggedItemBase
class BlogPageTag(TaggedItemBase):
content_object = ParentalKey(
'BlogInnerPage',
related_name='tagged_items',
on_delete=models.CASCADE,
)
class BlogInnerPage(Page):
icon = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=False,
on_delete=models.SET_NULL,
related_name='+'
)
...
post_date = models.DateTimeField(auto_now_add=True, null=True)
tags = ClusterTaggableManager(through=BlogPageTag, blank=False)
@property
def sidebar_tags(self):
blogs = BlogInnerPage.objects.live().all()
tags = {}
for post in blogs:
for tag in post.tags.all():
if tag.slug in tags:
tags[tag.slug]['count'] += 1
else:
tags[tag.slug] = {
'name': tag.name,
'count': …Run Code Online (Sandbox Code Playgroud) 我创建了一个 DAG,它使用 cron 语法每 5 分钟执行一次。此外,池是为此 dag 创建的,只有一个插槽。
我试图重新启动服务器/调度程序并重置数据库。目前,DAG 在 UTC 时间运行。另外,我试图设置我的本地时区,即“欧洲/明斯克”(UTC+3)——但它没有任何效果。
import random
import time
import airflow
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': airflow.utils.dates.days_ago(2),
'email': ['airflow@example.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
'pool': 'download',
# 'priority_weight': 10,
# 'queue': 'bash_queue',
}
params = {
'table': 'api_avitoimage',
}
dag = DAG(
dag_id='test_download_avitoimage',
default_args=default_args,
schedule_interval='*/5 * * * *',
) …Run Code Online (Sandbox Code Playgroud) 假设我有用于与提取的行的坐标的列表cv2.HoughLinesP从边缘掩模从获得的cv2.Canny边缘检测器。
lines = [[x1,y1,x2,y2] , ... ]
Run Code Online (Sandbox Code Playgroud)
如果一条线的斜率在±60?以内,则将其分类为水平线。水平方向的 所有其他斜坡均被丢弃。
如果一条线的斜率在±5?以内,则将其分类为垂直线。垂直方向。所有其他斜坡均被丢弃。
import numpy as np
import cv2
def detect_line_angle(line):
x1, y1, x2, y2 = line
angle = np.arctan2(x2 - x1, y2 - y1)
# angle = angle * 180 / 3.14
return angle
def get_lines_from_edge_mask(edge_mask):
result = []
lines = cv2.HoughLinesP(edge_mask, 1, np.pi / 180, 30, maxLineGap=5)
for line in lines:
result.append(line[0])
return result
def is_horizontal(theta, delta=1.05):
return True if (np.pi - delta) <= theta …Run Code Online (Sandbox Code Playgroud)