qlever 0.2.14__py3-none-any.whl → 0.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of qlever might be problematic. Click here for more details.

@@ -1,41 +1,37 @@
1
1
  # Qleverfile for YAGO 4, use with https://github.com/ad-freiburg/qlever-control
2
2
  #
3
- # qlever get-data # downloads eight nt.gz file of size ~60 GB (as of 12.03.2020)
4
- # qlever index # takes ~4.5 hours and ~10 GB RAM (on an AMD Ryzen 9 5900X)
5
- # qlever start # starts the server (takes around one minute)
3
+ # qlever get-data # downloads 8 nt.gz file of size ~60 GB (as of 12.03.2020)
4
+ # qlever index # takes ~4 hours and ~10 GB RAM (on an AMD Ryzen 9 5900X)
5
+ # qlever start # starts the server
6
6
 
7
- # Indexer settings
8
- DB = yago-4
9
- RDF_FILES = "yago-wd-*.nt.gz"
10
- CAT_FILES = "zcat ${RDF_FILES}"
11
- WITH_TEXT_INDEX = false
12
- STXXL_MEMORY = 10G
13
- SETTINGS_JSON = '{ "languages-internal": ["en"], "locale": { "language": "en", "country": "US", "ignore-punctuation": true }, "ascii-prefixes-only": true, "num-triples-per-batch": 5000000 }'
7
+ # NOTE concerning GET_DATA_CMD: The triples from wd-annotated-facts are
8
+ # contained in wd-facts. The "full types" are the YAGO types, the "simple
9
+ # types" are the schema.org types. They don't interfere with each other because
10
+ # they have distinct prefixes.
14
11
 
15
- # Get the data
16
- #
17
- # NOTE: The triples from wd-annotated-facts are contained in wd-facts. The
18
- # "full types" are the YAGO types, the "simple types" are the schema.org types.
19
- # They don't interfere with each other because they have distinct prefixes.
20
- GET_DATA_CMD = "wget -nc https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-class.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-facts.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-full-types.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-labels.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-sameAs.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-schema.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-shapes.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-simple-types.nt.gz"
12
+ [data]
13
+ NAME = yago-4
14
+ GET_DATA_CMD = curl --location --continue-at - --remote-name-all https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-class.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-facts.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-full-types.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-labels.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-sameAs.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-schema.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-shapes.nt.gz https://yago-knowledge.org/data/yago4/full/2020-02-24/yago-wd-simple-types.nt.gz
21
15
  INDEX_DESCRIPTION = "Full dump from https://yago-knowledge.org/downloads/yago-4, version 12.03.2020"
22
16
 
23
- # Server settings
24
- HOSTNAME = $(hostname -f)
25
- SERVER_PORT = 9004
17
+ [index]
18
+ FILE_NAMES = yago-wd-*.nt.gz
19
+ CAT_FILES = zcat ${FILE_NAMES}
20
+ WITH_TEXT_INDEX = false
21
+ STXXL_MEMORY = 10G
22
+ SETTINGS_JSON = { "languages-internal": ["en"], "locale": { "language": "en", "country": "US", "ignore-punctuation": true }, "ascii-prefixes-only": false, "num-triples-per-batch": 5000000 }
23
+
24
+ [server]
25
+ PORT = 9004
26
26
  ACCESS_TOKEN = ${DB}_2347348732
27
27
  MEMORY_FOR_QUERIES = 30G
28
28
  CACHE_MAX_SIZE = 20G
29
29
  CACHE_MAX_SIZE_SINGLE_ENTRY = 5G
30
- CACHE_MAX_NUM_ENTRIES = 100
31
30
 
32
- # QLever binaries
33
- QLEVER_BIN_DIR = /local/data/qlever/qlever-code/build
34
- USE_DOCKER = true
35
- QLEVER_DOCKER_IMAGE = adfreiburg/qlever
36
- QLEVER_DOCKER_CONTAINER = qlever.${DB}
31
+ [docker]
32
+ USE_DOCKER = true
33
+ IMAGE = adfreiburg/qlever
37
34
 
