Closed tylertownsend closed 4 years ago
@gbomarito So these imports will be exactly the same as before. For (probably trivial) clarity, see below
import bingo.symbolic_regression.agraph.backend as pyBackend
try:
from bingocpp.build import symbolic_regression as cppBackend
except ImportError:
print("Could not import C++ modules)
This allows people who are not developing bingo, but are wanting to build on top of it or just use it like other ML libraries (i.e. tensorflow) to import the things the would need to get their app running. https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/__init__.py
For example, someone who is just trying to get their program running doesn't need to import backend.py
or maps.py
so we really don't need them to know where they are located. So by having all the necessary modules in the init, they can simply just do the following
from bingo.symbolic_regression import \
AGraph as AGraph,
ComponentGenerator as ComponentGenerator,
AGraphGenerator as AGraphGenerator,
AGraphMutation as AGraphMutation,
AGraphCrossover as AGraphCrossover
The developers trying to run a symbolic regression program can know everything in symbolic_regression import is necessary to do symbolic regression.
Two side notes:
So I think I get it. The point is that users won't care if they're using cpp or python, and developers can do the more extensive imports, right?
I guess I was just thinking ahead to our performance benchmarks, and wondering if
import bingo.symbolic_regression.agraph.backend as pyBackend
would actually load the cpp. Am I right that it won't because there is no submodule agraph
in bingocpp?
and yes, I agree with your two side notes
This PR requires the new name convention for the pybind modules defined in bingocpp. This uses the init file import modules from the symbolic_regression package and will use the C++ bindings by default if they are built correctly. This requires the user to import only the necessary tools from the symbolic_regression directory and will not require them to know where the C++ modules are built and how to import them correctly.