Skip to content

Commit

Permalink
Update reference guide (#241)
Browse files Browse the repository at this point in the history
* Update reference guide

* Update CODEOWNERS
  • Loading branch information
katarinasupe authored Apr 18, 2023
1 parent 367f2ca commit 07f2981
Show file tree
Hide file tree
Showing 24 changed files with 1,610 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Josipmrden @katarinasupe @brunos252 @as51340
* @Josipmrden @katarinasupe @brunos252 @as51340 @antepusic
106 changes: 106 additions & 0 deletions docs/reference/gqlalchemy/connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
sidebar_label: connection
title: gqlalchemy.connection
---

## Connection Objects

```python
class Connection(ABC)
```

#### execute

```python
@abstractmethod
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
```

Executes Cypher query without returning any results.

#### execute\_and\_fetch

```python
@abstractmethod
def execute_and_fetch(
query: str,
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
```

Executes Cypher query and returns iterator of results.

#### is\_active

```python
@abstractmethod
def is_active() -> bool
```

Returns True if connection is active and can be used.

## MemgraphConnection Objects

```python
class MemgraphConnection(Connection)
```

#### execute

```python
@database_error_handler
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
```

Executes Cypher query without returning any results.

#### execute\_and\_fetch

```python
@database_error_handler
def execute_and_fetch(
query: str,
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
```

Executes Cypher query and returns iterator of results.

#### is\_active

```python
def is_active() -> bool
```

Returns True if connection is active and can be used.

## Neo4jConnection Objects

```python
class Neo4jConnection(Connection)
```

#### execute

```python
def execute(query: str, parameters: Dict[str, Any] = {}) -> None
```

Executes Cypher query without returning any results.

#### execute\_and\_fetch

```python
def execute_and_fetch(
query: str,
parameters: Dict[str, Any] = {}) -> Iterator[Dict[str, Any]]
```

Executes Cypher query and returns iterator of results.

#### is\_active

```python
def is_active() -> bool
```

Returns True if connection is active and can be used.

30 changes: 20 additions & 10 deletions docs/reference/gqlalchemy/disk_storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,53 @@ An abstract class for implementing on-disk storage features with specific databa
#### save\_node\_property

```python
def save_node_property(node_id: int, property_name: str, property_value: str) -> None
def save_node_property(node_id: int, property_name: str,
property_value: str) -> None
```

Saves a node property to an on disk database.

#### load\_node\_property

```python
def load_node_property(node_id: int, property_name: str, property_value: str) -> Optional[str]
def load_node_property(node_id: int, property_name: str,
property_value: str) -> Optional[str]
```

Loads a node property from an on disk database.

#### delete\_node\_property

```python
def delete_node_property(node_id: int, property_name: str, property_value: str) -> None
def delete_node_property(node_id: int, property_name: str,
property_value: str) -> None
```

Deletes a node property from an on disk database.

#### save\_relationship\_property

```python
def save_relationship_property(relationship_id: int, property_name: str, property_value: str) -> None
def save_relationship_property(relationship_id: int, property_name: str,
property_value: str) -> None
```

Saves a relationship property to an on disk database.

#### load\_relationship\_property

```python
def load_relationship_property(relationship_id: int, property_name: str, property_value: str) -> Optional[str]
def load_relationship_property(relationship_id: int, property_name: str,
property_value: str) -> Optional[str]
```

Loads a relationship property from an on disk database.

#### delete\_relationship\_property

```python
def delete_relationship_property(node_id: int, property_name: str, property_value: str) -> None
def delete_relationship_property(node_id: int, property_name: str,
property_value: str) -> None
```

Deletes a node property from an on disk database.
Expand Down Expand Up @@ -101,7 +107,8 @@ Deletes all properties in the database.
#### save\_node\_property

```python
def save_node_property(node_id: int, property_name: str, property_value: str) -> None
def save_node_property(node_id: int, property_name: str,
property_value: str) -> None
```

Saves a node property to an on disk database.
Expand Down Expand Up @@ -146,7 +153,8 @@ Deletes a node property from an on disk database.
#### save\_relationship\_property

```python
def save_relationship_property(relationship_id: int, property_name: str, property_value: str) -> None
def save_relationship_property(relationship_id: int, property_name: str,
property_value: str) -> None
```

Saves a relationship property to an on disk database.
Expand All @@ -160,7 +168,8 @@ Saves a relationship property to an on disk database.
#### load\_relationship\_property

```python
def load_relationship_property(relationship_id: int, property_name: str) -> Optional[str]
def load_relationship_property(relationship_id: int,
property_name: str) -> Optional[str]
```

Loads a relationship property from an on disk database.
Expand All @@ -178,7 +187,8 @@ Loads a relationship property from an on disk database.
#### delete\_relationship\_property

```python
def delete_relationship_property(relationship_id: int, property_name: str) -> None
def delete_relationship_property(relationship_id: int,
property_name: str) -> None
```

Deletes a node property from an on disk database.
Expand Down
29 changes: 29 additions & 0 deletions docs/reference/gqlalchemy/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_label: exceptions
title: gqlalchemy.exceptions
---

#### connection\_handler

```python
def connection_handler(func,
delay: float = 0.01,
timeout: float = 5.0,
backoff: int = 2)
```

Wrapper for a wait on the connection.

**Arguments**:

- `func` - A function that tries to create the connection
- `delay` - A float that defines how long to wait between retries.
- `timeout` - A float that defines how long to wait for the port.
- `backoff` - An integer used for multiplying the delay.


**Raises**:

- `GQLAlchemyWaitForConnectionError` - Raises an error
after the timeout period has passed.

71 changes: 56 additions & 15 deletions docs/reference/gqlalchemy/graph_algorithms/integrated_algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ lambda.
#### \_\_init\_\_

```python
def __init__(lower_bound: int = None, upper_bound: int = None, condition: str = None) -> None
def __init__(lower_bound: int = None,
upper_bound: int = None,
condition: str = None) -> None
```

**Arguments**:

- `lower_bound` - Lower bound for path depth. Defaults to `None`.
- `upper_bound` - Upper bound for path depth. Defaults to `None`.
- `lower_bound` - Lower bound for path depth.
- `upper_bound` - Upper bound for path depth.
- `condition` - Filter through nodes and relationships that pass this
condition. Defaults to `None`.
condition.

#### \_\_str\_\_

Expand Down Expand Up @@ -107,15 +109,17 @@ lambda.
#### \_\_init\_\_

```python
def __init__(lower_bound: int = None, upper_bound: int = None, condition: str = None) -> None
def __init__(lower_bound: int = None,
upper_bound: int = None,
condition: str = None) -> None
```

**Arguments**:

- `lower_bound` - Lower bound for path depth. Defaults to None.
- `upper_bound` - Upper bound for path depth. Defaults to None.
- `lower_bound` - Lower bound for path depth.
- `upper_bound` - Upper bound for path depth.
- `condition` - Filter through nodes and relationships that pass this
condition. Defaults to None.
condition.

#### \_\_str\_\_

Expand All @@ -139,7 +143,8 @@ If bounds are specified, returns them in grammar-defined form.
class WeightedShortestPath(IntegratedAlgorithm)
```

Build a Djikstra shortest path call for a Cypher query
Build a Djikstra shortest path call for a Cypher query.

The weighted shortest path algorithm can be called in Memgraph with Cypher
queries such as:
" MATCH (a {id: 723})-[r *WSHORTEST 10 (r, n | r.weight) weight_sum
Expand All @@ -151,16 +156,52 @@ is a filter lambda, used to filter which relationships and nodes to use.
#### \_\_init\_\_

```python
def __init__(upper_bound: int = None, condition: str = None, total_weight_var: str = DEFAULT_TOTAL_WEIGHT, weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
def __init__(upper_bound: int = None,
condition: str = None,
total_weight_var: str = DEFAULT_TOTAL_WEIGHT,
weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
```

**Arguments**:

- `upper_bound` - Upper bound for path depth.
- `condition` - Filter through nodes and relationships that pass this
condition.
- `total_weight_var` - Variable defined as the sum of all weights on
path being returned.
- `weight_property` - property being used as weight.

## AllShortestPath Objects

```python
class AllShortestPath(IntegratedAlgorithm)
```

Build a Djikstra shortest path call for a Cypher query.

The weighted shortest path algorithm can be called in Memgraph with Cypher
queries such as:
" MATCH (a {id: 723})-[r *ALLSHORTEST 10 (r, n | r.weight) total_weight
(r, n | r.x > 12 AND r.y < 3)]-(b {id: 882}) RETURN * "
It is called inside the relationship clause, "*ALLSHORTEST" naming the
algorithm, "10" specifying search depth bounds, and "(r, n | <expression>)"
is a filter lambda, used to filter which relationships and nodes to use.

#### \_\_init\_\_

```python
def __init__(upper_bound: int = None,
condition: str = None,
total_weight_var: str = DEFAULT_TOTAL_WEIGHT,
weight_property: str = DEFAULT_WEIGHT_PROPERTY) -> None
```

**Arguments**:

- `upper_bound` - Upper bound for path depth. Defaults to None.
- `upper_bound` - Upper bound for path depth.
- `condition` - Filter through nodes and relationships that pass this
condition. Defaults to None.
condition.
- `total_weight_var` - Variable defined as the sum of all weights on
path being returned. Defaults to "total_weight".
- `weight_property` - property being used as weight. Defaults to
"r.weight".
path being returned.
- `weight_property` - Property being used as weight.

9 changes: 7 additions & 2 deletions docs/reference/gqlalchemy/graph_algorithms/query_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ method.
#### parse\_query\_module\_signature

```python
def parse_query_module_signature(signature: str) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]
def parse_query_module_signature(
signature: str) -> Tuple[List[Dict[str, str]], List[Dict[str, str]]]
```

Query Modules signatures received from Memgraph are parsed into a
Expand All @@ -67,7 +68,11 @@ type of argument and "default" where default argument value is given
#### parse\_field

```python
def parse_field(vars_field: str, name_type_delimiter: str = NAME_TYPE_DELIMITIER, default_value_delimiter: str = EQUALS_DELIMITER) -> List[Dict[str, str]]
def parse_field(
vars_field: str,
name_type_delimiter: str = NAME_TYPE_DELIMITIER,
default_value_delimiter: str = EQUALS_DELIMITER
) -> List[Dict[str, str]]
```

Parse a field of arguments or returns from Query Module signature.
Expand Down
Loading

0 comments on commit 07f2981

Please sign in to comment.