How can I load MAGE query modules in Memgraph? Is there a difference if a query module is written in Python or C?
Query modules can be written using C API ( .so modules), and Python API ( .py modules). Each file corresponds to one query module with one or more procedures within them. The names of these files will be mapped to the query module names. For example, a procedure node_connectivity in nxalg.py will be mapped to nxalg.node_connectivity() in the Cypher query language.
Once you start Memgraph, it will attempt to load query modules from all .so and .py files from the default (/usr/lib/memgraph/query_modules and /var/lib/memgraph/internal_modules) directories.
MAGE modules are located at /usr/lib/memgraph/query_modules and custom modules developed via Memgraph Lab at /var/lib/memgraph/internal_modules.
Memgraph can load query modules from additional directories if their path is added to the --query-modules-directory flag in the main configuration file (/etc/memgraph/memgraph.conf) or supplied as a command-line parameter (e.g. when using Docker).
If you are supplying the additional directory as a parameter, do not forget to include the path to /usr/lib/memgraph/query_modules, otherwise queries from that directory will not be loaded when Memgraph starts.
If a certain query module was added while Memgraph was already running, you need to load it manually using the mg.load("module_name") procedure within a query:
CALL mg.load("py_example");
If you want to reload all existing modules and load any newly added ones, use mg.load_all():
CALL mg.load_all();
You can check if the query module has been loaded by using the mg.procedures() procedure within a query:
CALL mg.procedures() YIELD *;
How can I load MAGE query modules in Memgraph?