qlever 0.5.15__py3-none-any.whl → 0.5.18__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.

qlever/qleverfile.py CHANGED
@@ -76,7 +76,9 @@ class Qleverfile:
76
76
  "all the files of the dataset",
77
77
  )
78
78
  index_args["cat_input_files"] = arg(
79
- "--cat-input-files", type=str, help="The command that produces the input"
79
+ "--cat-input-files",
80
+ type=str,
81
+ help="The command that produces the input",
80
82
  )
81
83
  index_args["multi_input_json"] = arg(
82
84
  "--multi-input-json",
@@ -103,6 +105,14 @@ class Qleverfile:
103
105
  default="{}",
104
106
  help="The `.settings.json` file for the index",
105
107
  )
108
+ index_args["ulimit"] = arg(
109
+ "--ulimit",
110
+ type=int,
111
+ default=None,
112
+ help="Explicitly set the limit for the maximal number of open "
113
+ "files (default: 1048576 when the total size of the input files "
114
+ "is larger than 10 GB)",
115
+ )
106
116
  index_args["index_binary"] = arg(
107
117
  "--index-binary",
108
118
  type=str,
@@ -113,10 +123,17 @@ class Qleverfile:
113
123
  index_args["stxxl_memory"] = arg(
114
124
  "--stxxl-memory",
115
125
  type=str,
116
- default="5G",
117
126
  help="The amount of memory to use for the index build "
118
127
  "(the name of the option has historical reasons)",
119
128
  )
129
+ index_args["parser_buffer_size"] = arg(
130
+ "--parser-buffer-size",
131
+ type=str,
132
+ help="Each parser thread reads the input in batches of this size, "
133
+ "and in parallel parsing, each batch that is not the last must be "
134
+ "large enough to contain the end of at least one statement "
135
+ "(default: 10M)",
136
+ )
120
137
  index_args["only_pso_and_pos_permutations"] = arg(
121
138
  "--only-pso-and-pos-permutations",
122
139
  action="store_true",
@@ -140,7 +157,8 @@ class Qleverfile:
140
157
  "from_text_records_and_literals",
141
158
  ],
142
159
  default="none",
143
- help="Whether to also build an index for text search" "and for which texts",
160
+ help="Whether to also build an index for text search"
161
+ "and for which texts",
144
162
  )
145
163
  index_args["text_words_file"] = arg(
146
164
  "--text-words-file",
@@ -168,10 +186,13 @@ class Qleverfile:
168
186
  "--host-name",
169
187
  type=str,
170
188
  default="localhost",
171
- help="The name of the host on which the server listens for " "requests",
189
+ help="The name of the host on which the server listens for "
190
+ "requests",
172
191
  )
173
192
  server_args["port"] = arg(
174
- "--port", type=int, help="The port on which the server listens for requests"
193
+ "--port",
194
+ type=int,
195
+ help="The port on which the server listens for requests",
175
196
  )
176
197
  server_args["access_token"] = arg(
177
198
  "--access-token",
@@ -328,7 +349,9 @@ class Qleverfile:
328
349
 
329
350
  # Read the Qleverfile.
330
351
  defaults = {"random": "83724324hztz", "version": "01.01.01"}
331
- config = ConfigParser(interpolation=ExtendedInterpolation(), defaults=defaults)
352
+ config = ConfigParser(
353
+ interpolation=ExtendedInterpolation(), defaults=defaults
354
+ )
332
355
  try:
333
356
  config.read(qleverfile_path)
334
357
  except Exception as e:
qlever/util.py CHANGED
@@ -3,9 +3,9 @@ from __future__ import annotations
3
3
  import errno
4
4
  import re
5
5
  import secrets
6
- import socket
7
6
  import shlex
8
7
  import shutil
8
+ import socket
9
9
  import string
10
10
  import subprocess
11
11
  from datetime import date, datetime
@@ -30,8 +30,11 @@ def get_total_file_size(patterns: list[str]) -> int:
30
30
 
31
31
 
32
32
  def run_command(
33
- cmd: str, return_output: bool = False, show_output: bool = False
34
- ) -> Optional[str]:
33
+ cmd: str,
34
+ return_output: bool = False,
35
+ show_output: bool = False,
36
+ use_popen: bool = False,
37
+ ) -> Optional[str | subprocess.Popen]:
35
38
  """
36
39
  Run the given command and throw an exception if the exit code is non-zero.
37
40
  If `return_output` is `True`, return what the command wrote to `stdout`.
@@ -41,6 +44,7 @@ def run_command(
41
44
 
42
45
  TODO: Find the executable for `bash` in `__init__.py`.
43
46
  """
