Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Fix package name and version (#16)
Browse files Browse the repository at this point in the history
## What is the goal of this PR?

Complying with CI/CD plan outlined [here](http://tinyurl.com/GraknCICDSpreadsheet), we're renaming `grakn` to `grakn-client` and are using updated `@graknlabs_bazel_distribution` which stamp the `git` version to snapshot packages

## What are the changes implemented in this PR?

- rename `grakn` to `grakn-client`
- update commit hash of `@graknlabs_bazel_distribution`
- update commit hash of `@graknlabs_grakn_core`
  • Loading branch information
vmax committed Feb 26, 2019
1 parent 828bddf commit 6b56611
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 94 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ py_library(

deploy_pip(
name = "deploy-pip",
package_name = "grakn",
package_name = "grakn-client",
version_file = "//:VERSION",
classifiers = [
"Programming Language :: Python",
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0.dev1
1.5.0-SNAPSHOT
7 changes: 5 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "graknlabs_grakn_core",
remote = "https://github.com/graknlabs/grakn",
commit = "ec41e803e3a12696cec731ad6071c26e90cea926"
commit = "2091602fbcca45823d2bc3d5062ce7cdb6b25b89"
)

git_repository(
Expand All @@ -28,7 +28,7 @@ python_grpc_compile()
git_repository(
name="graknlabs_bazel_distribution",
remote="https://github.com/graknlabs/bazel-distribution",
commit="18d774e16187bd4148fe36842b68bafa46017d6f"
commit="3fff34b151afabaee5af7ffb35ed99e52747c932"
)

pip_import(
Expand Down Expand Up @@ -79,3 +79,6 @@ graql_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()
8 changes: 4 additions & 4 deletions grakn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ def put_entity_type(self, label):
return self._tx_service.put_entity_type(label)
put_entity_type.__annotations__ = {'label': str}

def put_relationship_type(self, label):
""" Define a new relationship type with the given label """
return self._tx_service.put_relationship_type(label)
put_relationship_type.__annotations__ = {'label': str}
def put_relation_type(self, label):
""" Define a new relation type with the given label """
return self._tx_service.put_relation_type(label)
put_relation_type.__annotations__ = {'label': str}

def put_attribute_type(self, label, data_type):
""" Define a new attribute type with the given label and data type
Expand Down
8 changes: 4 additions & 4 deletions grakn/service/Session/Concept/BaseTypeMapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@


# base type constant names
CONCEPTS = META_TYPE, ATTRIBUTE_TYPE, RELATIONSHIP_TYPE, ENTITY_TYPE, ENTITY, ATTRIBUTE, RELATIONSHIP, ROLE, RULE = \
"META_TYPE", "ATTRIBUTE_TYPE", "RELATIONSHIP_TYPE", "ENTITY_TYPE", "ENTITY", "ATTRIBUTE", "RELATIONSHIP", "ROLE", "RULE"
CONCEPTS = META_TYPE, ATTRIBUTE_TYPE, RELATION_TYPE, ENTITY_TYPE, ENTITY, ATTRIBUTE, RELATION, ROLE, RULE = \
"META_TYPE", "ATTRIBUTE_TYPE", "RELATION_TYPE", "ENTITY_TYPE", "ENTITY", "ATTRIBUTE", "RELATION", "ROLE", "RULE"

"""
NOTE: the string META_TYPE is the name of the programmatic type of
Expand All @@ -39,12 +39,12 @@
grpc_base_type_to_name = {
grpc_base_types.Value("META_TYPE"): META_TYPE,
grpc_base_types.Value("ENTITY_TYPE"): ENTITY_TYPE,
grpc_base_types.Value("RELATION_TYPE"): RELATIONSHIP_TYPE,
grpc_base_types.Value("RELATION_TYPE"): RELATION_TYPE,
grpc_base_types.Value("ATTRIBUTE_TYPE"): ATTRIBUTE_TYPE,
grpc_base_types.Value("ROLE"): ROLE,
grpc_base_types.Value("RULE"): RULE,
grpc_base_types.Value("ENTITY"): ENTITY,
grpc_base_types.Value("RELATION"): RELATIONSHIP,
grpc_base_types.Value("RELATION"): RELATION,
grpc_base_types.Value("ATTRIBUTE"): ATTRIBUTE
}

Expand Down
52 changes: 23 additions & 29 deletions grakn/service/Session/Concept/Concept.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def is_entity_type(self):
return isinstance(self, EntityType)
is_entity_type.__annotations__ = {'return': bool}

def is_relationship_type(self):
""" Check if this concept is a RelationshipType concept """
return isinstance(self, RelationshipType)
is_relationship_type.__annotations__ = {'return': bool}
def is_relation_type(self):
""" Check if this concept is a RelationType concept """
return isinstance(self, RelationType)
is_relation_type.__annotations__ = {'return': bool}

def is_role(self):
""" Check if this concept is a Role """
Expand All @@ -87,10 +87,10 @@ def is_entity(self):
return isinstance(self, Entity)
is_entity.__annotations__ = {'return': bool}

def is_relationship(self):
""" Check if this concept is a Relationship concept """
return isinstance(self, Relationship)
is_relationship.__annotations__ = {'return': bool}
def is_relation(self):
""" Check if this concept is a Relation concept """
return isinstance(self, Relation)
is_relation.__annotations__ = {'return': bool}


class SchemaConcept(Concept):
Expand Down Expand Up @@ -351,20 +351,17 @@ def regex(self, pattern=None):
regex.__annotations__ = {'pattern': str}


class RelationshipType(Type):

# NOTE: `relation` not `relationship` used in RequestBuilder already

class RelationType(Type):
def create(self):
""" Create an instance of a relationship with this type """
""" Create an instance of a relation with this type """
create_rel_inst_req = RequestBuilder.ConceptMethod.RelationType.create()
method_response = self._tx_service.run_concept_method(self.id, create_rel_inst_req)
grpc_relationship_concept = method_response.relationType_create_res.relation
grpc_relation_concept = method_response.relationType_create_res.relation
from grakn.service.Session.Concept import ConceptFactory
return ConceptFactory.create_concept(self._tx_service, grpc_relationship_concept)
return ConceptFactory.create_concept(self._tx_service, grpc_relation_concept)

def roles(self):
""" Retrieve roles in this relationship schema type """
""" Retrieve roles in this relation schema type """
get_roles = RequestBuilder.ConceptMethod.RelationType.roles()
method_response = self._tx_service.run_concept_method(self.id, get_roles)
from grakn.service.Session.util import ResponseReader
Expand All @@ -379,13 +376,13 @@ def roles(self):


def relates(self, role):
""" Set a role in this relationship schema type """
""" Set a role in this relation schema type """
relates_req = RequestBuilder.ConceptMethod.RelationType.relates(role)
method_response = self._tx_service.run_concept_method(self.id, relates_req)
return self

def unrelate(self, role):
""" Remove a role in this relationship schema type """
""" Remove a role in this relation schema type """
unrelate_req = RequestBuilder.ConceptMethod.RelationType.unrelate(role)
method_response = self._tx_service.run_concept_method(self.id, unrelate_req)
return self
Expand Down Expand Up @@ -420,9 +417,8 @@ def get_then(self):

class Role(SchemaConcept):

def relationships(self):
""" Retrieve relationships that this role participates in, as an iterator """
# NOTE: relations vs relationships here
def relations(self):
""" Retrieve relations that this role participates in, as an iterator """
relations_req = RequestBuilder.ConceptMethod.Role.relations()
method_response = self._tx_service.run_concept_method(self.id, relations_req)
from grakn.service.Session.util import ResponseReader
Expand Down Expand Up @@ -464,9 +460,8 @@ def type(self):
from grakn.service.Session.Concept import ConceptFactory
return ConceptFactory.create_concept(self._tx_service, method_response.thing_type_res.type)

def relationships(self, *roles):
""" Get iterator this Thing's relationships, filtered to the optionally provided roles """
# NOTE `relations` rather than `relationships`
def relations(self, *roles):
""" Get iterator this Thing's relations, filtered to the optionally provided roles """
relations_req = RequestBuilder.ConceptMethod.Thing.relations(roles)
method_response = self._tx_service.run_concept_method(self.id, relations_req)
from grakn.service.Session.util import ResponseReader
Expand Down Expand Up @@ -558,12 +553,11 @@ def owners(self):
ConceptFactory.create_concept(tx_service, iter_res.conceptMethod_iter_res.attribute_owners_iter_res.thing)
)

class Relationship(Thing):

# NOTE `relation` has replaced `relationship` in ResponseBuilder
class Relation(Thing):

def role_players_map(self):
""" Retrieve dictionary {role : set(players)} for this relationship """
""" Retrieve dictionary {role : set(players)} for this relation """
role_players_map_req = RequestBuilder.ConceptMethod.Relation.role_players_map()
method_response = self._tx_service.run_concept_method(self.id, role_players_map_req)

Expand Down Expand Up @@ -616,13 +610,13 @@ def role_players(self, *roles):


def assign(self, role, thing):
""" Assign an entity to a role on this relationship instance """
""" Assign an entity to a role on this relation instance """
assign_req = RequestBuilder.ConceptMethod.Relation.assign(role, thing)
method_response = self._tx_service.run_concept_method(self.id, assign_req)
return self

def unassign(self, role, thing):
""" Un-assign an entity from a role on this relationship instance """
""" Un-assign an entity from a role on this relation instance """
unassign_req = RequestBuilder.ConceptMethod.Relation.unassign(role, thing)
method_response = self._tx_service.run_concept_method(self.id, unassign_req)
return self
6 changes: 3 additions & 3 deletions grakn/service/Session/Concept/ConceptFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
#

from grakn.service.Session.Concept import BaseTypeMapping
from grakn.service.Session.Concept.Concept import EntityType, RelationshipType, AttributeType, Role, Rule, Entity, Relationship, Attribute, Type
from grakn.service.Session.Concept.Concept import EntityType, RelationType, AttributeType, Role, Rule, Entity, Relation, Attribute, Type


# map names to ConceptHierarchy types
name_to_object = {
BaseTypeMapping.META_TYPE: Type,
BaseTypeMapping.ENTITY_TYPE: EntityType,
BaseTypeMapping.RELATIONSHIP_TYPE: RelationshipType,
BaseTypeMapping.RELATION_TYPE: RelationType,
BaseTypeMapping.ATTRIBUTE_TYPE: AttributeType,
BaseTypeMapping.ROLE: Role,
BaseTypeMapping.RULE: Rule,
BaseTypeMapping.ENTITY: Entity,
BaseTypeMapping.RELATIONSHIP: Relationship,
BaseTypeMapping.RELATION: Relation,
BaseTypeMapping.ATTRIBUTE: Attribute
}

Expand Down
8 changes: 4 additions & 4 deletions grakn/service/Session/TransactionService.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def put_entity_type(self, label):
return ResponseReader.ResponseReader.put_entity_type(self, response.putEntityType_res)
put_entity_type.__annotations__ = {'label': str}

def put_relationship_type(self, label):
request = RequestBuilder.put_relationship_type(label)
def put_relation_type(self, label):
request = RequestBuilder.put_relation_type(label)
response = self._communicator.send(request)
return ResponseReader.ResponseReader.put_relationship_type(self, response.putRelationType_res)
put_relationship_type.__annotations__ = {'label': str}
return ResponseReader.ResponseReader.put_relation_type(self, response.putRelationType_res)
put_relation_type.__annotations__ = {'label': str}

def put_attribute_type(self, label, data_type):
request = RequestBuilder.put_attribute_type(label, data_type)
Expand Down
5 changes: 2 additions & 3 deletions grakn/service/Session/util/RequestBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def put_entity_type(label):
return transaction_req

@staticmethod
def put_relationship_type(label):
# NOTE: Relation vs relationship
def put_relation_type(label):
put_relation_type_req = transaction_messages.Transaction.PutRelationType.Req()
put_relation_type_req.label = label
transaction_req = transaction_messages.Transaction.Req()
Expand Down Expand Up @@ -582,7 +581,7 @@ def unhas(attribute_concept):
return concept_method_req

class Relation(object):
""" Generates Relation (aka Relationship) method messages """
""" Generates Relation method messages """

@staticmethod
def role_players_map():
Expand Down
4 changes: 2 additions & 2 deletions grakn/service/Session/util/ResponseReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def put_entity_type(tx_service, grpc_put_entity_type):
return ConceptFactory.create_concept(tx_service, grpc_put_entity_type.entityType)

@staticmethod
def put_relationship_type(tx_service, grpc_put_relationship_type):
return ConceptFactory.create_concept(tx_service, grpc_put_relationship_type.relationType)
def put_relation_type(tx_service, grpc_put_relation_type):
return ConceptFactory.create_concept(tx_service, grpc_put_relation_type.relationType)

@staticmethod
def put_attribute_type(tx_service, grpc_put_attribute_type):
Expand Down

0 comments on commit 6b56611

Please sign in to comment.