Skip to content

MaD: update generator scripts to support writing JSON data extensions - #22798

Open
nickrolfe wants to merge 2 commits into
mainfrom
nickrolfe/mad-generator-json
Open

nickrolfe wants to merge 2 commits into
mainfrom
nickrolfe/mad-generator-json

Conversation

@nickrolfe

@nickrolfe nickrolfe commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

This is split into two commits:

  1. Updates the scripts so that they store and build models using an in-memory representation that is independent of the YAML format currently used. This means rows are represented as Python tuples, where previously they were created as YAML-formatted strings during the merging process. Scalar values inside those tuples are represented as Python strings and booleans. Only the DataExtensionFile.write_yaml function now has to deal with YAML formatting concerns.
  2. Adds support for writing JSON and choosing which format to use.

For now, YAML is still the default. We can change this when CLI support for JSON extensions is widely available and the existing models in this repo have been converted to JSON. (I will be making a separate PR with a conversion script).

I tested these changes by running both misc/scripts/models-as-data/generate_mad.py and java/ql/src/utils/modelconverter/ConvertExtensions.py and manually inspecting the output.

@nickrolfe
nickrolfe force-pushed the nickrolfe/mad-generator-json branch 2 times, most recently from 95c94ef to ccf9c6e Compare October 12, 2026 10:01
@nickrolfe
nickrolfe requested a balanced review from Copilot October 12, 2026 10:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Bulk generation currently raises an attribute error, and single-file generation no longer produces a single file.

1 open finding
What changed in this PR

Refactors MaD generation around a format-independent representation and adds JSON output support.

Changes:

  • Adds shared YAML/JSON serialization.
  • Refactors generators and converters to accumulate typed rows.
  • Cleans up generated files in either format.
File Description
helpers.py Adds shared extension merging and writing.
generate_mad.py Adds format selection and uses structured rows.
data_extension_file.py Implements YAML and JSON serialization.
convert_extensions.py Uses the shared extension representation.
bulk_generate_mad.py Cleans up YAML and JSON outputs.

🧠 Review effort: Balanced


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

Comment thread misc/scripts/models-as-data/generate_mad.py Outdated
In preparation for adding support for JSON data extensions, this commit
updates the scripts so that they store and build models using an
in-memory representation that is independent of the YAML format
currently used. This means rows are represented as Python tuples, where
previously they were created as YAML-formatted strings in the merging
process. Scalar values inside those tuples are represented as Python
strings and booleans.

Only the DataExtensionFile.write_yaml function now has to deal with YAML
formatting concerns.
@nickrolfe
nickrolfe force-pushed the nickrolfe/mad-generator-json branch from ccf9c6e to 893bc80 Compare October 12, 2026 10:28
@nickrolfe
nickrolfe requested a balanced review from Copilot October 12, 2026 10:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Direct Generator usage in bulk generation lacks extension_format and fails before writing output.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread misc/scripts/models-as-data/generate_mad.py
The `generate_mad.py` script accepts a flag that lets you choose between
YAML or JSON, but YAML is still the default. We can change the default
later, when CLI support for JSON is widely available.

`convert_extensions.py` also still hard-codes `.yml` as the output
extension/format.
@nickrolfe
nickrolfe force-pushed the nickrolfe/mad-generator-json branch from 893bc80 to 3872102 Compare October 12, 2026 10:52
@nickrolfe
nickrolfe requested a balanced review from Copilot October 12, 2026 10:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Generated JSON begins with an unsupported comment and is therefore invalid JSON.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread misc/scripts/models-as-data/data_extension_file.py
@nickrolfe
nickrolfe marked this pull request as ready for review October 12, 2026 10:59
@nickrolfe
nickrolfe requested a review from a team as a code owner October 12, 2026 10:59

This branch has not been deployed

No deployments
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.

2 participants