38
- # QLever UI
39
- QLEVERUI_PORT = 7000
40
- QLEVERUI_DIR = qlever-ui
41
- QLEVERUI_CONFIG = yago-4
35
+ [ui]
36
+ PORT = 7000
37
+ CONFIG = yago-4
qlever/__init__.py CHANGED
@@ -91,10 +91,9 @@ def show_available_config_names():
91
91
 
92
92
  # Show the available action names.
93
93
  def show_available_action_names():
94
- log.info("The qlever script takes a sequence of action names as "
95
- "arguments, for example:")
94
+ log.info("You can now execute a sequence of actions, for example:")
96
95
  log.info("")
97
- log.info(f"{BLUE}qlever get-data index restart example-query ui {NORMAL}")
96
+ log.info(f"{BLUE}qlever get-data index restart test-query ui {NORMAL}")
98
97
  log.info("")
99
98
  log.info(f"Available action names are: {', '.join(action_names)}")
100
99
  log.info("")
@@ -147,6 +146,11 @@ class Actions:
147
146
  "general": {
148
147
  "log_level": "info",
149
148
  "pid": "0",
149
+ "example_queries_url": (f"https://qlever.cs.uni-freiburg.de/"
150
+ f"api/examples/"
151
+ f"{self.config['ui']['config']}"),
152
+ "example_queries_limit": "10",
153
+ "example_queries_send": "0",
150
154
  },
151
155
  "index": {
152
156
  "binary": "IndexBuilderMain",
@@ -330,8 +334,8 @@ class Actions:
330
334
  Setup a pre-filled Qleverfile in the current directory.
331
335
  """
332
336
 
333
- log.info(f"{BLUE}Creating a pre-filled Qleverfile{NORMAL}")
334
- log.info("")
337
+ # log.info(f"{BLUE}Creating a pre-filled Qleverfile{NORMAL}")
338
+ # log.info("")
335
339
 
336
340
  # If there is already a Qleverfile in the current directory, exit.
337
341
  if os.path.isfile("Qleverfile"):
@@ -367,8 +371,7 @@ class Actions:
367
371
  log.info("Afterwards, run `qlever` without arguments to see "
368
372
  "which actions are available")
369
373
  else:
370
- log.info("If you are unsure how to continue, run `qlever`"
371
- " without arguments to see the available actions")
374
+ show_available_action_names()
372
375
  log.info("")
373
376
 
374
377
  @track_action_rank
@@ -1018,6 +1021,59 @@ class Actions:
1018
1021
  raise ActionException(f"Failed to get cache stats and settings: "
1019
1022
  f"{e}")
1020
1023
 
1024
+ @track_action_rank
1025
+ def action_clear_cache(self, only_show=False):
1026
+ """
1027
+ Action that clears the cache (unpinned entries only).
1028
+ """
1029
+
1030
+ # Construct the curl command.
1031
+ clear_cache_cmd = (f"curl -s {self.config['server']['url']} "
1032
+ f"--data-urlencode \"cmd=clear-cache\"")
1033
+
1034
+ # Show it.
1035
+ self.show(clear_cache_cmd, only_show)
1036
+ if only_show:
1037
+ return
1038
+
1039
+ # Execute it.
1040
+ try:
1041
+ subprocess.run(clear_cache_cmd, shell=True,
1042
+ stdout=subprocess.DEVNULL)
1043
+ print("Cache cleared (only unpinned entries)")
1044
+ print()
1045
+ self.action_cache_stats_and_settings(only_show)
1046
+ except Exception as e:
1047
+ raise ActionException(f"Failed to clear the cache: {e}")
1048
+
1049
+ @track_action_rank
1050
+ def action_clear_cache_complete(self, only_show=False):
1051
+ """
1052
+ Action that clears the cache completely (both pinned and unpinned
1053
+ entries).
1054
+ """
1055
+
1056
+ # Construct the curl command.
1057
+ access_token = self.config['server']['access_token']
1058
+ clear_cache_cmd = (f"curl -s {self.config['server']['url']} "
1059
+ f"--data-urlencode \"cmd=clear-cache-complete\" "
1060
+ f"--data-urlencode \"access-token={access_token}\"")
1061
+
1062
+ # Show it.
1063
+ self.show(clear_cache_cmd, only_show)
1064
+ if only_show:
1065
+ return
1066
+
1067
+ # Execute it.
1068
+ try:
1069
+ subprocess.run(clear_cache_cmd, shell=True,
1070
+ stdout=subprocess.DEVNULL)
1071
+ print("Cache cleared (both pinned and unpinned entries)")
1072
+ print()
1073
+ self.action_cache_stats_and_settings(only_show)
1074
+ except Exception as e:
1075
+ raise ActionException(f"Failed to clear the cache: {e}")
1076
+
1021
1077
  @track_action_rank
1022
1078
  def action_autocompletion_warmup(self, only_show=False):
1023
1079
  """
@@ -1066,6 +1122,8 @@ class Actions:
1066
1122
  f"--data-urlencode access-token={access_token} "
1067
1123
  f"--data-urlencode pinresult=true "
1068
1124
  f"--data-urlencode send=0")
