Commit Graph

209 Commits

Author SHA1 Message Date
Teon Banek
fbdcad1106 Implement calling Python procedures
Summary:
You should now be able to invoke query procedures written in Python. To
test the example you can run memgraph with PYTHONPATH set to `include`.
For example, assuming you are in the root of the repo, run this command.

    PYTHONPATH=$PWD/include ./build/memgraph --query-modules-directory=./query_modules/

Alternatively, you can set a symlink inside the ./query_modules to point
to `include/mgp.py`, so there's no need to set PYTHONPATH. For example,
assuming you are in the root of the repo, run the following.

    cd ./query_modules
    ln -s ../include/mgp.py
    cd ..
    ./build/memgraph --query-modules-directory=./query_modules/

Depends on D207

Reviewers: mferencevic, ipaljak, dsantl

Reviewed By: ipaljak

Subscribers: buda, tlastre, pullbot

Differential Revision: https://phabricator.memgraph.io/D2708
2020-03-06 16:25:51 +01:00
Teon Banek
d531e44bef Merge Invalid.*Error into InvalidContextError
Summary:
There's no need for so many Exception subclasses, because the root cause
is always the same.

Depends on D2700

Reviewers: mferencevic, ipaljak

Reviewed By: mferencevic, ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2701
2020-03-04 12:52:05 +01:00
Teon Banek
74d9dd0b0a Implement mgp.Path
Reviewers: ipaljak, mferencevic

Reviewed By: ipaljak, mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2700
2020-03-04 12:51:06 +01:00
Teon Banek
b922ca75d0 Add mgp_path_equal to C API
Reviewers: ipaljak, mferencevic

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2697
2020-03-02 13:19:22 +01:00
Teon Banek
4049b9d10a Add mgp_path_copy to C API
Reviewers: ipaljak

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2694
2020-02-28 10:57:36 +01:00
Ivan Paljak
b6b6403b06 Implement PyEdgesIterator and integrate with PyVertex
Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2692
2020-02-27 15:57:02 +01:00
Teon Banek
ad892f2db3 Support typing annotations in Python Query Modules
Reviewers: mferencevic, ipaljak, tlastre

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2689
2020-02-27 13:18:57 +01:00
Ivan Paljak
32e56684db Add Python class for mgp_vertex
Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2688
2020-02-26 14:01:43 +01:00
Teon Banek
e7f363ecbe Add Python class for mgp_edge
Reviewers: teon.banek, ipaljak, mferencevic

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2679
2020-02-25 10:26:08 +01:00
Teon Banek
34db077cbd Register Python procedures
Summary:
With this diff you should now be able to register `example.py` and read
procedures found there. The procedures will be listed through `CALL
mg.procedures() YIELD *` query, but invoking them will raise
`NotYetImplemented`.

If you wish to test this, you will need to run the Memgraph executable
with PYTHONPATH set to the `include` directory where `mgp.py` is found.
Additionally, you need to pass `--query-modules-directory` flag to
Memgraph, such that it points to where it will find the `example.py`.

For example, when running from the root directory of Memgraph repo, the
shell invocation below should do the trick (assuming `./build/memgraph`
is where is the executable). Make sure that `./query_modules/` does not
have `example.so` built, as that may interfere with loading
`example.py`.

    PYTHONPATH=$PWD/include ./build/memgraph --query-modules-directory=./query_modules/

Reviewers: mferencevic, ipaljak, llugovic

Reviewed By: mferencevic, ipaljak, llugovic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2678
2020-02-19 14:35:22 +01:00
Teon Banek
ad740e4ae2 Add _mgp.Graph and _mgp.VerticesIterator to embedded Python
Reviewers: llugovic, ipaljak, mferencevic

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2669
2020-02-14 10:00:55 +01:00
Teon Banek
4281a57923 Stub out full Python API for Query Modules
Summary:
This is the Python 3.5+ version of our C API found in
include/mg_procedure.h. It should strive to be simple to use, but very
hard to misuse. The Python API avoids almost all memory management
issues found in the C API, so it is automatically less error prone.

Unfortunately, we cannot avoid the issue of having some objects being
alive only during the execution of a custom procedure. For such objects
we have a `Invalid<Object>Error` exception types. The Python API should
fairly easily check the validity because all such objects are related to
ProcCtx in some way. Our C/C++ part will push 1 instance of ProcCtx each
time a Python procedure is invoked and can therefore easily change
ProcCtx to be invalid. This can be as simple as changing the
implementation pointer of ProcCtx to NULL.

Reviewers: mferencevic, ipaljak, tlastre, dsantl, buda

Reviewed By: mferencevic, tlastre

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2650
2020-02-04 13:10:10 +01:00
Teon Banek
dd30522b2a Update mgp_result_new_record documentation
Reviewers: mferencevic, ipaljak

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2575
2019-11-28 14:58:46 +01:00
Teon Banek
df6ce53c67 query/procedure: Expose vertex ID through C API
Reviewers: mferencevic, ipaljak

