Luigi LocalTarget二进制文件

Álv*_*rco 8 python-3.x luigi

LocalTarget在项目中的Luigi管道中编写二进制文件时遇到了麻烦.我在这里解决了这个问题:

class LuigiTest(luigi.Task):
    def output(self):
        return luigi.LocalTarget('test.npz')

    def run(self):
        with self.output().open('wb') as fout:
            np.savez_compressed(fout, array=np.asarray([1, 2, 3]))
Run Code Online (Sandbox Code Playgroud)

我尝试打开'w','wb'但我不断收到以下错误:

TypeError: write() argument must be str, not bytes
Run Code Online (Sandbox Code Playgroud)

我使用的是python 3.5.1,我的luigi版本是2.1.1

Álv*_*rco 10

问题在于格式LocalTarget.将其更改为:

return luigi.LocalTarget('test.npz', format=luigi.format.Nop)
Run Code Online (Sandbox Code Playgroud)

解决了这个问题.但是文档中没有任何相关内容.