【发布时间】:2019-10-05 12:09:12
【问题描述】:
我正在尝试使用 docker 和 luigi https://hub.docker.com/r/spotify/luigi 进行一些试验
我用 spotify/luigi 创建了一个 docker 容器。我对此很陌生,并且似乎无法通过控制台访问此图像。
我创建了一个共享卷并将其映射到容器的 /luigi/share/
import luigi
import time
class HelloWorld(luigi.Task):
def requires(self):
return None
def output(self):
return luigi.LocalTarget('/luigi/share/helloworld3.txt')
def run(self):
time.sleep(1)
with self.output().open('w') as outfile:
outfile.write('Hello World!\n')
time.sleep(1)
class NameSubstituter(luigi.Task):
name = luigi.Parameter()
def requires(self):
return HelloWorld()
def output(self):
return luigi.LocalTarget(self.input().path + '.name_' + self.name)
def run(self):
time.sleep(1)
with self.input().open() as infile, self.output().open('w') as outfile:
text = infile.read()
text = text.replace('World', self.name)
outfile.write(text)
time.sleep(1)
if __name__ == '__main__':
luigi.run()
这是我使用 python test.py --scheduler-host 192.168.178.48 NameSubstituter 运行的示例代码
当我现在查看另一个具有共享卷的容器时,没有创建任何文本文件。
我有点迷路了……
提前谢谢你
【问题讨论】: