Skip to content

generator: add command line argument to override enabled scripts#1609

Merged
tahini merged 1 commit into
chairemobilite:mainfrom
tahini:addGeneratorCli
May 20, 2026
Merged

generator: add command line argument to override enabled scripts#1609
tahini merged 1 commit into
chairemobilite:mainfrom
tahini:addGeneratorCli

Conversation

@tahini
Copy link
Copy Markdown
Contributor

@tahini tahini commented May 20, 2026

fixes #1601

When developing a questionnaire, we may want to build only part of it, for example the choices, labels or widgets for quick development. Long questionnaire can take a while to generate everything and it is not desirable to do it at all times.

This adds the command line argument --only that takes a comma-separated list of scripts to generate. For example, to generate only the widget configs, conditional and labels, adding --only widgets_configs,widgets,conditionals,labels would generate only those data, ignoring the rest.

Summary by CodeRabbit

  • New Features

    • Added a command-line option to generate only selected scripts instead of running the full generation set.
  • Documentation

    • Updated usage guidance with an example showing how to pass the selection via the new command-line option.

Review Change Stack

@tahini tahini requested a review from samuel-duhaime May 20, 2026 13:59
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a7788df8-14c0-456b-a603-062010d7d283

📥 Commits

Reviewing files that changed from the base of the PR and between b00f365 and d2f338e.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/evolution-generator/README.md
  • packages/evolution-generator/src/scripts/generate_survey.py
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: pr-build-check
  • GitHub Check: build-and-test (24.x)
  • GitHub Check: code-lint
  • GitHub Check: generate-and-build-generator (24.x)
  • GitHub Check: test-sequential (24.x)
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[style] ~47-~47: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ...only` command-line argument to generate only specified scripts (e.g., widgets, condi...

(ADVERB_REPETITION_PREMIUM)

🪛 Ruff (0.15.13)
packages/evolution-generator/src/scripts/generate_survey.py

[warning] 70-70: Missing return type annotation for private function _parse_only_scripts

(ANN202)


[warning] 81-84: Avoid specifying long messages outside the exception class

(TRY003)


[warning] 90-93: Avoid specifying long messages outside the exception class

(TRY003)


[warning] 98-98: Missing return type annotation for private function _override_enabled_scripts

(ANN202)


[warning] 106-106: Too many branches (15 > 12)

(PLR0912)


[warning] 106-106: Too many statements (65 > 50)

(PLR0915)

🔇 Additional comments (10)
packages/evolution-generator/src/scripts/generate_survey.py (8)

5-8: LGTM!


28-46: LGTM!


48-64: LGTM!


67-95: LGTM!


98-101: LGTM!


106-120: LGTM!


287-294: LGTM!


297-300: LGTM!

packages/evolution-generator/README.md (1)

183-184: LGTM!

CHANGELOG.md (1)

47-47: LGTM!


Walkthrough

This PR adds a --only command-line argument to the generator that lets users selectively generate scripts by specifying aliases. The implementation defines supported script aliases and keys, parses the comma-separated --only argument with validation, and overrides config-file settings when provided. The feature integrates into the main generate_survey function and CLI entry point, with changelog documentation of the new capability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • samuel-duhaime
  • kaligrafy
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a command-line argument to override enabled scripts in the generator.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #1601: a --only CLI argument accepting comma-separated script names to generate only selected outputs, reducing development build times.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the --only CLI feature: documentation updates, new parsing/override functions, and CLI argument integration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tahini
Copy link
Copy Markdown
Contributor Author

tahini commented May 20, 2026

I tested and it works. There is no tests for this file, and it would need quite a lot of mocking all the scripts. @samuel-duhaime let me know if you insist to get tests, I can see what can be done.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 47: Update the CHANGELOG.md entry to improve clarity: change "Command
line arguments to the generator to generate only a list of scripts instead of
everything" to a bold heading following other generator feature entries (e.g.,
**Generator: ...**), use "command-line" as a compound adjective, explicitly
reference the flag `--only`, and hyphenate compound phrases where appropriate
(e.g., "list-only scripts" or "generate a list-only of scripts") so the entry
reads clearly and consistently with other generator entries.

In `@packages/evolution-generator/src/scripts/generate_survey.py`:
- Around line 69-82: The parsing loop for only_scripts can produce an empty
normalized_scripts set when the user passes only whitespace/commas, silently
disabling all scripts; after the loop that populates normalized_scripts (using
only_scripts and SUPPORTED_SCRIPT_ALIASES) add a check that if
normalized_scripts is empty you raise a ValueError with a clear message like "No
valid scripts specified in --only; supported values are: <list>" (use ",
".join(sorted(SUPPORTED_SCRIPT_ALIASES.keys())) to produce the list) so callers
get an explicit error instead of silently continuing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d09e2208-4f42-4676-860b-1b690ad7d04b

📥 Commits

Reviewing files that changed from the base of the PR and between 59d66d7 and b00f365.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • packages/evolution-generator/src/scripts/generate_survey.py
📜 Review details
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[grammar] ~47-~47: Use a hyphen to join words.
Context: ...bilite/evolution/issues/997)). - Command line arguments to the generator to gener...

(QB_NEW_EN_HYPHEN)

🪛 Ruff (0.15.13)
packages/evolution-generator/src/scripts/generate_survey.py

[warning] 65-65: Missing return type annotation for private function _parse_only_scripts

(ANN202)


[warning] 76-79: Avoid specifying long messages outside the exception class

(TRY003)


[warning] 85-85: Missing return type annotation for private function _override_enabled_scripts

(ANN202)


[warning] 93-93: Too many branches (15 > 12)

(PLR0912)


[warning] 93-93: Too many statements (65 > 50)

(PLR0915)

🔇 Additional comments (6)
packages/evolution-generator/src/scripts/generate_survey.py (6)

28-44: LGTM!


48-62: LGTM!


85-88: LGTM!


93-93: LGTM!

Also applies to: 104-107


274-281: LGTM!


284-284: LGTM!

Also applies to: 287-287

Comment thread CHANGELOG.md Outdated
Comment thread packages/evolution-generator/src/scripts/generate_survey.py
Copy link
Copy Markdown
Collaborator

@samuel-duhaime samuel-duhaime left a comment

Choose a reason for hiding this comment

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

Je crois qu'il serait important de mettre à jour le README de evolution-generator pour montrer brièvement un exemple de cette commande.

Comment thread packages/evolution-generator/src/scripts/generate_survey.py
Comment thread packages/evolution-generator/src/scripts/generate_survey.py Outdated
fixes chairemobilite#1601

When developing a questionnaire, we may want to build only part of it,
for example the choices, labels or widgets for quick development. Long
questionnaire can take a while to generate everything and it is not
desirable to do it at all times.

This adds the command line argument `--only` that takes a
comma-separated list of scripts to generate. For example, to generate
only the widget configs, conditional and labels, adding `--only
widgets_configs,widgets,conditionals,labels` would generate only those
data, ignoring the rest.
@tahini tahini force-pushed the addGeneratorCli branch from b00f365 to d2f338e Compare May 20, 2026 19:13
@tahini tahini requested a review from samuel-duhaime May 20, 2026 19:13
Copy link
Copy Markdown
Collaborator

@samuel-duhaime samuel-duhaime left a comment

Choose a reason for hiding this comment

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

C'est bon!

@tahini tahini merged commit 0901b0c into chairemobilite:main May 20, 2026
6 checks passed
@tahini tahini deleted the addGeneratorCli branch May 20, 2026 19:34
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.

generator: add a command line argument to build only part of the generator

2 participants