47
+
44
48
  subprocess_args = {
45
49
  "executable": shutil.which("bash"),
46
50
  "shell": True,
@@ -48,17 +52,21 @@ def run_command(
48
52
  "stdout": None if show_output else subprocess.PIPE,
49
53
  "stderr": subprocess.PIPE,
50
54
  }
55
+
56
+ # With `Popen`, the command runs in the current shell and a process object
57
+ # is returned (which can be used, e.g., to kill the process).
58
+ if use_popen:
59
+ if return_output:
60
+ raise Exception("Cannot return output if `use_popen` is `True`")
61
+ return subprocess.Popen(f"set -o pipefail; {cmd}", **subprocess_args)
62
+
63
+ # With `run`, the command runs in a subshell and the output is captured.
51
64
  result = subprocess.run(f"set -o pipefail; {cmd}", **subprocess_args)
65
+
52
66
  # If the exit code is non-zero, throw an exception. If something was
53
67
  # written to `stderr`, use that as the exception message. Otherwise, use a
54
68
  # generic message (which is also what `subprocess.run` does with
55
69
  # `check=True`).
56
- # log.debug(f"Command `{cmd}` returned the following result")
57
- # log.debug("")
58
- # log.debug(f"exit code: {result.returncode}")
59
- # log.debug(f"stdout: {result.stdout}")
60
- # log.debug(f"stderr: {result.stderr}")
61
- # log.debug("")
62
70
  if result.returncode != 0:
63
71
  if len(result.stderr) > 0:
64
72
  raise Exception(result.stderr.replace("\n", " ").strip())
@@ -99,7 +107,11 @@ def run_curl_command(
99
107
  )
100
108
  )
101
109
  result = subprocess.run(
102
- curl_cmd, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
110
+ curl_cmd,
111
+ shell=True,
112
+ text=True,
113
+ stdout=subprocess.PIPE,
114
+ stderr=subprocess.PIPE,
103
115
  )
104
116
  # Case 1: An error occurred, raise an exception.
105
117
  if result.returncode != 0:
