This is a single class library. Users will most likely to use the MetaFrame
class only. So it would be better if we can do that like from metaframe import MetaFrame
, instead of current from metaframe.metaframe import MetaFrame
.
One way to do this is to define MetaFrame
within __init__.py
, or just importing it there. But sometimes this causes some unwanted overheads if importing metaframe.MetaFrame
is costly.
And, if we put package metadata like __version__
, there might be build time dependency problems. metaframe.__init__.py
will be imported at the build time. There should be an error since pyspark
is not a build time dependency. (I did't tested this. Not 100% sure.)
I think we can try lazy module imports to handle this. It's kind of hacky but I used it somewhere else, and saw some similer approaches.
It should be something like
# __init__.py
def __getattr__(name):
if name == "Crawler":
from metaframe.metaframe import MetaFrame
return MetaFrame
But.. this works only for python>3.7 (see PEP-562)