YAMLFileCatalog `text` argument is broken
jim22k opened this issue · comments
YAMLFileCatalog(path=None, text=None, autoreload=True, **kwargs)
The text
argument that is broken. Attempting to pass a YAML string leads to several errors:
self._dir
is not set- This is only set further down in
_load()
- This is only set further down in
self.getenv
is not set- This is set during base
Catalog.__init__()
- This is set during base
To make it work, YAMLFileCatalog.__init__
would need to look like:
self.path = path
if text:
self._dir = "text_only" # <-- this is new
self.autoreload = False
else:
self.autoreload = autoreload # set this to False if don't want reloads
self.filesystem = kwargs.pop('fs', None)
self.access = "name" not in kwargs
super(YAMLFileCatalog, self).__init__(**kwargs)
if text: # <-- this is new
self.name = self.name or "yaml_text_cat" # <-- this is new
self.parse(text) # <-- this was moved
Can we remove it?
Should this be fixed? Or should the text=None
argument simply be removed?
All the tests pass with it gone, so unless a dependent package is using this argument (which seems unlikely with the broken state), I propose that it should be removed.
It seems that it should probably be removed if it doesn't work and isn't tested. Maybe the argument should be kept in the signature for one release cycle and a depr error given if it is not None. Given that text can be put into a io.String/BytesIO or into fsspec's memory:// filesystem, there really isn't a reason to have another code path.
I'll add the deprecation warning for now. We can remove the argument after the next release.