Return function to luigi output method

156 views Asked by At

I am trying to return path of input zip archive. I am stuck on implementing luigi output method:

def get_zip_path() -> str:
    input_zip = ''
    with open("/input/index.json", "r") as input_index:
        json_str = json.load(input_zip)   
        input_zip = json_str["source"]
    return input_zip

class Input(luigi.Task):
"""
Unpack dicom zip archive to workdir
"""
    @property
    def zip_path():
        return get_zip_path()

    def output(self):
        return luigi.LocalTarget(self.zip_path())

I want class Input() return method output the string of zip path "/input/zipfile.zip" but get the error

TypeError: zip_path() takes 0 positional arguments but 1 was given
1

There are 1 answers

0
0x26res On

It's a python error rather than an issue with luigi

Try this:

    @property
    def zip_path(self):
        return get_zip_path()