Local file Luigi LocalTarget

I'm having trouble writing binary LocalTargetin the Luigi pipeline in my project. I highlighted the problem here:

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]))

I tried to open like 'w'and 'wb', but I keep getting the following error:

TypeError: write() argument must be str, not bytes

I am using python 3.5.1 and my version of luigi is 2.1.1

+4
source share
1 answer

The problem was the format LocalTarget. Change it to:

return luigi.LocalTarget('test.npz', format=luigi.format.Nop)

solved a problem. However, this was not in the documentation.

+4
source

Source: https://habr.com/ru/post/1652680/


All Articles