Skip to content

Add openCypher seed datasets #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Starting with v1.31.6, this file will contain a record of major features and updates made in each release of graph-notebook.

## Upcoming
- Added Air-Routes and EPL sample seed datasets for openCypher ([Link to PR](https://git.1-hub.cnaws/graph-notebook/pull/540))

## Release 3.9.0 (Oct 9, 2023)
- New Gremlin Language Tutorial notebooks ([Link to PR](https://git.1-hub.cnaws/graph-notebook/pull/533))
Expand Down
3 changes: 2 additions & 1 deletion src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2513,7 +2513,8 @@ def on_button_clicked(b=None):
progress.close()
return
else: # gremlin and cypher
if fullfile_query: # treat entire file content as one query
# treat entire file content as one query
if fullfile_query or (source_dropdown.value == 'samples' and 'full' in q['name']):
if seeding_language == 'opencypher':
query_status = process_cypher_query_line(q['content'], 0, q)
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
"""
61,407 changes: 61,407 additions & 0 deletions src/graph_notebook/seed/queries/propertygraph/opencypher/airports/airports_full.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Leagues
CREATE (epl:League { name:"English Premier League",nickname: "EPL"})

// Teams
CREATE (arsenal:Team {name:"Arsenal", fullName:"Arsenal F. C.", nickname:"The Gunners", founded:1886})
CREATE (chelsea:Team {name:"Chelsea", fullName:"Chelsea F.C.", nickname:"The Blues", founded:1905})
CREATE (tottenhamhotspur:Team {name:"Tottenham Hotspur", fullName:"Tottenham Hotspur F.C.", nickname:"Spurs", founded:1882})
CREATE (westhamunited:Team {name:"West Ham United", fullName:"West Ham United F.C.", nickname:"The Hammers", founded:1895})
CREATE (liverpool:Team {name:"Liverpool", fullName:"Liverpool F.C.", nickname:"The Reds", founded:1892})
CREATE (everton:Team {name:"Everton", fullName:"Everton F.C.", nickname:"The Toffees", founded:1878})
CREATE (manchesterunited:Team {name:"Manchester United", fullName:"Manchester United F.C.", nickname:"The Red Devils", founded:1878})
CREATE (manchestercity:Team {name:"Manchester City", fullName:"Manchester City F.C", nickname:"The Citizens", founded:1880})
CREATE (wolverhamptonwanderers:Team {name:"Wolverhampton Wanderers", fullName:"Wolverhampton Wanderers F.C", nickname:"Wolves", founded:1877})
CREATE (burnley:Team {name:"Burnley", fullName:"Burnley F.C", nickname:"The Clarets", founded:1882})
CREATE (sheffieldunited:Team {name:"Sheffield United", fullName:"Sheffield United F.C", nickname:"The Blades", founded:1889})
CREATE (crystalpalace:Team {name:"Crystal Palace", fullName:"Crystal Palace F.C", nickname:"Eagles", founded:1905})
CREATE (southampton:Team {name:"Southampton", fullName:"Southampton F.C", nickname:"The Saints", founded:1885})
CREATE (newcastleunited:Team {name:"Newcastle United", fullName:"Newcastle United F.C", nickname:"The Magpies", founded:1892})
CREATE (brightonandhovealbion:Team {name:"Brighton and Hove Albion", fullName:"Brighton and Hove Albion F.C", nickname:"Seagulls", founded:1901})
CREATE (watford:Team {name:"Watford", fullName:"Watford F.C.", nickname:"Hornets", founded:1898})
CREATE (bournemouth:Team {name:"Bournemouth", fullName:"Bournemouth F.C.", nickname:"The Cherries", founded:1899})
CREATE (astonvilla:Team {name:"Aston Villa", fullName:"Aston Villa F.C.", nickname:"The Villans", founded:1897})
CREATE (leicestercity:Team {name:"Leicester City", fullName:"Leicester City F.C.", nickname:"The Foxes", founded:1884})
CREATE (norwichcity:Team {name:"Norwich City", fullName:"Norwich City F.C.", nickname:"The Canaries", founded:1902})

// Stadiums
CREATE (theemirates:Stadium {name:"The Emirates", opened:2006, capacity:60704})
CREATE (stamfordbridge:Stadium {name:"Stamford Bridge", opened:1877, capacity:40834})
CREATE (tottenhamhotspurstadium:Stadium {name:"Tottenham Hotspur Stadium", opened:2019, capacity:62214})
CREATE (londonstadium:Stadium {name:"London Stadium", opened:2016, capacity:60000})
CREATE (anfield:Stadium {name:"Anfield", opened:1884, capacity:53394})
CREATE (goodisonpark:Stadium {name:"Goodison Park", opened:1892, capacity:39414})
CREATE (oldtrafford:Stadium {name:"Old Trafford", opened:1910, capacity:75643})
CREATE (etihadstadium:Stadium {name:"Etihad Stadium", opened:2003, capacity:55107})
CREATE (molineuxstadium:Stadium {name:"Molineux Stadium", opened:1889, capacity:32050})
CREATE (turfmoor:Stadium {name:"Turf Moor", opened:1883, capacity:21944})
CREATE (bramalllane:Stadium {name:"Bramall Lane", opened:1855, capacity:32125})
CREATE (selhurstparkstadium:Stadium {name:"Selhurst Park Stadium", opened:1924, capacity:25486})
CREATE (stmarysstadium:Stadium {name:"St. Mary's Stadium", opened:2001, capacity:32384})
CREATE (stjamespark:Stadium {name:"St. James' Park", opened:1880, capacity:52305})
CREATE (americanexpresscommunitystadium:Stadium {name:"American Express Community Stadium", opened:2011, capacity:30750})
CREATE (vicarageroad:Stadium {name:"Vicarage Road", opened:1922, capacity:22200})
CREATE (vitalitystadium:Stadium {name:"Vitality Stadium", opened:1910, capacity:11364})
CREATE (villapark:Stadium {name:"Villa Park", opened:1897, capacity:42095})
CREATE (kingpowerstadium:Stadium {name:"King Power Stadium", opened:2002, capacity:32261})
CREATE (carrowroadstadium:Stadium {name:"Carrow Road Stadium", opened:1935, capacity:27359})

// Cities
CREATE (citylondon:City {name:"London"})
CREATE (cityliverpool:City {name:"Liverpool"})
CREATE (citymanchester:City {name:"Manchester"})
CREATE (citywolverhampton:City {name:"Wolverhampton"})
CREATE (cityleicester:City {name:"Leicester"})
CREATE (citybrighton:City {name:"Brighton"})
CREATE (citysouthampton:City {name:"Southampton"})
CREATE (citynewcastle:City {name:"Newcastle"})
CREATE (citysheffield:City {name:"Sheffield"})
CREATE (citybirmingham:City {name:"Birmingham"})
CREATE (citywatford:City {name:"Watford"})
CREATE (citynorwich:City {name:"Norwich"})
CREATE (citybournemouth:City {name:"Bournemouth"})
CREATE (cityburnley:City {name:"Burnley"})

// Stadium Rels
CREATE (arsenal)-[:STADIUM]->(theemirates)-[:CITY]->(citylondon)
CREATE (chelsea)-[:STADIUM]->(stamfordbridge)-[:CITY]->(citylondon)
CREATE (tottenhamhotspur)-[:STADIUM]->(tottenhamhotspurstadium)-[:CITY]->(citylondon)
CREATE (westhamunited)-[:STADIUM]->(londonstadium)-[:CITY]->(citylondon)
CREATE (crystalpalace)-[:STADIUM]->(selhurstparkstadium)-[:CITY]->(citylondon)
CREATE (liverpool)-[:STADIUM]->(anfield)-[:CITY]->(cityliverpool)
CREATE (everton)-[:STADIUM]->(goodisonpark)-[:CITY]->(cityliverpool)
CREATE (manchesterunited)-[:STADIUM]->(oldtrafford)-[:CITY]->(citymanchester)
CREATE (manchestercity)-[:STADIUM]->(etihadstadium)-[:CITY]->(citymanchester)
CREATE (wolverhamptonwanderers)-[:STADIUM]->(molineuxstadium)-[:CITY]->(citywolverhampton)
CREATE (leicestercity)-[:STADIUM]->(kingpowerstadium)-[:CITY]->(cityleicester)
CREATE (brightonandhovealbion)-[:STADIUM]->(americanexpresscommunitystadium)-[:CITY]->(citybrighton)
CREATE (southampton)-[:STADIUM]->(stmarysstadium)-[:CITY]->(citysouthampton)
CREATE (newcastleunited)-[:STADIUM]->(stjamespark)-[:CITY]->(citynewcastle)
CREATE (sheffieldunited)-[:STADIUM]->(bramalllane)-[:CITY]->(citysheffield)
CREATE (astonvilla)-[:STADIUM]->(villapark)-[:CITY]->(citybirmingham)
CREATE (watford)-[:STADIUM]->(vicarageroad)-[:CITY]->(citywatford)
CREATE (norwichcity)-[:STADIUM]->(carrowroadstadium)-[:CITY]->(citynorwich)
CREATE (bournemouth)-[:STADIUM]->(vitalitystadium)-[:CITY]->(citybournemouth)
CREATE (burnley)-[:STADIUM]->(turfmoor)-[:CITY]->(cityburnley)

// League Rels
CREATE (arsenal)-[:CURRENT_LEAGUE]->(epl)
CREATE (chelsea)-[:CURRENT_LEAGUE]->(epl)
CREATE (tottenhamhotspur)-[:CURRENT_LEAGUE]->(epl)
CREATE (westhamunited)-[:CURRENT_LEAGUE]->(epl)
CREATE (liverpool)-[:CURRENT_LEAGUE]->(epl)
CREATE (everton)-[:CURRENT_LEAGUE]->(epl)
CREATE (manchesterunited)-[:CURRENT_LEAGUE]->(epl)
CREATE (manchestercity)-[:CURRENT_LEAGUE]->(epl)
CREATE (wolverhamptonwanderers)-[:CURRENT_LEAGUE]->(epl)
CREATE (burnley)-[:CURRENT_LEAGUE]->(epl)
CREATE (sheffieldunited)-[:CURRENT_LEAGUE]->(epl)
CREATE (crystalpalace)-[:CURRENT_LEAGUE]->(epl)
CREATE (southampton)-[:CURRENT_LEAGUE]->(epl)
CREATE (newcastleunited)-[:CURRENT_LEAGUE]->(epl)
CREATE (brightonandhovealbion)-[:CURRENT_LEAGUE]->(epl)
CREATE (watford)-[:CURRENT_LEAGUE]->(epl)
CREATE (bournemouth)-[:CURRENT_LEAGUE]->(epl)
CREATE (astonvilla)-[:CURRENT_LEAGUE]->(epl)
CREATE (leicestercity)-[:CURRENT_LEAGUE]->(epl)
CREATE (norwichcity)-[:CURRENT_LEAGUE]->(epl)
12 changes: 12 additions & 0 deletions test/unit/seed/get_datasets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ def test_get_custom_queries_from_file_sparql(self):
self.assertEqual(1, len(queries))
self.assertEqual('0_test_data.txt', queries[0]['name'])

def test_get_data_sets_cypher(self):
data_sets = get_data_sets('opencypher')
self.assertTrue('airports' in data_sets)

def test_get_sample_queries_cypher(self):
language = 'opencypher'
name = 'airports'
location = 'samples'
queries = get_queries(language, name, location)
self.assertEqual(1, len(queries))
self.assertEqual('airports_full.txt', queries[0]['name'])

def test_get_custom_queries_from_directory_cypher(self):
language = ''
name = 'local_seed_test_cypher'
Expand Down