Skip to content

Commit

Permalink
Update for 1.8: delete syntax, remove via, query options, syntax …
Browse files Browse the repository at this point in the history
…renaming (typedb#296)

## What is the goal of this PR?
Documentation of:
* new delete syntax and features, such as deleting attribute ownerships (removing `via`), and removing role players from relations. 
* New syntax: introduce the `value` keyword instead of `datatype`, and `datetime` instead of `date`. 
* Query Options
* Updating dependency tables for clients
* Instructions on updating relations
* Use new `.get()` syntax on query execute

## What are the changes implemented in this PR?
* Update docs delete documentation
* Add section on removing relation players
* Update CI image to use Ubuntu 16 and remove RBE installation (for now)
* Introduce Query Options
* Move dependency tables to bottom of client pages
  • Loading branch information
flyingsilverfin authored Jun 19, 2020
1 parent 208a5eb commit a82396a
Show file tree
Hide file tree
Showing 33 changed files with 595 additions and 415 deletions.
52 changes: 29 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

version: 2.1
commands:
install-bazel-linux-rbe:
install-bazel:
steps:
- run: curl -OL https://raw.githubusercontent.com/graknlabs/build-tools/master/ci/install-bazel-linux.sh
- run: bash ./install-bazel-linux.sh && rm ./install-bazel-linux.sh
- run: curl -OL https://raw.githubusercontent.com/graknlabs/build-tools/master/ci/install-bazel-rbe.sh
- run: bash ./install-bazel-rbe.sh && rm ./install-bazel-rbe.sh
- run: pyenv global system system

run-bazel-rbe:
parameters:
Expand All @@ -42,77 +41,83 @@ commands:

jobs:
build:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run-bazel-rbe:
command: bazel build //...

test-query-graql-lang:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run-bazel-rbe:
command: bazel test //test/query:graql-lang --test_output=errors

test-query-graql-java:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run-bazel-rbe:
command: bazel test //test/query:graql-java --test_output=errors

test-example-java:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run-grakn-server
- run: bazel test //test/example/java:phone-calls --test_output=errors
- run: bazel test //test/example/java:social-network --test_output=errors

test-example-nodejs:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run-grakn-server
- run: bazel test //test/example/nodejs:phone-calls --test_output=errors
- run: bazel test //test/example/nodejs:social-network --test_output=errors

test-example-python:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run: pyenv global 2.7.12 3.5.2
- run-grakn-server
- run: bazel test //test/example/python:phone-calls --test_output=errors
- run: bazel test //test/example/python:social-network --test_output=errors

test-links:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run: pyenv global 2.7.12 3.5.2
- run: bazel test //test/links:test --test_output=errors

release-staging:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run: |
export RELEASE_DOCS_USERNAME=$REPO_GITHUB_USERNAME
Expand All @@ -121,10 +126,11 @@ jobs:
bazel run @graknlabs_build_tools//ci:release-docs -- development $CIRCLE_SHA1
release-production:
machine: true
machine:
image: ubuntu-1604:201903-01
working_directory: ~/docs
steps:
- install-bazel-linux-rbe
- install-bazel
- checkout
- run: |
export RELEASE_DOCS_USERNAME=$REPO_GITHUB_USERNAME
Expand Down
10 changes: 5 additions & 5 deletions 00-general/04-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ A [Grakn schema](../09-schema/00-overview.md) is the blueprint of a Grakn knowle
define
title sub attribute,
datatype string;
value string;
event-date sub attribute,
abstract,
datatype date;
value datetime;
approved-date sub event-date;
## an abstract relation, only to be subtyped by other relations
Expand Down Expand Up @@ -139,7 +139,7 @@ public class SocialNetworkQuickstartQuery extends Throwable {
var("org").has("name", var("org-n"))
).get();

List<ConceptMap> answers = transaction.execute(query);
List<ConceptMap> answers = transaction.execute(query).get();

for (ConceptMap answer : answers) {
System.out.println(answer.get("per-fn").asAttribute().value());
Expand Down Expand Up @@ -171,7 +171,7 @@ with GraknClient(uri="localhost:48555") as client:
(reacted-emotion: $fun, reacted-to: $pos, reacted-by: $per) isa reaction;
get $pos;
'''
answer_iterator = transaction.query(query)
answer_iterator = transaction.query(query).get()
for answer in answer_iterator:
print(answer.map().get("pos").id)
```
Expand Down Expand Up @@ -239,7 +239,7 @@ commit
#### Delete the newly added person
<!-- ignore-test -->
```graql
match $per isa person, has full-name "Johny Jimbly Joe"; delete $per;
match $per isa person, has full-name "Johny Jimbly Joe"; delete $per isa person;
```

<!-- test-ignore -->
Expand Down
10 changes: 10 additions & 0 deletions 03-client-api/00-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ A session is responsible for connecting our application to a particular keyspace
### Transaction
A transaction is responsible for performing write and read operations over the concepts types and instances within the connected keyspace. When executing a query to retrieve data, an iterator is returned, which can then be lazily consumed to execute a request on the server to return the next concrete result.

### Futures and Async Queries
Queries can be computed asynchronously on the grakn server whilst local processing takes place. In order to execute async queries, clients may wrap the result in an async task wrapping object, such as a Promise or Future, depending on the convention in the given language.

<div class="note">
[Important]
When a transaction is committed or closed, all currently processing asynchronous queries are completed first.
</div>

### Investigating Answers
Depending on the type of the query carried out by a transaction, we retrieve different forms of answers. These answers, regardless of their type, all contain concepts. We can then use the methods introduced by the [Concept API](../04-concept-api/00-overview.md) to obtain more information about the retrieved concept and its surroundings. Furthermore, the Concept API allows us to traverse the neighbours of a specific concept instance to obtain more insights.

Expand All @@ -34,6 +42,8 @@ To avoid running into issues and make the most out of using a Grakn client, keep

**Keep the number of operations per transaction minimal**. Although it is technically possible to commit a write transaction once after many operations, it is not recommended. To avoid lengthy rollbacks, running out of memory and conflicting operations, it is best to keep the number of queries per transaction minimal, ideally to one query per transaction.

**Take advantage of asynchronous queries where possible.** This cuts down and masks network round-trip costs and increases your throughput. All queries can safely be made asynchronous, as async queries within a transaction are executed sequentially on the server-side.

## Available Clients
Grakn currently supports clients for:
- [Java](../03-client-api/01-java.md)
Expand Down
77 changes: 30 additions & 47 deletions 03-client-api/01-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,10 @@ Summary: API Reference of Grakn Client Java.
templatePath: 03-client-api/references/
---

## Dependencies
## Installation

| Client Java | Grakn Core | Grakn KGMS |
| :---------: | :-------------:| :------------: |
| 1.7.2 | 1.7.1 | N/A |
| 1.6.2 | 1.6.2 | 1.6.2 |
| 1.6.1 | 1.6.0, 1.6.1 | N/A |
| 1.5.5 | 1.5.8, 1.5.9 | 1.5.8 |
| 1.5.4 | 1.5.8, 1.5.9 | 1.5.8 |
| 1.5.3 | 1.5.2 to 1.5.7 | 1.5.2 to 1.5.7 |
| 1.5.2 | 1.5.2, 1.5.3 | 1.5.2 to 1.5.4 |
| 1.5.0 | 1.5.0 | N/A |
| 1.4.3 | 1.4.3 | 1.4.3 |
| 1.4.2 | 1.4.2 | 1.2.0 |
| 1.4.1 | 1.4.0 | 1.2.0 |
| 1.4.0 | 1.4.0 | 1.2.0 |
| 1.3.0 | 1.3.0 | 1.2.0 |

<div class="tabs dark">
#### To use this client, you need a compatible Grakn Server running. Visit our [Compatibility Table](#dependencies)

[tab:Grakn Core]
```xml
<repositories>
<repository>
Expand All @@ -35,39 +18,14 @@ templatePath: 03-client-api/references/
</repository>
</repositories>
<dependencies>
<dependency>
&lt;groupId&gt;io.graql&lt;/groupId&gt;
&lt;artifactId&gt;graql-lang&lt;/artifactId&gt;
<version>1.0.5</version>
</dependency>
<dependency>
&lt;groupId&gt;io.grakn.client&lt;/groupId&gt;
&lt;artifactId&gt;grakn-client&lt;/artifactId&gt;
<version>1.6.2</version>
<version>{version}</version>
</dependency>
</dependencies>
```
[tab:end]

[tab:Grakn KGMS]
```xml
<repositories>
<repository>
<id>mavencentral</id>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
&lt;groupId&gt;ai.grakn.kgms&lt;/groupId&gt;
&lt;artifactId&gt;client&lt;/artifactId&gt;
<version>1.6.2</version>
</dependency>
</dependencies>
```
[tab:end]

</div>

## Quickstart
First make sure, the [Grakn Server](/docs/running-grakn/install-and-run#start-the-grakn-server) is running.
Expand Down Expand Up @@ -158,15 +116,15 @@ public class GraknQuickstartC {
// Insert a person using a WRITE transaction
GraknClient.Transaction writeTransaction = session.transaction().write();
GraqlInsert insertQuery = Graql.insert(var("x").isa("person").has("email", "[email protected]"));
List<ConceptMap> insertedId = writeTransaction.execute(insertQuery);
List<ConceptMap> insertedId = writeTransaction.execute(insertQuery).get();
System.out.println("Inserted a person with ID: " + insertedId.get(0).get("x").id());
// to persist changes, a write transaction must always be committed (closed)
writeTransaction.commit();

// Read the person using a READ only transaction
GraknClient.Transaction readTransaction = session.transaction().read();
GraqlGet getQuery = Graql.match(var("p").isa("person")).get().limit(10);
Stream<ConceptMap> answers = readTransaction.stream(getQuery);
Stream<ConceptMap> answers = readTransaction.stream(getQuery).get();
answers.forEach(answer -> System.out.println(answer.get("p").id()));

// transactions, sessions and clients must always be closed
Expand Down Expand Up @@ -204,6 +162,31 @@ To view examples of running various Graql queries using the Grakn Client Java, h

{% include api/generic.html data=site.data.03_client_api.references.transaction language="java" %}

{% include api/generic.html data=site.data.03_client_api.references.options language="java" %}

{% include api/generic.html data=site.data.03_client_api.references.graql language="java" %}

{% include api/answers.html data=site.data.03_client_api.references.answer language="java" %}



## Dependencies

| Client Java | Grakn Core | Grakn KGMS |
| :---------: | :-------------:| :------------: |
| 1.8.1 | 1.8.0 | N/A |
| 1.8.0 | 1.8.0 | N/A |
| 1.7.3 | 1.7.1, 1.7.2 | N/A |
| 1.7.2 | 1.7.1, 1.7.2 | N/A |
| 1.6.2 | 1.6.2 | 1.6.2 |
| 1.6.1 | 1.6.0, 1.6.1 | N/A |
| 1.5.5 | 1.5.8, 1.5.9 | 1.5.8 |
| 1.5.4 | 1.5.8, 1.5.9 | 1.5.8 |
| 1.5.3 | 1.5.2 to 1.5.7 | 1.5.2 to 1.5.7 |
| 1.5.2 | 1.5.2, 1.5.3 | 1.5.2 to 1.5.4 |
| 1.5.0 | 1.5.0 | N/A |
| 1.4.3 | 1.4.3 | 1.4.3 |
| 1.4.2 | 1.4.2 | 1.2.0 |
| 1.4.1 | 1.4.0 | 1.2.0 |
| 1.4.0 | 1.4.0 | 1.2.0 |
| 1.3.0 | 1.3.0 | 1.2.0 |
38 changes: 23 additions & 15 deletions 03-client-api/02-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@ keywords: grakn, client, python
longTailKeywords: grakn python client, grakn client python, client python, python client
Summary: API Reference of Grakn Client Python.
---
## Installation

## Dependencies
#### To use this client, you need a compatible Grakn Server running. Visit our [Compatibility Table](#dependencies)

| Client Python | Grakn Core | Grakn KGMS | Python |
| :------------: | :-------------------------: | :----------: | :----: |
| 1.7.0 | 1.7.1 | N/A | >= 2.7 |
| 1.6.0 to 1.6.1 | 1.6.0 to 1.6.2 | 1.6.2 | >= 2.7 |
| 1.5.4 | 1.5.8, 1.5.9 | 1.5.8 | >= 2.7 |
| 1.5.3 | 1.5.2 to 1.5.7 | 1.5.2 to 1.5.7 | >= 2.7 |
| 1.5.2 | 1.5.2, 1.5.3 | 1.5.2 | >= 2.7 |
| 1.5.1 | 1.5.0 | N/A | >= 2.7 |
| 1.4.2 | 1.3.0 to 1.4.3 | 1.2.0, 1.4.3 | >= 3.6 |
| 1.3.0 to 1.3.2 | 1.3.0 | 1.4.3 | >= 3.6 |

## Installation
```
pip install grakn-client
```
Expand Down Expand Up @@ -90,23 +80,23 @@ with GraknClient(uri="localhost:48555") as client:
with client.session(keyspace="social_network") as session:
## Insert a Person using a WRITE transaction
with session.transaction().write() as write_transaction:
insert_iterator = write_transaction.query('insert $x isa person, has email "[email protected]";')
insert_iterator = write_transaction.query('insert $x isa person, has email "[email protected]";').get()
concepts = [ans.get("x") for ans in insert_iterator]
print("Inserted a person with ID: {0}".format(concepts[0].id))
## to persist changes, write transaction must always be committed (closed)
write_transaction.commit()

## Read the person using a READ only transaction
with session.transaction().read() as read_transaction:
answer_iterator = read_transaction.query("match $x isa person; get; limit 10;")
answer_iterator = read_transaction.query("match $x isa person; get; limit 10;").get()

for answer in answer_iterator:
person = answer.map().get("x")
print("Retrieved person with id " + person.id)

## Or query and consume the iterator immediately collecting all the results
with session.transaction().read() as read_transaction:
answer_iterator = read_transaction.query("match $x isa person; get; limit 10;")
answer_iterator = read_transaction.query("match $x isa person; get; limit 10;").get()
persons = [ans.get("x") for ans in answer_iterator]
for person in persons:
print("Retrieved person with id "+ person.id)
Expand Down Expand Up @@ -143,7 +133,25 @@ To view examples of running various Graql queries using the Grakn Client Python,

{% include api/generic.html data=site.data.03_client_api.references.transaction language="python" %}

{% include api/generic.html data=site.data.03_client_api.references.options language="python" %}

{% include api/generic.html data=site.data.03_client_api.references.iterator language="python" %}

{% include api/answers.html data=site.data.03_client_api.references.answer language="python" %}


## Dependencies

| Client Python | Grakn Core | Grakn KGMS | Python |
| :------------: | :-------------------------: | :----------: | :----: |
| 1.8.0 | 1.8.0 | N/A | >= 3.5 |
| 1.7.2 | 1.7.1, 1.7.2 | N/A | >= 2.7 |
| 1.7.1 | 1.7.1 | N/A | >= 2.7 |
| 1.7.0 | 1.7.1 | N/A | >= 2.7 |
| 1.6.0 to 1.6.1 | 1.6.0 to 1.6.2 | 1.6.2 | >= 2.7 |
| 1.5.4 | 1.5.8, 1.5.9 | 1.5.8 | >= 2.7 |
| 1.5.3 | 1.5.2 to 1.5.7 | 1.5.2 to 1.5.7 | >= 2.7 |
| 1.5.2 | 1.5.2, 1.5.3 | 1.5.2 | >= 2.7 |
| 1.5.1 | 1.5.0 | N/A | >= 2.7 |
| 1.4.2 | 1.3.0 to 1.4.3 | 1.2.0, 1.4.3 | >= 3.6 |
| 1.3.0 to 1.3.2 | 1.3.0 | 1.4.3 | >= 3.6 |
Loading

0 comments on commit a82396a

Please sign in to comment.