Skip to content

Use Python instead of sed to edit the Qleverfile in setup-config - #323

Merged
hannahbast merged 5 commits into
qlever-dev:mainfrom
tanmay-9:setup-config-without-sed
Aug 25, 2026
Merged

Use Python instead of sed to edit the Qleverfile in setup-config#323
hannahbast merged 5 commits into
qlever-dev:mainfrom
tanmay-9:setup-config-without-sed

Conversation

@tanmay-9

Copy link
Copy Markdown
Collaborator

qlever setup-config no longer pipes the template through sed to patch in the ACCESS_TOKEN and the --port, --timeout, and --system overrides, but edits it in Python with the new util.update_ini_values. That does not depend on the platform's sed, and unlike a sed substitution it can also add an option or a section that the template does not have.

--show now prints the options that will differ from the template, with the ACCESS_TOKEN masked, instead of a shell pipeline. With QLEVER_IS_RUNNING_IN_CONTAINER set, --port and --timeout are now still applied and only SYSTEM is forced to native; before, all overrides were skipped in that case. And an override that was not given on the command line is no longer written at all, so a generated Qleverfile keeps the TIMEOUT and SYSTEM of its template.

@hannahbast
hannahbast marked this pull request as ready for review August 25, 2026 16:17
Copilot AI lite review requested due to automatic review settings August 25, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the sed-based Qleverfile patching in qlever setup-config with a Python-native INI updater (util.update_ini_values), improving cross-platform behavior and enabling adding missing sections/options.

Changes:

  • Add edit_option_line / update_ini_values utilities to update INI-style files in-memory (including adding missing options/sections).
  • Refactor setup-config to build an updates structure and apply it via Python (and change --show to print a summary rather than a shell pipeline).
  • Add focused unit tests for the new INI editing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test/qlever/test_util.py Adds unit tests covering option editing and INI update behavior (replace/append/add/ignore commented lines).
src/qlever/util.py Introduces Python helpers for editing INI content (replacing prior sed command generation).
src/qlever/commands/setup_config.py Switches setup-config from shell pipeline to Python edits; adjusts override handling and --show output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +91 to +96
for section, arg_name in self.override_args:
if arg_value := getattr(args, arg_name, None):
updates.setdefault(section, {})[arg_name.upper()] = (
str(arg_value),
False,
)
Comment on lines +111 to +117
for section, option_dict in updates.items():
show_lines.append(f"\n[{section}]")
for option, (value, is_suffix) in option_dict.items():
shown_value = (
"*" * len(value) if option == "ACCESS_TOKEN" else value
)
show_lines.append(f"{option} = {shown_value}")
Comment thread src/qlever/util.py
Comment on lines +647 to +650
for section in updates:
if section not in sections_seen:
result_lines.append(f"\n[{section}]")
result_lines.extend(missing_option_lines(section))
@hannahbast hannahbast changed the title Use a python-native solution to update Qleverfile values Use Python instead of sed to generate the Qleverfile in setup-config Aug 25, 2026
@hannahbast hannahbast changed the title Use Python instead of sed to generate the Qleverfile in setup-config Use Python instead of sed to edit the Qleverfile in setup-config Aug 25, 2026
@hannahbast
hannahbast merged commit e3d86f0 into qlever-dev:main Aug 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants