qlever 0.2.5__py3-none-any.whl → 0.5.41__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.
Files changed (68) hide show
  1. qlever/Qleverfiles/Qleverfile.dblp +36 -0
  2. qlever/Qleverfiles/Qleverfile.dblp-plus +33 -0
  3. qlever/Qleverfiles/Qleverfile.dbpedia +30 -0
  4. qlever/Qleverfiles/Qleverfile.default +51 -0
  5. qlever/Qleverfiles/Qleverfile.dnb +40 -0
  6. qlever/Qleverfiles/Qleverfile.fbeasy +29 -0
  7. qlever/Qleverfiles/Qleverfile.freebase +28 -0
  8. qlever/Qleverfiles/Qleverfile.imdb +36 -0
  9. qlever/Qleverfiles/Qleverfile.ohm-planet +41 -0
  10. qlever/Qleverfiles/Qleverfile.olympics +31 -0
  11. qlever/Qleverfiles/Qleverfile.orkg +30 -0
  12. qlever/Qleverfiles/Qleverfile.osm-country +39 -0
  13. qlever/Qleverfiles/Qleverfile.osm-planet +39 -0
  14. qlever/Qleverfiles/Qleverfile.osm-planet-from-pbf +42 -0
  15. qlever/Qleverfiles/Qleverfile.pubchem +131 -0
  16. qlever/Qleverfiles/Qleverfile.scientists +29 -0
  17. qlever/Qleverfiles/Qleverfile.uniprot +74 -0
  18. qlever/Qleverfiles/Qleverfile.vvz +31 -0
  19. qlever/Qleverfiles/Qleverfile.wikidata +42 -0
  20. qlever/Qleverfiles/Qleverfile.wikipathways +40 -0
  21. qlever/Qleverfiles/Qleverfile.yago-4 +33 -0
  22. qlever/__init__.py +44 -1380
  23. qlever/command.py +87 -0
  24. qlever/commands/__init__.py +0 -0
  25. qlever/commands/add_text_index.py +115 -0
  26. qlever/commands/benchmark_queries.py +1019 -0
  27. qlever/commands/cache_stats.py +125 -0
  28. qlever/commands/clear_cache.py +88 -0
  29. qlever/commands/extract_queries.py +120 -0
  30. qlever/commands/get_data.py +48 -0
  31. qlever/commands/index.py +333 -0
  32. qlever/commands/index_stats.py +306 -0
  33. qlever/commands/log.py +66 -0
  34. qlever/commands/materialized_view.py +110 -0
  35. qlever/commands/query.py +142 -0
  36. qlever/commands/rebuild_index.py +176 -0
  37. qlever/commands/reset_updates.py +59 -0
  38. qlever/commands/settings.py +115 -0
  39. qlever/commands/setup_config.py +97 -0
  40. qlever/commands/start.py +336 -0
  41. qlever/commands/status.py +50 -0
  42. qlever/commands/stop.py +90 -0
  43. qlever/commands/system_info.py +130 -0
  44. qlever/commands/ui.py +271 -0
  45. qlever/commands/update.py +90 -0
  46. qlever/commands/update_wikidata.py +1204 -0
  47. qlever/commands/warmup.py +41 -0
  48. qlever/config.py +223 -0
  49. qlever/containerize.py +167 -0
  50. qlever/log.py +55 -0
  51. qlever/qlever_main.py +79 -0
  52. qlever/qleverfile.py +530 -0
  53. qlever/util.py +330 -0
  54. qlever-0.5.41.dist-info/METADATA +127 -0
  55. qlever-0.5.41.dist-info/RECORD +59 -0
  56. {qlever-0.2.5.dist-info → qlever-0.5.41.dist-info}/WHEEL +1 -1
  57. qlever-0.5.41.dist-info/entry_points.txt +2 -0
  58. qlever-0.5.41.dist-info/top_level.txt +1 -0
  59. build/lib/qlever/__init__.py +0 -1383
  60. build/lib/qlever/__main__.py +0 -4
  61. qlever/__main__.py +0 -4
  62. qlever-0.2.5.dist-info/METADATA +0 -277
  63. qlever-0.2.5.dist-info/RECORD +0 -12
  64. qlever-0.2.5.dist-info/entry_points.txt +0 -2
  65. qlever-0.2.5.dist-info/top_level.txt +0 -4
  66. src/qlever/__init__.py +0 -1383
  67. src/qlever/__main__.py +0 -4
  68. {qlever-0.2.5.dist-info → qlever-0.5.41.dist-info/licenses}/LICENSE +0 -0
qlever/command.py ADDED
@@ -0,0 +1,87 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+
5
+ from termcolor import colored
6
+
7
+ from qlever.log import log
8
+
9
+
10
+ class QleverCommand(ABC):
11
+ """
12
+ Abstract base class for all the commands in `qlever/commands`.
13
+ """
14
+
15
+ @abstractmethod
16
+ def __init__(self):
17
+ """
18
+ Initialize the command.
19
+
20
+ IMPORTANT: This should be very LIGHTWEIGHT (typically: a few
21
+ assignments, if any) because we create one object per command and
22
+ initialize each of them.
23
+ """
24
+ pass
25
+
26
+ @abstractmethod
27
+ def description(self) -> str:
28
+ """
29
+ A concise description of the command, which will be shown when the user
30
+ types `qlever --help` or `qlever <command> --help`.
31
+ """
32
+ pass
33
+
34
+ @abstractmethod
35
+ def should_have_qleverfile(self) -> bool:
36
+ """
37
+ Return `True` if the command should have a Qleverfile, `False`
38
+ otherwise. If a command should have a Qleverfile, but none is
39
+ specified, the command can still be executed if all the required
40
+ arguments are specified on the command line, but there will be warning.
41
+ """
42
+ pass
43
+
44
+ @abstractmethod
45
+ def relevant_qleverfile_arguments(self) -> dict[str, list[str]]:
46
+ """
47
+ Retun the arguments relevant for this command. This must be a subset of
48
+ the names of `all_arguments` defined in `QleverConfig`. Only these
49
+ arguments can then be used in the `execute` method.
50
+ """
51
+ pass
52
+
53
+ @abstractmethod
54
+ def additional_arguments(self, subparser):
55
+ """
56
+ Add additional command-specific arguments (which are not in
57
+ `QleverConfig.all_arguments` and cannot be specified in the Qleverfile)
58
+ to the given `subparser`. If there are no additional arguments, just
59
+ implement as `pass`.
60
+ """
61
+ pass
62
+
63
+ @abstractmethod
64
+ def execute(self, args) -> bool:
65
+ """
66
+ Execute the command with the given `args`. Return `True` if the command
67
+ executed normally. Return `False` if it did not execute normally, but
68
+ the problem could be identified and handled. In all other cases, raise
69
+ a `CommandException`.
70
+ """
71
+ pass
72
+
73
+ @staticmethod
74
+ def show(command_description: str, only_show: bool = False):
75
+ """
76
+ Helper function that shows the command line or description of an
77
+ action, together with an explanation.
78
+ """
79
+
80
+ log.info(colored(command_description, "blue"))
81
+ log.info("")
82
+ if only_show:
83
+ log.info(
84
+ 'You passed the argument "--show", therefore the command '
85
+ 'is only shown, but not executed (omit the "--show" to '
86
+ "execute it)"
87
+ )
File without changes
@@ -0,0 +1,115 @@
1
+ from __future__ import annotations
2
+
3
+ import subprocess
4
+
5
+ from qlever.command import QleverCommand
6
+ from qlever.containerize import Containerize
7
+ from qlever.log import log
8
+ from qlever.util import get_existing_index_files, run_command
9
+
10
+
11
+ class AddTextIndexCommand(QleverCommand):
12
+ """
13
+ Class for executing the `index` command.
14
+ """
15
+
16
+ def __init__(self):
17
+ pass
18
+
19
+ def description(self) -> str:
20
+ return "Add text index to an index built with `qlever index`"
21
+
22
+ def should_have_qleverfile(self) -> bool:
23
+ return True
24
+
25
+ def relevant_qleverfile_arguments(self) -> dict[str, list[str]]:
26
+ return {
27
+ "data": ["name"],
28
+ "index": [
29
+ "index_binary",
30
+ "text_index",
31
+ "text_words_file",
32
+ "text_docs_file",
33
+ ],
34
+ "runtime": ["system", "image", "index_container"],
35
+ }
36
+
37
+ def additional_arguments(self, subparser) -> None:
38
+ subparser.add_argument(
39
+ "--overwrite-existing",
40
+ action="store_true",
41
+ help="Overwrite existing text index files",
42
+ )
43
+
44
+ def execute(self, args) -> bool:
45
+ # Check that there is actually something to add.
46
+ if args.text_index == "none":
47
+ log.error("You specified `--text_index none`, nothing to add")
48
+ return False
49
+
50
+ # Construct the command line.
51
+ add_text_index_cmd = f"{args.index_binary} -A -i {args.name}"
52
+ if args.text_index in [
53
+ "from_text_records",
54
+ "from_text_records_and_literals",
55
+ ]:
56
+ add_text_index_cmd += (
57
+ f" -w {args.text_words_file}" f" -d {args.text_docs_file}"
58
+ )
59
+ if args.text_index in [
60
+ "from_literals",
61
+ "from_text_records_and_literals",
62
+ ]:
63
+ add_text_index_cmd += " --text-words-from-literals"
64
+ add_text_index_cmd += f" | tee {args.name}.text-index-log.txt"
65
+
66
+ # Run the command in a container (if so desired).
67
+ if args.system in Containerize.supported_systems():
68
+ add_text_index_cmd = Containerize().containerize_command(
69
+ add_text_index_cmd,
70
+ args.system,
71
+ "run --rm",
72
+ args.image,
73
+ args.index_container,
74
+ volumes=[("$(pwd)", "/index")],
75
+ working_directory="/index",
76
+ )
77
+
78
+ # Show the command line.
79
+ self.show(add_text_index_cmd, only_show=args.show)
80
+ if args.show:
81
+ return True
82
+
83
+ # When running natively, check if the binary exists and works.
84
+ if args.system == "native":
85
+ try:
86
+ run_command(f"{args.index_binary} --help")
87
+ except Exception as e:
88
+ log.error(
89
+ f'Running "{args.index_binary}" failed ({e}), '
90
+ f"set `--index-binary` to a different binary or "
91
+ f"use `--container_system`"
92
+ )
93
+ return False
94
+
95
+ # Check if text index files already exist.
96
+ existing_text_index_files = get_existing_index_files(
97
+ f"{args.name}.text.*"
98
+ )
99
+ if len(existing_text_index_files) > 0 and not args.overwrite_existing:
100
+ log.error(
101
+ "Text index files found, if you want to overwrite them, "
102
+ "use --overwrite-existing"
103
+ )
104
+ log.info("")
105
+ log.info(f"Index files found: {existing_text_index_files}")
106
+ return False
107
+
108
+ # Run the index command.
109
+ try:
110
+ subprocess.run(add_text_index_cmd, shell=True, check=True)
111
+ except Exception as e:
112
+ log.error(f'Running "{add_text_index_cmd}" failed ({e})')
113
+ return False
114
+
115
+ return True