How to pass parameter of cache_directory?

Maybe very basic question, but I can’t find how to pass cache_directory parameter to DatasetReader class.

Currently, the following works.

class MyIterator(DatasetReader):
    def __init__(self, args, token_indexers=None, cached_dir=None):
        super().__init__(lazy=args.allen_lazyload)
        self.args = args
        ...
    
    @overrides
    def _read(self, train_dev_testflag) -> Iterator[Instance]:
        ...

    @overrides
    def text_to_instance(self, data = None) -> Instance:
        ...

if __name__ == '__main__':
    opts = argparselike()
    reader = MyIterator(args=opts)

but this don’t work.

class MyIterator(DatasetReader):
    def __init__(self, args, token_indexers=None, cached_dir=None):
        super().__init__(lazy=args.allen_lazyload, cache_directory=cached_dir)
        self.args = args
        ...
    
    @overrides
    def _read(self, train_dev_testflag) -> Iterator[Instance]:
        ...

    @overrides
    def text_to_instance(self, data = None) -> Instance:
        ...

if __name__ == '__main__':
    opts = argparselike()
    reader = MyIterator(args=opts, token_indexers=None,  cached_dir=args.cache_dirpath)

What I mean is that I can’t pass parameter cache_directory and can’t cache instances.
If you’d know how to solve this, I’d appreciate it much.
Thanks.

In version 0.9, you needed to call reader.cache_data(args.cache_dirpath) after instantiating MyIterator. The cache_directory parameter was added after 0.9, and you need to be using the latest master in order to use it.

Calling cache_data after instantiating MyIterator, before calling _read works. Thanks for your advice.