1125
+ clear_cache_cmd = (f"curl -s {self.config['server']['url']} "
1126
+ f"--data-urlencode \"cmd=clear-cache\"")
1069
1127
  log.info(pin_cmd)
1070
1128
  # Launch query and show the `resultsize` of the JSON response.
1071
1129
  try:
@@ -1075,6 +1133,9 @@ class Actions:
1075
1133
  if "exception" in json_result:
1076
1134
  raise Exception(json_result["exception"])
1077
1135
  log.info(f"Result size: {json_result['resultsize']:,}")
1136
+ log.info(clear_cache_cmd)
1137
+ subprocess.check_output(clear_cache_cmd, shell=True,
1138
+ stderr=subprocess.DEVNULL)
1078
1139
  except Exception as e:
1079
1140
  log.error(f"Query failed: {e}")
1080
1141
 
@@ -1085,14 +1146,18 @@ class Actions:
1085
1146
  """
1086
1147
 
1087
1148
  # Construct curl command to obtain the example queries.
1088
- config_name = self.config["ui"]["config"]
1089
- examples_url = f"{self.config['ui']['url']}/examples/{config_name}"
1090
- curl_cmd = f"curl -s {examples_url}"
1149
+ config_general = self.config["general"]
1150
+ example_queries_url = config_general["example_queries_url"]
1151
+ example_queries_limit = int(config_general["example_queries_limit"])
1152
+ example_queries_send = int(config_general["example_queries_send"])
1153
+ curl_cmd = f"curl -s {example_queries_url}"
1091
1154
 
1092
1155
  # Show what the action does.
1093
1156
  self.show(f"Launch example queries obtained via: {curl_cmd}\n"
1094
1157
  f"SPARQL endpoint: {self.config['server']['url']}\n"
1095
- f"Clearing the cache before each query + using send=0",
1158
+ f"Clearing the cache before each query\n"
1159
+ f"Using send={example_queries_send} and limit="
1160
+ f"{example_queries_limit}",
1096
1161
  only_show)
1097
1162
  if only_show:
1098
1163
  return
@@ -1116,7 +1181,7 @@ class Actions:
1116
1181
  query_cmd = (f"curl -s {self.config['server']['url']} "
1117
1182
  f"-H \"Accept: application/qlever-results+json\" "
1118
1183
  f"--data-urlencode query={shlex.quote(query)} "
1119
- f"--data-urlencode send=0")
1184
+ f"--data-urlencode send={example_queries_send}")
1120
1185
  try:
1121
1186
  subprocess.run(clear_cache_cmd, shell=True,
1122
1187
  stdout=subprocess.DEVNULL,
@@ -1128,28 +1193,33 @@ class Actions:
1128
1193
  if "exception" in json_result:
1129
1194
  raise Exception(json_result["exception"])
1130
1195
  result_size = int(json_result["resultsize"])
1131
- result_string = "{:,}".format(result_size)
1196
+ result_string = f"{result_size:>14,}"
1132
1197
  except Exception as e:
1133
1198
  time_seconds = 0.0
1134
1199
  result_size = 0
1135
- result_string = f"{RED}{e}{NORMAL}"
1200
+ result_string = (f"{RED} FAILED{NORMAL}"
1201
+ f" {RED}({e}){NORMAL}")
1136
1202
 
1137
1203
  # Print description, time, result in tabular form.
1138
1204
  log.debug(query)
1139
1205
  log.info(f"{description:<60} {time_seconds:6.2f} s "
1140
- f"{result_string:>10}")
1206
+ f"{result_string}")
1141
1207
  count += 1
1142
1208
  total_time_seconds += time_seconds
1143
1209
  total_result_size += result_size
1144
- if count == 10:
1210
+ if count == example_queries_limit:
1145
1211
  break
1146
1212
 
1147
1213
  # Print total time.
1148
1214
  log.info("")
1149
- description = (f"TOTAL for {count} "
1215
+ description = (f"TOTAL for {count} "
1150
1216
  f"{'query' if count == 1 else 'queries'}")
1151
1217
  log.info(f"{description:<60} {total_time_seconds:6.2f} s "
1152
- f"{total_result_size:>10,}")
1218
+ f"{total_result_size:>14,}")
1219
+ description = (f"AVERAGE for {count} "
1220
+ f"{'query' if count == 1 else 'queries'}")
1221
+ log.info(f"{description:<60} {total_time_seconds / count:6.2f} s "
1222
+ f"{round(total_result_size / count):>14,}")
1153
1223
 
1154
1224
  @track_action_rank
1155
1225
  def action_memory_profile(self, only_show=False):
@@ -1386,3 +1456,5 @@ def main():
1386
1456
  # Execute the action (or only show what would be executed).
1387
1457
  execute_action(actions, action_name, only_show=only_show)
1388
1458
  log.info("")
1459
+
1460
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qlever
3
- Version: 0.2.14
3
+ Version: 0.3.1
4
4
  Summary: Script for using the QLever SPARQL engine.
5
5
  Author-email: Hannah Bast <bast@cs.uni-freiburg.de>
6
6
  License: Apache License
@@ -1,4 +1,4 @@
1
- qlever/__init__.py,sha256=IrxDbgzT3u_unXXTy2wXQ5HGVOYbxY0O0eBAd5wmWOs,58394
1
+ qlever/__init__.py,sha256=55Dxjww9I-7XCHrjvzku79lPSdg6brRxvwwZUZg2c3Q,61344
2
2
  qlever/__main__.py,sha256=mmp__u0a-Dztg3BUlJ4LL98OVo_j1MLiDCKewKlwfMM,38
3
3
  qlever/Qleverfiles/Qleverfile.dblp,sha256=yuSDOhC3ypsXt2rAd4yjSzz0OQsZ2i6Pcq0Qh-stlBM,1199
4
4
  qlever/Qleverfiles/Qleverfile.dblp-plus,sha256=E9bW49ztinBlW7azcT51QPW2jQWBPk29SDZ31RuIOO4,1389
@@ -6,7 +6,6 @@ qlever/Qleverfiles/Qleverfile.default,sha256=1roS4FHGiSA7iXBcX2DH3zwE5Ozht6-A551
6
6
  qlever/Qleverfiles/Qleverfile.dnb,sha256=TNyLFuN_VJeNPlbHKAqLbSw1dgqUTBS5HbYJOJohRsI,1547
7
7
  qlever/Qleverfiles/Qleverfile.fbeasy,sha256=N_ctx6Ae7ISbrOtBthOso_5_SCZuMz7TxsaiTzFd-mc,1032
8
8
  qlever/Qleverfiles/Qleverfile.freebase,sha256=JbjW5JTpiCvaGVqjCq2CawPVNWStwwH5sptdK85Y2KM,1150
9
- qlever/Qleverfiles/Qleverfile.gnd,sha256=9TtYaaztetZ-V0xDE7FejkTFaH466WWmfI-R-IJkWE4,1049
10
9
  qlever/Qleverfiles/Qleverfile.imdb,sha256=o5LfmZZKZH7Ycu0qaxQF1L_4KVLhd5R2DIYw3bCJ7BM,1654
11
10
  qlever/Qleverfiles/Qleverfile.olympics,sha256=09yDlhbrr0kqImLQKqIe2NkS35aWGSJJUHyI1ollQBE,1055
12
11
  qlever/Qleverfiles/Qleverfile.osm-country,sha256=zYu4734aGeqwL2xBc9A4qHchYdyHyv6L5ny1XL7bA-A,1959
@@ -14,10 +13,10 @@ qlever/Qleverfiles/Qleverfile.pubchem,sha256=Wk5adgo4tIHbCg57cWwoOqIBBSN878wqjEW
14
13
  qlever/Qleverfiles/Qleverfile.scientists,sha256=oFhzURcRFciA27GZ-ux_hsDe0esBLobWHC6h_Vf2xy8,1735
15
14
  qlever/Qleverfiles/Qleverfile.uniprot,sha256=q5Nkr3diZ5oXdT0N72ONBEHBFZQCKYmEChAsjO4hnwE,2249
16
15
  qlever/Qleverfiles/Qleverfile.wikidata,sha256=qTb9UjiAIZVIxCIXVEvaNNMacN0c0x2cPWXChPQcgmw,1346
17
- qlever/Qleverfiles/Qleverfile.yago-4,sha256=iX6oUloi_opZYetfNJLmGoHd47VmCKiuUAhpwYJu4QU,2233
18
- qlever-0.2.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
19
- qlever-0.2.14.dist-info/METADATA,sha256=9eaFdSkRxT8zL7NkZ01xOzyfqRgkJzUFhNs407DzLQ0,16152
20
- qlever-0.2.14.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
21
- qlever-0.2.14.dist-info/entry_points.txt,sha256=pWFGQafjVuvwADcae4_8QVFeqPbTynj5RabMsod5VOY,39
22
- qlever-0.2.14.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
23
- qlever-0.2.14.dist-info/RECORD,,
16
+ qlever/Qleverfiles/Qleverfile.yago-4,sha256=ghAJRf6VhJfTOh8grdIekeFgmroaCVMTdRhKr7vYVes,1944
17
+ qlever-0.3.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
+ qlever-0.3.1.dist-info/METADATA,sha256=diUXBn4bdAvOX3k3QEQYXfxQ748hdSM1FNCvB3l6JWg,16151
19
+ qlever-0.3.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
20
+ qlever-0.3.1.dist-info/entry_points.txt,sha256=pWFGQafjVuvwADcae4_8QVFeqPbTynj5RabMsod5VOY,39
21
+ qlever-0.3.1.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
22
+ qlever-0.3.1.dist-info/RECORD,,
@@ -1,31 +0,0 @@
1
- # Qleverfile for Olympics, use with https://github.com/ad-freiburg/qlever-control
2
- #
3
- # qlever get-data # downloads .zip file of size 13 MB, uncompressed to 323 MB
4
- # qlever index # takes ~10 seconds and ~1 GB RAM (on an AMD Ryzen 9 5900X)
5
- # qlever start # starts the server (instant)
6
-
7
- [data]
8
- NAME = gnd
9
- BASE_URL = https://github.com/wallscope/olympics-rdf
10
- GET_DATA_CMD = curl -O https://data.dnb.de/opendata/authorities-gnd_lds.nt.gz
11
- INDEX_DESCRIPTION = GND authority data from https://data.dnb.de/opendata/authorities-gnd_lds.nt.gz
12
- # TEXT_DESCRIPTION = All literals, search with FILTER CONTAINS(?var, "...")
13
-
14
- [index]
15
- FILE_NAMES = authorities-gnd_lds.nt.gz
16
- CAT_FILES = zcat ${FILE_NAMES}
17
- SETTINGS_JSON = { "ascii-prefixes-only": true, "num-triples-per-batch": 1000000 }
18
-
19
- [server]
20
- PORT = 7035
21
- ACCESS_TOKEN = ${data:NAME}_7643543846
22
- MEMORY_FOR_QUERIES_GB = 5
23
- CACHE_MAX_SIZE_GB = 2
24
-
25
- [docker]
26
- USE_DOCKER = true
27
- IMAGE = adfreiburg/qlever
28
-
29
- [ui]
30
- PORT = 7000
31
- CONFIG = olympics