@@ -120,18 +132,23 @@ def run_curl_command(
120
132
  return result.stdout
121
133
 
122
134
 
123
- def is_qlever_server_alive(port: str) -> bool:
135
+ def is_qlever_server_alive(endpoint_url: str) -> bool:
124
136
  """
125
137
  Helper function that checks if a QLever server is running on the given
126
- port.
138
+ endpoint. Return `True` if the server is alive, `False` otherwise.
127
139
  """
128
140
 
129
- message = "from the qlever script".replace(" ", "%20")
130
- curl_cmd = f"curl -s http://localhost:{port}/ping?msg={message}"
131
- exit_code = subprocess.call(
132
- curl_cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
141
+ message = "from the `qlever` CLI"
142
+ curl_cmd = (
143
+ f"curl -s {endpoint_url}/ping"
144
+ f" --data-urlencode msg={shlex.quote(message)}"
133
145
  )
134
- return exit_code == 0
146
+ log.debug(curl_cmd)
147
+ try:
148
+ run_command(curl_cmd)
149
+ return True
150
+ except Exception:
151
+ return False
135
152
 
136
153
 
137
154
  def get_existing_index_files(basename: str) -> list[str]:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: qlever
3
- Version: 0.5.15
3
+ Version: 0.5.18
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-2.0
@@ -1,12 +1,12 @@
1
- qlever/__init__.py,sha256=7VKA8tp5iHZQyTXhDOcxUbloZ7WyxDnkruq0iJOzQcE,1403
2
- qlever/command.py,sha256=yOr0Uc8D8-AM7EjwDsVzbc3KNYjPH-FVOZhIHkqO588,2749
1
+ qlever/__init__.py,sha256=GlDcYX0TzV-7nAFaBzPc1Y6cNwz0rsLJFNfLNXl9UiM,1410
2
+ qlever/command.py,sha256=oxsMtu445OnoZ6kKRJCUbyAGbavWcu39gLor8hWuLjQ,2765
3
3
  qlever/config.py,sha256=qYPy-MQ7BwGrvKSazQWhs0lnlOFqm-d47mpZhc3fptc,10254
4
4
  qlever/containerize.py,sha256=bnHmjKIFEe-NcuAMRNnXAFjRVLcLnk9f5JspCCyhgt8,5210
5
- qlever/log.py,sha256=2O_RvFymnu_dB10ErBTAOsI8bgjORfdD0tE3USH-siM,1315
5
+ qlever/log.py,sha256=WLscWV4fFF_w_uXSOfvWzhyzRM7t_61inE2ks3zf6Gw,1317
6
6
  qlever/qlever_main.py,sha256=-E4W8YdZ_teszGwXu6bQgBcH3y47TFJU8JLPIDwc_-g,2449
7
- qlever/qlever_old.py,sha256=X-JxmepFKYeFgSLLp0TRDNqXSxDwIbc8_0Xstiems8c,62026
8
- qlever/qleverfile.py,sha256=lygAjI5_wV_e-JoIGIqVTdd4yyvApzZiSlqSsmdlJpU,14529
9
- qlever/util.py,sha256=qLxBRyHPT2VTj0xcOCFcP6HV-Lm-g-64QpvOc4V0_a8,8029
7
+ qlever/qlever_old.py,sha256=cY55BD3tCsxBmxKobKkI-VtjQBj6-4b3TLGs_9gXwQc,63388
8
+ qlever/qleverfile.py,sha256=8J5s0zhVH97QaQtedYkfyvyps5B28nhaoNwRF1fROwY,15287
9
+ qlever/util.py,sha256=xAK9GT8SgU3z65F1dFXazxsd60letqLQqQAZ81mdJSY,8374
10
10
  qlever/Qleverfiles/Qleverfile.dblp,sha256=RaTJrabloAdaHwSl5V7Ws9phWyM_oXPSeZpKodZXA6c,1256
11
11
  qlever/Qleverfiles/Qleverfile.dblp-plus,sha256=TJHxp8I1P6JKJjbuAllEpB32-huuY1gH0FlenqPVJ5g,1334
12
12
  qlever/Qleverfiles/Qleverfile.dbpedia,sha256=aaNZZayE-zVePGSwPzXemkX__Ns8-kP_E7DNNKZPnqg,1160
@@ -15,38 +15,40 @@ qlever/Qleverfiles/Qleverfile.dnb,sha256=43w_CVi00yf7FHdDvBtHHQR3yU1d-JCNnD_uxYZ
15
15
  qlever/Qleverfiles/Qleverfile.fbeasy,sha256=9dwCMltT0BIMN4LRmaZFp1a7aV0kh0nJ9XLiQb_NJNo,940
16
16
  qlever/Qleverfiles/Qleverfile.freebase,sha256=eFMOxeyuWVbb06Gv2-VFkuKE5tTyckddTDHdw5wbZN8,1028
17
17
  qlever/Qleverfiles/Qleverfile.imdb,sha256=1xUBFimgnEHKP_o6tlqwJvIVpEE4Zx6UK_JnnQsG7Ew,1638
18
- qlever/Qleverfiles/Qleverfile.ohm-planet,sha256=yG6NgW6x6sGTzmCi1wEAkQ-i9goTj2u3PQxvCUwjExs,2122
18
+ qlever/Qleverfiles/Qleverfile.ohm-planet,sha256=xZJ0tyJmPGcD-naWV7BUBCj8ADxcKEN2AxvsrHuYuZs,2286
19
19
  qlever/Qleverfiles/Qleverfile.olympics,sha256=5w9BOFwEBhdSzPz-0LRxwhv-7Gj6xbF539HOXr3cqD0,1088
20
20
  qlever/Qleverfiles/Qleverfile.orkg,sha256=Uizz-RhlSeExgfckWztewa4l_v3zMN8IR7NaGYKrqt4,937
21
21
  qlever/Qleverfiles/Qleverfile.osm-country,sha256=Pb9o5H3b7wVlVRgdiPHWCvrnkIRS1YUhxOazbUmoKZE,1897
22
- qlever/Qleverfiles/Qleverfile.osm-planet,sha256=555aaMOIzAILvzwpCjucd_GE7TlYxmT2Qh8hME68stU,1418
22
+ qlever/Qleverfiles/Qleverfile.osm-planet,sha256=-TN85LV6A8ukWhzkriV4RFuXsduUwDbU9xpg14MXcbA,1379
23
23
  qlever/Qleverfiles/Qleverfile.pubchem,sha256=ooSj2gqTzbGY_pMCvfL-MfE7Z0d5hQB4_EF5Pp2Mn6M,14465
24
24
  qlever/Qleverfiles/Qleverfile.scientists,sha256=9eZ2c6P9a3E3VHa3RR7LdOQbF4k3oyyrn56Z3u4LZYs,1164
25
- qlever/Qleverfiles/Qleverfile.uniprot,sha256=Yejez7uel9Vp8e4w-fI8-qLSqWyDUvjlq33gpebVC5k,6329
25
+ qlever/Qleverfiles/Qleverfile.uniprot,sha256=Agih0rz1gRkfQjHNynLqBQ5OzljofopbOgArP6ijsNQ,6240
26
26
  qlever/Qleverfiles/Qleverfile.vvz,sha256=cLzm85erKoFCDllH5eFcSi35MdR6Tahj1MgtvGRxanM,922
27
27
  qlever/Qleverfiles/Qleverfile.wikidata,sha256=zVUXF75XJyK1h-J-7EjFemzmkSyoPtng1mNY3U7S78M,2061
28
28
  qlever/Qleverfiles/Qleverfile.wikipathways,sha256=UFEVLrtOBiSQfibBN9xc2wDXrnWcnx5f8PY9khcE6bc,1983
29
29
  qlever/Qleverfiles/Qleverfile.yago-4,sha256=hAS_2ZmC1zxNsKXip7t1F_iqu3CC-6O7v6HZhuFbnWY,1819
30
30
  qlever/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- qlever/commands/add_text_index.py,sha256=cvBhX5rooRAXsn1Oput6b0B10w-MGMfS4ZPAhDfm7OQ,3669
31
+ qlever/commands/add_text_index.py,sha256=xJ49Iq1-CszXjHDvOpllqLw1J1kCxQl7H848XD1vEz0,3820
32
32
  qlever/commands/cache_stats.py,sha256=zGPLSWDNn7dwAAt2o-2ExqHmw1FeN8i6nEQbaaqF830,4156
33
33
  qlever/commands/clear_cache.py,sha256=n52ohE1EE4M_B4kId_v8tbAlW-BGwG1K-ZYQ9QgxIJU,2974
34
- qlever/commands/example_queries.py,sha256=g5s9nPDj9SmvLYF_sexESDJxl7YzM9cAbNqPVU5-wZg,19526
34
+ qlever/commands/example_queries.py,sha256=l2brrZk1YWh1rkOSeCTgUueOZ7Jvu5Qncag-9B88jOI,22881
35
+ qlever/commands/extract_queries.py,sha256=TZBmZLz_NknU1LKbl9nPmxdb82lsPeDhTWjIo81llvA,3942
35
36
  qlever/commands/get_data.py,sha256=nHOHMjv0tSLWJDOR0ba_LK-Bk-mcGnphb8hbqcVYFhE,1411
36
- qlever/commands/index.py,sha256=02o_-EFwxyCOY7Pl49O1tVvMQELWTb5tCwdmSlNgM8w,12777
37
+ qlever/commands/index.py,sha256=W99AeBJNiN9pBVAVaayRAUEm6K58ucFqZvW6KpFBGxU,13327
37
38
  qlever/commands/index_stats.py,sha256=9EBo1Oq5PGjajrvWJNafJ-Wg_d90DaO5AGq9a5plSRM,11720
38
39
  qlever/commands/log.py,sha256=vLqkgtx1udnQqoUBMWB5G9rwr-l7UKrDpyFYSMuoXWw,1987
39
- qlever/commands/query.py,sha256=vu6vTeTqtKhuKbv_wzloHvbJFj_2GTHPIfDpQfrc8FE,3603
40
+ qlever/commands/query.py,sha256=lqQR3wiDLAzxg3Da5Xim6gxkAeEexPJxldoTfB9U4H0,4588
41
+ qlever/commands/settings.py,sha256=lyI_mdRMp3zv3RQ-tU2g2ZivfMD0r0R6ODf0VH9aVBk,3742
40
42
  qlever/commands/setup_config.py,sha256=wEy1LAunpOnqrUCbazMpt1u9HJCKgXJEMxF3zjh0jb0,3344
41
- qlever/commands/start.py,sha256=TdAulZqkTv9W0QBPwQqg-ixYI3iHMpZ1SHHvFRO_jbs,9524
43
+ qlever/commands/start.py,sha256=gtYKB1sgc5SwY0DA3IMnowXMqXccHA2cOYZ71dgey5k,11589
42
44
  qlever/commands/status.py,sha256=TtnBqcdkF3zTDKft07zpVcIX7kFu7d_nOy9b6Ohh9vQ,1650
43
- qlever/commands/stop.py,sha256=AVafaoNb1JYmhulZ9_Bvq5gKcxBekb-S1QQRjBFo_-k,4160
44
- qlever/commands/system_info.py,sha256=Y3DtUJAlnh6uSvIVoToE10G7SStu-L5NbalIXvBB6D0,4614
45
- qlever/commands/ui.py,sha256=Ppo6YXA8JXNDPvC5D5duKGMPyhRvXfc1CaoSwjL-jBg,3644
45
+ qlever/commands/stop.py,sha256=z25gWfLA9qIJ7F3zWZa0p0oVnt61kHcsB1evjgXhKX4,4557
46
+ qlever/commands/system_info.py,sha256=I84EKgMO5J8pvsTDhkVKHzsRLtPajNg9KTQN5kWjqLU,4660
47
+ qlever/commands/ui.py,sha256=T2Sl6w9tXNpZf-Zv3A9SLmarujszTIjGOYyPfyT4sX4,3821
46
48
  qlever/commands/warmup.py,sha256=kJHzS7HJo8pD2CphJuaXDj_CYP02YDo2DVM-pun3A80,1029
47
- qlever-0.5.15.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
48
- qlever-0.5.15.dist-info/METADATA,sha256=A9M3q3eqWpFdUBOgKMNiPE8LnR5u78LCHJqCIZaQAfY,4583
49
- qlever-0.5.15.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
50
- qlever-0.5.15.dist-info/entry_points.txt,sha256=U_gbYYi0wwdsn884eb0XoOXfvhACOsxhlO330dZ9bi0,87
51
- qlever-0.5.15.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
52
- qlever-0.5.15.dist-info/RECORD,,
49
+ qlever-0.5.18.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
50
+ qlever-0.5.18.dist-info/METADATA,sha256=sOgFKONlHKZQkpaYYHV-GnMXRHGnXuhpqYDI7rKJmso,4583
51
+ qlever-0.5.18.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
52
+ qlever-0.5.18.dist-info/entry_points.txt,sha256=U_gbYYi0wwdsn884eb0XoOXfvhACOsxhlO330dZ9bi0,87
53
+ qlever-0.5.18.dist-info/top_level.txt,sha256=kd3zsYqiFd0--Czh5XTVkfEq6XR-XgRFW35X0v0GT-c,7
54
+ qlever-0.5.18.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5