Skip to content

Extend parameter file loader to parse TOML in addition to YAML#874

Open
huyhoang171106 wants to merge 2 commits intonteract:mainfrom
huyhoang171106:feat/extend-parameter-file-loader-to-parse-to
Open

Extend parameter file loader to parse TOML in addition to YAML#874
huyhoang171106 wants to merge 2 commits intonteract:mainfrom
huyhoang171106:feat/extend-parameter-file-loader-to-parse-to

Conversation

@huyhoang171106
Copy link
Copy Markdown

Summary

The current read_yaml_file path is YAML-specific and is used by CLI --parameters_file. To support issue #719 cleanly, this loader should accept TOML files (primarily .toml) while preserving existing YAML behavior and backward compatibility for current callers.

Files changed

  • papermill/iorw.py (modified)
  • papermill/cli.py (modified)

Testing

  • Not run in this environment.

What does this PR do?

Fixes #<issue_number>

Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
Signed-off-by: Nguyen Huy Hoang <181364121+huyhoang171106@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 26, 2026 15:12
Copy link
Copy Markdown

Copilot AI left a comment

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 aims to extend Papermill’s --parameters_file loader to accept TOML files (issue #719) while preserving existing YAML behavior.

Changes:

  • Added a conditional import for tomllib (with tomli fallback) in papermill/iorw.py.
  • Updated CLI help text for --parameters_file to mention TOML support.

Reviewed changes

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

File Description
papermill/iorw.py Introduces tomllib/tomli import plumbing, but no parsing logic is wired in yet.
papermill/cli.py Updates --parameters_file help text to say “YAML or TOML”, without corresponding behavior changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread papermill/iorw.py
Comment on lines +8 to +15
try:
import tomllib
except ModuleNotFoundError:
try:
import tomli as tomllib
except ModuleNotFoundError:
tomllib = None

Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The newly added tomllib/tomli import is currently unused anywhere in this module, which will fail Ruff/Pyflakes (unused import/unused variable). Either wire this into the parameters-file loader (e.g., TOML parsing) or remove the import until it’s used. If TOML support is intended for Python 3.10, also ensure the tomli fallback is an actual dependency (or raise a clear error when tomllib is None).

Suggested change
try:
import tomllib
except ModuleNotFoundError:
try:
import tomli as tomllib
except ModuleNotFoundError:
tomllib = None

Copilot uses AI. Check for mistakes.
Comment thread papermill/cli.py
@click.option('--parameters', '-p', nargs=2, multiple=True, help='Parameters to pass to the parameters cell.')
@click.option('--parameters_raw', '-r', nargs=2, multiple=True, help='Parameters to be read as raw string.')
@click.option('--parameters_file', '-f', multiple=True, help='Path to YAML file containing parameters.')
@click.option('--parameters_file', '-f', multiple=True, help='Path to YAML or TOML file containing parameters.')
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This help text now claims --parameters_file accepts TOML, but the implementation still routes to read_yaml_file(...), which only loads YAML/JSON and enforces extensions ['.json', '.yaml', '.yml']. Either implement TOML support end-to-end (loader + CLI wiring) or keep the help text YAML-only to avoid misleading users.

Suggested change
@click.option('--parameters_file', '-f', multiple=True, help='Path to YAML or TOML file containing parameters.')
@click.option('--parameters_file', '-f', multiple=True, help='Path to YAML file containing parameters.')

Copilot uses AI. Check for mistakes.
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