Skip to content

Commit

Permalink
Update workbase to work with grakn 1.5 (#69)
Browse files Browse the repository at this point in the history
## What is the goal of this PR?
To make workbase compliant with grakn v1.5
closes: #68

## What are the changes implemented in this PR?

1) Change dependency of grakn to latest commit off client node-js
2) Change all occurrences of relationship to relation
3) Change the way we insert the offset and limit into a query to come after the get
4) Update tests
  • Loading branch information
Syed Irtaza Raza authored and vmax committed Mar 2, 2019
1 parent 7f672ae commit 02d5f8e
Show file tree
Hide file tree
Showing 42 changed files with 312 additions and 384 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -12,7 +12,7 @@ Grakn Workbase is Grakn's Integrated Development Environment to perform knowledg

You can also see Workbase as another interface for a user to interact with their Grakn database, as an alternative to the [Grakn Console](http://dev.grakn.ai/docs/running-grakn/console) and [Grakn Client API/Drivers](http://dev.grakn.ai/docs/client-api/overview).

Workbase Visualiser allows you to visualise data in the Grakn knowledge graph, and investigate their relationships, by performing read queries ([`match-get` queries](/docs/query/get-query)) as well as one of the computer queries: [`compute path`](/docs/query/compute-query#compute-the-shortest-path) queries. Whether you need a tool to test and experiment with your newly created Grakn knowledge graph, or that you prefer a graphical interface for reading data from Grakn, you will find Workbase extremely useful.
Workbase Visualiser allows you to visualise data in the Grakn knowledge graph, and investigate their relations, by performing read queries ([`match-get` queries](/docs/query/get-query)) as well as one of the computer queries: [`compute path`](/docs/query/compute-query#compute-the-shortest-path) queries. Whether you need a tool to test and experiment with your newly created Grakn knowledge graph, or that you prefer a graphical interface for reading data from Grakn, you will find Workbase extremely useful.

## Download Workbase
Grakn Workbase is available for Linux, Mac and Windows. Head over to the [Workbase Releases page](https://github.com/graknlabs/workbase/releases) to download and install the latest release of Workbase.
Expand Down
132 changes: 32 additions & 100 deletions WORKSPACE
@@ -1,66 +1,17 @@
#
# GRAKN.AI - THE KNOWLEDGE GRAPH
# Copyright (C) 2018 Grakn Labs Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#

workspace(name = "grakn_workbase")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


git_repository(
name = "graknlabs_grakn_core",
remote = "https://github.com/graknlabs/grakn",
commit = "c9913c782d19edb2fb0144a556d66b2248a7c9b7"
commit = "cef8a507d9946207bd1171986dec67eb4ea3b51a"
)


########################################
# Remote Build Execution #
########################################

http_archive(
name = "bazel_toolchains",
sha256 = "07a81ee03f5feae354c9f98c884e8e886914856fb2b6a63cba4619ef10aaaf0b",
strip_prefix = "bazel-toolchains-31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/31b5dc8c4e9c7fd3f5f4d04c6714f2ce87b126c1.tar.gz",
],
git_repository(
name = "graknlabs_client_java",
remote = "https://github.com/graknlabs/client-java",
commit = "79c1f242b91fe315a5a52a9c0a04dd4fe0dc04b5"
)


####################
# Load Build Tools #
####################

# Load additional build tools, such bazel-deps and unused-deps
load("@graknlabs_grakn_core//dependencies/tools:dependencies.bzl", "tools_dependencies")
tools_dependencies()


#####################################
# Load Java dependencies from Maven #
#####################################

load("@graknlabs_grakn_core//dependencies/maven:dependencies.bzl", maven_dependencies_for_build = "maven_dependencies")
maven_dependencies_for_build()


######################################
# Load Node.js dependencies from NPM #
######################################
Expand All @@ -79,66 +30,47 @@ rules_nodejs_dependencies()
load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "npm_install")
node_repositories(package_json = ["//:package.json"], node_version = "10.13.0")

########################################
# Load compiler dependencies for ANTLR #
########################################

# Load ANTLR dependencies for Bazel
load("@graknlabs_grakn_core//dependencies/compilers:dependencies.bzl", "antlr_dependencies")
antlr_dependencies()

# Load ANTLR dependencies for ANTLR programs
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
antlr_dependencies()


#######################################
# Load compiler dependencies for GRPC #
#######################################

# Load GRPC dependencies
load("@graknlabs_grakn_core//dependencies/compilers:dependencies.bzl", "grpc_dependencies")
grpc_dependencies()

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", com_github_grpc_grpc_bazel_grpc_deps = "grpc_deps")
com_github_grpc_grpc_bazel_grpc_deps()

# Load GRPC Java dependencies
load("@stackb_rules_proto//java:deps.bzl", "java_grpc_compile")
java_grpc_compile()
load("@graknlabs_grakn_core//dependencies/tools:dependencies.bzl", "tools_dependencies")
tools_dependencies()

# Load GRPC Python dependencies
load("@stackb_rules_proto//python:deps.bzl", "python_grpc_compile")
python_grpc_compile()
load("@graknlabs_grakn_core//dependencies/tools/checkstyle:checkstyle.bzl", "checkstyle_dependencies")
checkstyle_dependencies()

# Load GRPC Node.js dependencies
load("@stackb_rules_proto//node:deps.bzl", "node_grpc_compile")
node_grpc_compile()
load("@graknlabs_grakn_core//dependencies/distribution:dependencies.bzl", "distribution_dependencies")
distribution_dependencies()

load("@graknlabs_bazel_distribution//github:dependencies.bzl", "github_dependencies_for_deployment")
github_dependencies_for_deployment()

########################################
# Load Deployment Dependencies #
########################################
load("@com_github_google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules")
google_common_workspace_rules()

git_repository(
name="graknlabs_bazel_distribution",
remote="https://github.com/graknlabs/bazel-distribution",
commit="5f7a464b943fc3c370c42d2f5b59993ec2cd435f"
)
load("@stackb_rules_proto//java:deps.bzl", "java_grpc_compile")
java_grpc_compile()

load("@graknlabs_bazel_distribution//github:dependencies.bzl", "github_dependencies_for_deployment")
github_dependencies_for_deployment()
load("@graknlabs_grakn_core//dependencies/maven:dependencies.bzl", maven_dependencies_for_build = "maven_dependencies")
maven_dependencies_for_build()

load("@graknlabs_grakn_core//dependencies/git:dependencies.bzl", "graknlabs_graql")
graknlabs_graql()

load("@graknlabs_graql//dependencies/compilers:dependencies.bzl", "antlr_dependencies")
antlr_dependencies()

git_repository(
name="com_github_google_bazel_common",
remote="https://github.com/graknlabs/bazel-common",
commit="550f0490798a4e4b6c5ff8cac3b6f5c2a5e81e21",
)
load("@rules_antlr//antlr:deps.bzl", "antlr_dependencies")
antlr_dependencies()

load("@com_github_google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules")
google_common_workspace_rules()
load("@graknlabs_graql//dependencies/maven:dependencies.bzl", graql_dependencies = "maven_dependencies")
graql_dependencies()

load("@graknlabs_grakn_core//dependencies/tools/checkstyle:checkstyle.bzl", "checkstyle_dependencies")
checkstyle_dependencies()
load("@stackb_rules_proto//java:deps.bzl", "java_grpc_compile")
java_grpc_compile()

load("@graknlabs_grakn_core//dependencies/docker:dependencies.bzl", "docker_dependencies")
docker_dependencies()
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -17,7 +17,7 @@
"dev": "node .electron-vue/dev-runner.js",
"pack": "npm run pack:main && npm run pack:renderer",
"pack:main": "node ./node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node ./node_modules/webpack/bin/webpack.js --progress --colors --config .electron-vue/webpack.main.config.js",
"pack:renderer": "node ./node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node ./node_modules/webpack/bin/webpack.js --progress --colors --config .electron-vue/webpack.renderer.config.js",
"pack:renderer": "node ./node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node ./node_modules/webpack/bin/webpack.js --progress --colors --config .electron-vue/webpack.renderer.config.js",
"postinstall": "bash ./install-node-electron.sh",
"unit": "node ./node_modules/jest/bin/jest.js ./test/unit",
"e2e": "npm run pack && node ./node_modules/jest/bin/jest.js ./test/e2e --runInBand"
Expand Down Expand Up @@ -73,7 +73,7 @@
"@blueprintjs/table": "^3.1.1",
"codemirror": "^5.38.0",
"electron-store": "^1.3.0",
"grakn": "1.3.1",
"grakn-client": "http://repo.grakn.ai/repository/test-npm-group/grakn-client/-/grakn-client-1.5.0-229329be4a5817aadec2ef392338b41297bb3f73.tgz",
"grpc": "^1.18.0",
"hex-to-hsl": "^1.0.2",
"image-data-uri": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Login/LoginPage.vue
Expand Up @@ -177,7 +177,7 @@
</style>
<script>
import Grakn from 'grakn';
import Grakn from 'grakn-client';
import storage from '@/components/shared/PersistentStorage';
import ServerSettings from '@/components/ServerSettings';
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/SchemaDesign/LeftBar.vue
Expand Up @@ -7,7 +7,7 @@
<div class="content">
<new-entity-panel :showPanel="showPanel" v-on:show-panel="togglePanel"></new-entity-panel>
<new-attribute-panel :showPanel="showPanel" v-on:show-panel="togglePanel"></new-attribute-panel>
<new-relationship-panel :showPanel="showPanel" v-on:show-panel="togglePanel"></new-relationship-panel>
<new-relation-panel :showPanel="showPanel" v-on:show-panel="togglePanel"></new-relation-panel>
<new-rule-panel :showPanel="showPanel" v-on:show-panel="togglePanel"></new-rule-panel>
</div>
</div>
Expand Down Expand Up @@ -45,12 +45,12 @@
import NewEntityPanel from './LeftBar/NewEntityPanel';
import NewAttributePanel from './LeftBar/NewAttributePanel';
import NewRelationshipPanel from './LeftBar/NewRelationshipPanel';
import NewRelationPanel from './LeftBar/NewRelationPanel';
import NewRulePanel from './LeftBar/NewRulePanel';
export default {
components: { NewEntityPanel, NewAttributePanel, NewRelationshipPanel, NewRulePanel },
components: { NewEntityPanel, NewAttributePanel, NewRelationPanel, NewRulePanel },
data() {
return {
showPanel: undefined,
Expand Down
@@ -1,15 +1,15 @@
<template>
<div>
<button class="btn define-btn" :class="(showPanel === 'relationship') ? 'green-border': ''" @click="togglePanel">Relationship Type</button>
<div class="new-relationship-panel-container" v-if="showPanel === 'relationship'">
<button class="btn define-btn" :class="(showPanel === 'relation') ? 'green-border': ''" @click="togglePanel">Relation Type</button>
<div class="new-relation-panel-container" v-if="showPanel === 'relation'">
<div class="title">
Define New Relationship Type
Define New Relation Type
<div class="close-container" @click="$emit('show-panel', undefined)"><vue-icon icon="cross" iconSize="12" className="tab-icon"></vue-icon></div>
</div>
<div class="content">

<div class="row">
<input class="input-small label-input" v-model="relationshipLabel" placeholder="Relationship Label">
<input class="input-small label-input" v-model="relationLabel" placeholder="Relation Label">
sub
<div v-bind:class="(showTypeList) ? 'btn type-btn type-list-shown' : 'btn type-btn'" @click="showTypeList = !showTypeList"><div class="type-btn-text" >{{superType}}</div><div class="type-btn-caret"><vue-icon className="vue-icon" icon="caret-down"></vue-icon></div></div>

Expand Down Expand Up @@ -94,7 +94,7 @@

<div class="submit-row">
<button class="btn submit-btn" @click="resetPanel">Clear</button>
<loading-button v-on:clicked="defineRelationshipType" text="Submit" :loading="showSpinner" className="btn submit-btn"></loading-button>
<loading-button v-on:clicked="defineRelationType" text="Submit" :loading="showSpinner" className="btn submit-btn"></loading-button>
</div>

</div>
Expand Down Expand Up @@ -291,7 +291,7 @@
justify-content: space-between;
}
.new-relationship-panel-container {
.new-relation-panel-container {
position: absolute;
left: 120px;
top: 10px;
Expand Down Expand Up @@ -393,7 +393,7 @@

<script>
import logger from '@/../Logger';
import { DEFINE_RELATIONSHIP_TYPE, OPEN_GRAKN_TX } from '@/components/shared/StoresActions';
import { DEFINE_RELATION_TYPE, OPEN_GRAKN_TX } from '@/components/shared/StoresActions';
import { createNamespacedHelpers } from 'vuex';
export default {
Expand All @@ -403,7 +403,7 @@
showTypeList: false,
superTypes: [],
superType: undefined,
relationshipLabel: '',
relationLabel: '',
showSpinner: false,
newRoles: [''],
superRelatipnshipTypeRoles: [],
Expand All @@ -428,27 +428,27 @@
// methods
this.$options.methods = {
...(this.$options.methods || {}),
...mapActions([DEFINE_RELATIONSHIP_TYPE, OPEN_GRAKN_TX]),
...mapActions([DEFINE_RELATION_TYPE, OPEN_GRAKN_TX]),
};
},
watch: {
showPanel(val) {
if (val === 'relationship') { // reset panel when it is toggled
if (val === 'relation') { // reset panel when it is toggled
this.resetPanel();
}
},
metaTypeInstances(val) {
this.hasAttributes = val.attributes;
this.superTypes = ['relationship', ...this.metaTypeInstances.relationships];
this.superTypes = ['relation', ...this.metaTypeInstances.relations];
},
async superType(val) {
if (val !== 'relationship') { // if super type is not 'relationship' then compute roles of supertype for inheriting and overriding
if (val !== 'relation') { // if super type is not 'relation' then compute roles of supertype for inheriting and overriding
this.newRoles = [];
const graknTx = await this[OPEN_GRAKN_TX]();
const RelationshipType = await graknTx.getSchemaConcept(val);
const RelationType = await graknTx.getSchemaConcept(val);
this.superRelatipnshipTypeRoles = await Promise.all((await (await RelationshipType.roles()).collect()).map(async role => role.label()));
this.superRelatipnshipTypeRoles = await Promise.all((await (await RelationType.roles()).collect()).map(async role => role.label()));
this.overridenRoles.push(...this.superRelatipnshipTypeRoles.map(role => ({ label: role, override: false })));
Expand Down Expand Up @@ -482,11 +482,11 @@
this.toggledRoleTypes.push(type);
}
},
async defineRelationshipType() {
if (this.relationshipLabel === '') {
this.$notifyError('Cannot define Relationship Type without Relationship Label');
} else if (this.superType === 'relationship' && !this.newRoles[0].length && !this.toggledRoleTypes.length) {
this.$notifyError('Cannot define Relationship Type without atleast one related role');
async defineRelationType() {
if (this.relationLabel === '') {
this.$notifyError('Cannot define Relation Type without Relation Label');
} else if (this.superType === 'relation' && !this.newRoles[0].length && !this.toggledRoleTypes.length) {
this.$notifyError('Cannot define Relation Type without atleast one related role');
} else {
let overrideError = false;
Expand All @@ -495,7 +495,7 @@
});
if (overrideError) {
this.$notifyError('Cannot define Relationship Type with an empty overriden role');
this.$notifyError('Cannot define Relation Type with an empty overriden role');
} else {
this.showSpinner = true;
Expand All @@ -506,8 +506,8 @@
// collect all roles which are already defined but only need to be related
const relateRoles = this.overridenRoles.map(role => ((!role.override) ? role.label : null)).filter(r => r);
this[DEFINE_RELATIONSHIP_TYPE]({
relationshipLabel: this.relationshipLabel,
this[DEFINE_RELATION_TYPE]({
relationLabel: this.relationLabel,
superType: this.superType,
defineRoles,
relateRoles,
Expand All @@ -516,7 +516,7 @@
})
.then(() => {
this.showSpinner = false;
this.$notifyInfo(`Relationship Type, ${this.relationshipLabel}, has been defined`);
this.$notifyInfo(`Relation Type, ${this.relationLabel}, has been defined`);
this.resetPanel();
})
.catch((e) => {
Expand All @@ -532,8 +532,8 @@
this.showTypeList = false;
},
resetPanel() {
this.relationshipLabel = '';
this.superTypes = ['relationship', ...this.metaTypeInstances.relationships];
this.relationLabel = '';
this.superTypes = ['relation', ...this.metaTypeInstances.relations];
this.superType = this.superTypes[0];
this.newRoles = [''];
this.toggledAttributeTypes = [];
Expand All @@ -544,8 +544,8 @@
this.overridenRoles = [];
},
togglePanel() {
if (this.showPanel === 'relationship') this.$emit('show-panel', undefined);
else this.$emit('show-panel', 'relationship');
if (this.showPanel === 'relation') this.$emit('show-panel', undefined);
else this.$emit('show-panel', 'relation');
},
addNewRole() {
this.newRoles.push('');
Expand Down

0 comments on commit 02d5f8e

Please sign in to comment.