Reviewed By: ipaljak

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2568
2019-11-26 17:06:31 +01:00
Teon Banek
019b6cddaa Use a custom value printer for procedure signature
Reviewers: mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2557
2019-11-21 11:17:00 +01:00
Teon Banek
5354a11a00 Add registering multiple procedures in query modules
Reviewers: mferencevic, dsantl, ipaljak

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2551
2019-11-21 10:13:09 +01:00
Teon Banek
1dc97a37f8 Cache globally allocated mgp_type instances
Summary:
This simplifies the C API and reduces total allocations done when
constructing a type.

Reviewers: mferencevic, ipaljak

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2550
2019-11-15 10:44:55 +01:00
Teon Banek
9c095501d8 query/procedure: Add type system for Cypher
Summary:
The type system is modelled after "CIP2015-09-16"
https://github.com/opencypher/openCypher/blob/master/cip/1.accepted/CIP2015-09-16-public-type-system-type-annotation.adoc

This is needed for registering procedures and their signatures. The
users will be able to specify what a custom procedure accepts and
returns. All of this needs to be available for inspection during
runtime. Therefore, this diff implements printing types as a user
presentable string. In the future, we will probably want to add type
checking through these types, because openCypher requires type checking
on values passed in and returned from custom procedures.

Reviewers: mferencevic, ipaljak, dsantl

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2544
2019-11-13 14:24:21 +01:00
Teon Banek
283a91cc60 Integrate loading openCypher module procedures
Summary:
All mgp_* symbols are exported from Memgraph executable, no other
symbols should be visible.

The primary C API header, mg_procedure.h, is now part of the
installation. Also, added a shippable query module example.

Directory `query_modules` is meant to contain sources of modules we
write and ship as part of the installation. Currently, there's only an
example module, but there may be potentially more. Some modules could
only be installed as part of the enterprise release.

For Memgraph to load custom procedures, it needs to be started with a
flag pointing to a directory with compiled shared libraries implementing
those procedures.

Reviewers: mferencevic, ipaljak, llugovic, dsantl, buda

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2538
2019-11-07 15:23:02 +01:00
Teon Banek
2e1063bbdb Introduce mgp_memory to mg_procedure API
Summary:
This makes the concrete memory resource an explicit argument in custom
procedures. Unfortunately, the API is a bit uglier but at least we don't
have to worry about threading, global state or similar. This is the
primary reason for this change as we would probably like to allow
procedures to spawn threads to compute stuff in a parallel fashion.

Reviewers: mferencevic, dsantl

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2495
2019-10-18 13:37:54 +02:00
Teon Banek
7afa4fd7b3 Add C API for working with graph constructs in procedures
Reviewers: mferencevic, ipaljak, dsantl

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2469
2019-10-15 15:06:35 +02:00
Teon Banek
103f51d3ec Add C API for creating a procedure result
Reviewers: mferencevic, ipaljak, dsantl

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2464
2019-10-04 10:27:39 +02:00
Teon Banek
d385ebfa15 Add C API for raw memory allocations in procedures
Reviewers: ipaljak, dsantl, mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2461
2019-10-02 10:28:49 +02:00
Teon Banek
6f25e43b52 Stub out C API for working with mg_value in custom procedures
Summary:
The `mg_value` is the main data type used in upcoming custom procedures. Each
custom procedure will receive arguments as an array of `mg_value` instances.
The results of custom procedures will also be built as `mg_value` instances.

We should strive to have as simple and straightforward C API for custom
procedures, because we want to limit the possibility of errors and bugs on the
user facing side. Custom procedures will run in Memgraph and as such can cause
crashes and potentially a lot of nasty stuff. The burden is on the writer of
custom procedures not to mess things up, so we should make messing things up
from the C API hard if not impossible to do.

Reviewers: mferencevic, ipaljak, dsantl

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2443
2019-09-25 15:46:25 +02:00
Marko Budiselic
e7f5bd4c21 antlr integration, *.hpp and *.cpp inside src dir, cleanup
Summary: antlr integration, *.hpp and *.cpp inside src dir, cleanup

Test Plan: manual

Reviewers: mislav.bradac, dgleich, florijan

Reviewed By: florijan

Subscribers: pullbot, buda

Differential Revision: https://phabricator.memgraph.io/D49
2017-02-17 16:20:31 +01:00
florijan
a11ebef9c5 Properties system and core storage major refactor. STABLE STATE, unit tests added. 2017-02-16 17:43:39 +01:00
florijan
55f1912910 Properties refactoring: STABLE STATE. Memgraph compiles. Properties are out. Tests are in progress. 2017-02-16 15:47:55 +01:00
florijan
70a8b93b0b Major properties system and database accessor refactor: first stable state (compiles). 2017-02-15 14:10:16 +01:00
florijan
9e09186d30 Properties refactor in progress. Dev merge (query execution landed). UNSTABLE STATE 2017-02-14 10:17:03 +01:00
Marko Budiselic
0fcda94162 Hardcoded query infrastructure - first concrete version - USEFUL FOR: POCs & pilots
Summary: Hardcoded query infrastructure - first concrete version - USEFUL FOR: POCs & pilots

