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

Commit

Permalink
Merge pull request #65 from gchq/gh-64-update-gaffer
Browse files Browse the repository at this point in the history
gh-64 - updated to Gaffer 0.6.2
  • Loading branch information
p013570 authored Mar 8, 2017
2 parents 6252a59 + 7b4df87 commit 3022950
Show file tree
Hide file tree
Showing 10 changed files with 272 additions and 43 deletions.
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gaffer tools is built using maven. This process will automatically pull in depen
projects below.


Gaffer (uk.gov.gchq.gaffer:gaffer2:0.6.1):
Gaffer (uk.gov.gchq.gaffer:gaffer2:0.6.2):

- Apache License, Version 2.0

Expand Down
8 changes: 4 additions & 4 deletions mini-accumulo-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ or

Can be built using 'mvn package' and run from the command line using:
```bash
java -cp target/mini-accumulo-cluster-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterWithShellController
java -cp target/mini-accumulo-cluster-[version]-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterWithShellController
```

When starting up it will print out something similar to:
Expand All @@ -53,12 +53,12 @@ This requires the same arguments as the cluster-with-shell, but it will not open
To run from command line, for example

```bash
java -cp target/mini-accumulo-cluster-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance
java -cp target/mini-accumulo-cluster-[version]-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance
```

It may be necessary to add other libraries to the accumulo classpath, to allow things like Gaffer to work. In this case you can use the following command to add libraries to the classpath.
```bash
java -cp target/mini-accumulo-cluster-jar-jar-with-dependencies.jar:otherFile1.jar:otherFile2.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance
java -cp target/mini-accumulo-cluster-[version]-jar-with-dependencies.jar:otherFile1.jar:otherFile2.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloClusterController ~/miniAccumuloCluster false password instance
```

shell
Expand All @@ -72,7 +72,7 @@ This can be run in one of two ways
In either case, the first argument must be the store.properties filename created by the cluster. In the second case, add another argument that points to the file containing the commands to run.

```bash
java -cp target/mini-accumulo-cluster-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloShellController ~/miniAccumuloCluster/store.properties
java -cp target/mini-accumulo-cluster-[version]-jar-with-dependencies.jar uk.gov.gchq.gaffer.miniaccumulocluster.MiniAccumuloShellController ~/miniAccumuloCluster/store.properties
```


4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>gaffer2</artifactId>
<version>0.6.1</version>
<version>0.6.2</version>
</parent>

<artifactId>gaffer-tools</artifactId>
Expand All @@ -38,7 +38,7 @@
</modules>

<properties>
<gaffer.version>0.6.1</gaffer.version>
<gaffer.version>0.6.2</gaffer.version>
<scm.url>
https://github.com/gchq/gaffer-tools
</scm.url>
Expand Down
2 changes: 1 addition & 1 deletion python-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This creates a distributable Python wheel which can installed locally to provide
The wheel file is install using pip:

```bash
pip3 install gaffer_shell-0.6.1-py2.py3-none-any.whl
pip3 install gaffer_shell-0.6.2-py2.py3-none-any.whl
```

After installation the shell can be imported into an application as below:
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from gafferpy import gaffer_connector
from gafferpy import gaffer_connector_pki

__version__ = "0.6.1"
__version__ = "0.6.2"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
122 changes: 115 additions & 7 deletions python-shell/src/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ def run_with_connector(gc):
generate_domain_objects_chain(gc)
get_element_group_counts(gc)
get_sub_graph(gc)
export_to_gaffer_result_cache(gc)
get_job_details(gc)
get_all_job_details(gc)
add_named_operation(gc)
get_all_named_operations(gc)
named_operation(gc)
delete_named_operation(gc)

op_chain_in_json(gc)


Expand Down Expand Up @@ -347,24 +355,124 @@ def get_element_group_counts(gc):


def get_sub_graph(gc):
# Initialise, update and fetch an in memory set export
# Export and Get to/from an in memory set
entity_seeds = gc.execute_operations(
[
g.InitialiseSetExport(),
g.GetAdjacentEntitySeeds(
seeds=[g.EntitySeed('1')],
),
g.UpdateExport(),
g.ExportToSet(),
g.GetAdjacentEntitySeeds(),
g.UpdateExport(),
g.FetchExport()
g.ExportToSet(),
g.GetSetExport()
]
)
print('Initialise, update and fetch export with adjacent entities')
print('Export and Get to/from an in memory set')
print(entity_seeds)
print()


def export_to_gaffer_result_cache(gc):
# Export to Gaffer Result Cache and Get from Gaffer Result Cache
job_details = gc.execute_operations(
[
g.GetAdjacentEntitySeeds(
seeds=[g.EntitySeed('1')],
),
g.ExportToGafferResultCache(),
g.GetJobDetails()
]
)
print('Export to Gaffer Result Cache. Job Details:')
print(job_details)
print()

job_id = job_details['jobId']
entity_seeds = gc.execute_operation(
g.GetGafferResultCacheExport(job_id=job_id),
)
print('Get Gaffer Result Cache Export.')
print(entity_seeds)
print()


def get_job_details(gc):
# Get all job details
job_details_initial = gc.execute_operations(
[
g.GetAdjacentEntitySeeds(
seeds=[g.EntitySeed('1')],
),
g.ExportToGafferResultCache(),
g.GetJobDetails()
]
)

job_id = job_details_initial['jobId']

job_details = gc.execute_operation(
g.GetJobDetails(job_id=job_id),
)
print('Get job details')
print(job_details)
print()


def get_all_job_details(gc):
# Get all job details
all_job_details = gc.execute_operation(
g.GetAllJobDetails(),
)
print('Get all job details (just prints the first 3 results)')
print(all_job_details[:3])
print()


def delete_named_operation(gc):
gc.execute_operation(
g.DeleteNamedOperation('CountAllElementGroups')
)
print('Deleted named operation: CountAllElementGroups')
print()


def add_named_operation(gc):
gc.execute_operation(
g.AddNamedOperation(
operation_chain={
"operations": [{
"class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements",
}, {
"class": "uk.gov.gchq.gaffer.operation.impl.CountGroups"
}]
},
name='CountAllElementGroups',
description='Counts all element groups',
overwrite=True
)
)
print('Added named operation: CountAllElementGroups')
print()


def get_all_named_operations(gc):
namedOperations = gc.execute_operation(
g.GetAllNamedOperations()
)
print('Named operations')
print(namedOperations)
print()


def named_operation(gc):
result = gc.execute_operation(
g.NamedOperation('CountAllElementGroups')
)
print('Execute named operation')
print(result)
print()


def op_chain_in_json(gc):
# Operation chain defined in json
result = gc.execute_operation_chain(
Expand All @@ -382,4 +490,4 @@ def op_chain_in_json(gc):


if __name__ == "__main__":
run('http://localhost:8080/rest/v1')
run('http://localhost:8080/rest/v1', False)
2 changes: 1 addition & 1 deletion python-shell/src/gafferpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from . import gaffer_connector
from . import gaffer_connector_pki

__version__ = "0.6.1"
__version__ = "0.6.2"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
Loading

0 comments on commit 3022950

Please sign in to comment.