小编Dip*_*pas的帖子

AWS ECS 在一个任务定义中启动多个容器

我有一个带有一个应用程序的 docker 容器,应用程序根据输入参数运行,传递给入口点。我想为 ECS 创建一个任务定义,并在一个任务定义中并行运行多个容器,每个容器具有不同的输入参数。

问题是 - 如果不在任务定义中为我的容器之一设置基本选项,我就无法做到这一点。但是,如果我的基本容器用完,我不想阻止其他人。所有容器都是独立的。

可能的选择是为每个容器创建一个任务定义。但它会花费更多,因为我的应用程序不会使用很多资源。

是否有任何其他解决方案或方法可以在一个任务定义中运行多个容器而不依赖于基本选项?

containers amazon-web-services amazon-ecs docker

5
推荐指数
1
解决办法
8939
查看次数

python-docx 获取标题文本

我想用 Python 从 docx 文件中读取标题文本。我正在使用 python-docx 模块。

如果此功能已经实现,有人可以帮助我做到这一点吗?

我尝试这样做,但没有成功。

from docx import Document

document = Document(path)
section = document.sections[0]
print(section.text)

Error:
    <class 'AttributeError'>'Section' object has no attribute 'text'
Run Code Online (Sandbox Code Playgroud)

和:

from docx import Document

document = Document(path)
header = document.sections[0].header
print(header.text)

Error:
    <class 'AttributeError'>'Section' object has no attribute 'header'
Run Code Online (Sandbox Code Playgroud)

python docx python-docx

4
推荐指数
1
解决办法
1万
查看次数

PySpark使用字典reducebykey

在进行reducebykey转换的情况下,为什么Spark强制从元组列表构建RDD?

reduce_rdd = sc.parallelize([{'k1': 1}, {'k2': 2}, {'k1': -2}, {'k3': 4}, {'k2': -5}, {'k1': 4}])
print(reduce_rdd.reduceByKey(lambda x, y: x + y).take(100))
Run Code Online (Sandbox Code Playgroud)

错误:

for k, v in iterator:
ValueError: need more than 1 value to unpack

    at org.apache.spark.api.python.PythonRunner$$anon$1.read(PythonRDD.scala:166)
    at org.apache.spark.api.python.PythonRunner$$anon$1.<init>(PythonRDD.scala:207)
    at org.apache.spark.api.python.PythonRunner.compute(PythonRDD.scala:125)
    at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:70)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.api.python.PairwiseRDD.compute(PythonRDD.scala:342)
    at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:306)
    at org.apache.spark.rdd.RDD.iterator(RDD.scala:270)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:73)
    at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:41)
    at org.apache.spark.scheduler.Task.run(Task.scala:89)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:242)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Run Code Online (Sandbox Code Playgroud)

如果reduceByKey()打算使用键值对的集合,那么对我来说,每个对都应该驻留在用于键值对的Python对象类型中,而字典不是元组.

python reduce apache-spark rdd pyspark

1
推荐指数
1
解决办法
1464
查看次数