Test Plan: manual + jenkins

Reviewers: sale, florijan

Reviewed By: florijan

Subscribers: pullbot, buda

Differential Revision: https://phabricator.memgraph.io/D45
2017-02-14 09:40:31 +01:00
florijan
c36883003a Merge conficts resolved 2017-02-13 09:23:34 +01:00
Florijan Stamenkovic
9adf5699d9 Major properties and storage refactoring in progress. UNSTABLE STATE 2017-02-13 09:21:35 +01:00
Florijan Stamenkovic
6320784687 Major properties and storage refactoring in progress. UNSTABLE STATE 2017-02-11 07:51:02 +01:00
Florijan Stamenkovic
ee523d5080 Continuing major refactor, UNSTABLE STATE. Merged current dev 2017-02-07 13:22:07 +01:00
Florijan Stamenkovic
6d981c9cd0 Skiplist minor bugfixes
Summary: Skiplist - fixed support for insertion of (const T&) objects. Before only (T&&) worked.

Test Plan: Tested already with slightliy modified tests.

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot, florijan, buda

Differential Revision: https://phabricator.memgraph.io/D48
2017-02-07 13:15:56 +01:00
Florijan Stamenkovic
b38704391c Typed-value migration in progress. UNSTABLE STATE 2017-02-06 12:40:55 +01:00
Florijan Stamenkovic
b374ae1dbb storage and database major refactor in progress, also switching from properties to typed-value system. a lot of overdesigned functionalities cut down, new implementations just started. VERY UNSTABLE STATE 2017-02-04 09:01:56 +01:00
Florijan Stamenkovic
10c7514c8a storage/model - added typed_value system and tests. Modified utils slightly (backward compatible).
Summary: Added TypedValue system.

Test Plan: ???

Reviewers: sale, buda

Reviewed By: buda

Subscribers: pullbot, florijan, buda, sale

Differential Revision: https://phabricator.memgraph.io/D46
2017-02-02 15:48:16 +01:00
Florijan Stamenkovic
46dbc08d4e Merge branch 'MG_typed_values-new_implementation' into MG_typed_value_migration 2017-02-02 10:37:01 +01:00
Florijan Stamenkovic
261797ea9c storage/model/typed_value - fixes after code review 2017-02-02 10:29:14 +01:00
Florijan Stamenkovic
e508482ab9 Deleted storage/model/properties, started refactoring 2017-02-02 09:03:48 +01:00
Florijan Stamenkovic
b329225322 storage/model - added typed_value system and tests. Modified utils slightly (backward compatible).
Summary: Added TypedValue system.

Test Plan: ???

Reviewers: sale, buda

Subscribers: florijan, buda, sale

Differential Revision: https://phabricator.memgraph.io/D46
2017-02-01 14:05:08 +01:00
sale
99b8a4f234 Added Skiplist ReverseIterator, Distance Approximation Prototype and documented some stuff
Summary: Skiplist ReverseIterator and Distance Approximation

Test Plan: manual

Reviewers: florijan, buda

Reviewed By: buda

Subscribers: pullbot, florijan, buda

Differential Revision: https://phabricator.memgraph.io/D44
2017-01-31 15:16:38 +01:00
Florijan Stamenkovic
4f649c9821 storage - UniqueObjectStore class added (with unit tests)
Summary: storage - UnoqueObjectStore documentation improved

Test Plan: no test plan

Reviewers: sale, buda

Reviewed By: sale, buda

Subscribers: pullbot, florijan, sale, buda

Differential Revision: https://phabricator.memgraph.io/D43
2017-01-24 14:46:11 +01:00
Florijan Stamenkovic
dee15acd1e data_structures/union_find - minor refactors and tests added
Summary: Minor refactor of the union_find data structure. Testing added for union_find.

Test Plan: Manual

Reviewers: sale, buda

Reviewed By: sale, buda

Subscribers: pullbot, florijan, sale, buda

Differential Revision: https://phabricator.memgraph.io/D42
2017-01-23 15:20:09 +01:00
sale
45c31b08e7 Bug fix arcconfig
Summary: Merge branch 'dev' of https://phabricator.memgraph.io/diffusion/MG/memgraph into dev

Test Plan: manual

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot, buda

Differential Revision: https://phabricator.memgraph.io/D40
2017-01-23 12:27:50 +01:00
Marko Budiselic
d7de5cfe08 merge + conflict resolution 2017-01-13 11:31:56 +01:00
Marko Budiselic
b1c293ef72 Review updates (documentation, namespace naming) 2017-01-12 19:42:52 +01:00
sale
d475b79a58 Merge 2017-01-11 09:18:10 +00:00
Marko Budiselic
057af7ac14 Much more serious implementation of FSWatcher
Summary: Much more serious implementation of FSWatcher

Test Plan: ctest -R fswatcher

Reviewers: dtomicevic, sale

Subscribers: buda

Differential Revision: https://phabricator.memgraph.io/D33
2017-01-08 01:07:12 +01:00