Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions pages/custom-query-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and **Rust**. These procedures are grouped into modules - **query module** files
(either `*.so` or `*.py` files).


# Developing your custom query module
## Developing your custom query module

To develop your custom query module procedures you can follow the guides for each language:

Expand Down Expand Up @@ -58,7 +58,7 @@ would be mapped in the Cypher query language as `example.procedure()` and
Each query module file can contain multiple read and write procedures and functions.


# Modifying the existing query modules
## Modifying the existing query modules

If existing MAGE library modules almost meet your needs, consider modifying them and make a contribution to the Memgraph Mage library.

Expand All @@ -81,15 +81,12 @@ Then, select a language you want to develop in.

{<h3 className="custom-header">Download the MAGE image</h3>}

Run the following command to get the Memgraph and MAGE development Docker image:
Run the following commands to get the Memgraph and MAGE Docker image and download the toolchain used for building modules:

```shell
docker run -p 7687:7687 memgraph/memgraph-mage:<version>-dev
docker run -p 7687:7687 memgraph/memgraph-mage:<version>
```

By running this command, you will get an image with the following tools
installed: `Python3`, `Rust`, `Clang`, `Make`, and `CMake`.

{<h3 className="custom-header">Develop a query</h3>}

When developing with Mage, take a look at the basis of developed [algorithms and utility procedures](https://github.com/memgraph/mage) and extend based on that.
Expand All @@ -106,15 +103,26 @@ Then, select a language you want to develop in.
Use the following command to start the MAGE container:

```shell
docker run --rm -p 7687:7687 --name mage memgraph-mage:version-dev
docker run --rm -p 7687:7687 --name mage memgraph-mage:<version>
```

Be sure to replace the version with the specific version, for example:
Be sure to replace the `<version>` with the specific version, for example:

```shell
docker run --rm -p 7687:7687 --name mage memgraph-mage:1.4-dev
docker run --rm -p 7687:7687 --name mage memgraph-mage:3.1.1
```

{<h3 className="custom-header">Download and install toolchain and development dependencies</h3>}

Run the `make-dev-container.sh` script as `root` within the container to download the current toolchain version and install required `apt` packages:

```shell
docker exec -i -u root mage bash -c "./make-dev-container.sh"
````

By running this command, your your container will have the following tools
installed: `Python3`, `Rust`, `Clang`, `Make`, and `CMake` alongside the toolchain used to build both Memgraph and MAGE.

{<h3 className="custom-header">Copy the files to the container</h3>}

Copy the files to the container named `mage`:
Expand All @@ -125,10 +133,10 @@ Then, select a language you want to develop in.

{<h3 className="custom-header">Enter the container</h3>}

Position yourself inside the container as `root`:
Position yourself inside the container as `memgraph`:

```shell
docker exec -u root -it mage /bin/bash
docker exec -u memgraph -it mage /bin/bash
```
<Callout>

Expand All @@ -144,10 +152,16 @@ Then, select a language you want to develop in.

{<h3 className="custom-header">Build MAGE</h3>}

Build MAGE with the option to copy executables from `mage/dist` to `/usr/lib/memgraph/query_modules`:
Activate the toolchain and build MAGE:

```shell
python3 setup build -p /usr/lib/memgraph/query_modules/
source /opt/toolchain-v6/activate
python3 setup build
```

Then copy executables from `/mage/dist` to `/usr/lib/memgraph/query_modules` as `root`:
```shell
docker exec -i -u root mage bash -c "cp -vr /mage/dist/* /usr/lib/memgraph/query_modules/"
```

{<h3 className="custom-header">Exit the container</h3>}
Expand Down Expand Up @@ -389,6 +403,11 @@ Then, select a language you want to develop in.

</Tabs.Tab>
<Tabs.Tab>

<Callout type="info">
We currently do not produce MAGE images with cuGraph (since version 1.3). If this is something you require, please raise an [issue](https://github.com/memgraph/mage/issues)
</Callout>

<Steps>

{<h3 className="custom-header">Download MAGE source code</h3>}
Expand Down