Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 25, 2025

Summary

Fixed CI error AttributeError: 'vmecpp.cpp._vmecpp.WOutFileContents' object has no attribute 'lrfp' by properly handling the Python-only lrfp field during Python<->C++ conversions.

Changes Made

  • Reverted all C++ changes: Removed lrfp from VmecINDATA, WOutFileContents, and pybind11 bindings
  • Removed lrfp from VmecInput: No C++ backend to support it as an input parameter
  • Kept lrfp in VmecWOut: Handles reading from and writing to Fortran wout files
  • Removed test_lrfp_flag_in_wout(): Existing tests cover the functionality
  • Kept lrfp__logical__ removal from _MISSING_FORTRAN_VARIABLES: Python side now handles it
  • Added lrfp to _CPP_WOUT_SPECIAL_HANDLING: Skips the field during Python<->C++ conversion
  • Set lrfp default in _from_cpp_wout: Initializes to False when converting from C++ to Python

What Remains

Python-side only (src/vmecpp/__init__.py):

  • VmecWOut.lrfp field with Pydantic annotations for NetCDF serialization
  • VmecWOut.lrfp__logical__() property for Fortran compatibility
  • Backwards compatibility: setdefault("lrfp__logical__", 0) for old wout files
  • Removed from _MISSING_FORTRAN_VARIABLES list in tests
  • Added to _CPP_WOUT_SPECIAL_HANDLING to skip during Python<->C++ conversions
  • Default value set to False in _from_cpp_wout() method

This allows loading Fortran VMEC wout files with lrfp flag without requiring special handling, while keeping implementation minimal on Python side only and properly handling C++ interop.

Original prompt

add the lrfp_logical_ with default to false to the wout, to allow them to avoid having to treat VMEC++ files in any special way. Use the same pattern for adding a boolean flag as for the other flags (accessible as lrfp property from python, but written to netcdf with the logical suffix) and make sure wout files WITHOUT the flags, stay backwards compatible.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@jurasic-pf
Copy link
Collaborator

to address incompatibilities discussed in PlasmaControl/DESC#2014

Copilot AI changed the title [WIP] Add lrfp_logical flag with default to false in wout files Add lrfp_logical_ flag to wout for Fortran VMEC compatibility Dec 25, 2025
Copilot AI requested a review from jurasic-pf December 25, 2025 10:02
@jurasic-pf
Copy link
Collaborator

@copilot Don't add it to the C++ source, it should only be handled on the python side and ignored.

Copy link
Contributor Author

Copilot AI commented Dec 25, 2025

@copilot Don't add it to the C++ source, it should only be handled on the python side and ignored.

Removed all C++ implementation in commit f82f946. The lrfp flag is now only handled on the Python side in VmecWOut for reading/writing Fortran wout files, with backwards compatibility for old files. Also removed the test as requested.

Copilot AI changed the title Add lrfp_logical_ flag to wout for Fortran VMEC compatibility Add lrfp_logical_ flag to wout for Fortran VMEC compatibility (Python-only) Dec 25, 2025
@jurasic-pf jurasic-pf marked this pull request as ready for review December 25, 2025 12:04
@jurasic-pf
Copy link
Collaborator

@copilot fix the ci errors AttributeError: 'vmecpp.cpp._vmecpp.WOutFileContents' object has no attribute 'lrfp'
by skipping that flag when going python <=> C++

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot fix the ci errors AttributeError: 'vmecpp.cpp._vmecpp.WOutFileContents' object has no attribute 'lrfp'
by skipping that flag when going python <=> C++

Fixed in commit 8548198. Added lrfp to _CPP_WOUT_SPECIAL_HANDLING to skip it during Python<->C++ conversions, and set default value False in _from_cpp_wout() when converting from C++.

@jurasic-pf jurasic-pf force-pushed the copilot/add-lrfp-logical-flag-to-wout branch from 8548198 to a69fee2 Compare January 12, 2026 09:02
Copy link
Collaborator


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jurasic-pf jurasic-pf force-pushed the copilot/add-lrfp-logical-flag-to-wout branch from a69fee2 to 12f190e Compare January 12, 2026 09:09
@jurasic-pf
Copy link
Collaborator

I regenerated the needed reference wout files to include the flag.

@jurasic-pf jurasic-pf force-pushed the copilot/add-lrfp-logical-flag-to-wout branch 3 times, most recently from 4f80cf9 to ea56152 Compare January 12, 2026 10:40
@graphite-app
Copy link

graphite-app bot commented Jan 12, 2026

Merge activity

…-only) (#399)

## Summary

Fixed CI error `AttributeError: 'vmecpp.cpp._vmecpp.WOutFileContents' object has no attribute 'lrfp'` by properly handling the Python-only `lrfp` field during Python<->C++ conversions.

## Changes Made

- [x] **Reverted all C++ changes**: Removed lrfp from VmecINDATA, WOutFileContents, and pybind11 bindings
- [x] **Removed lrfp from VmecInput**: No C++ backend to support it as an input parameter
- [x] **Kept lrfp in VmecWOut**: Handles reading from and writing to Fortran wout files
- [x] **Removed test_lrfp_flag_in_wout()**: Existing tests cover the functionality
- [x] **Kept lrfp__logical__ removal from _MISSING_FORTRAN_VARIABLES**: Python side now handles it
- [x] **Added lrfp to _CPP_WOUT_SPECIAL_HANDLING**: Skips the field during Python<->C++ conversion
- [x] **Set lrfp default in _from_cpp_wout**: Initializes to False when converting from C++ to Python

## What Remains

**Python-side only** (`src/vmecpp/__init__.py`):
- `VmecWOut.lrfp` field with Pydantic annotations for NetCDF serialization
- `VmecWOut.lrfp__logical__()` property for Fortran compatibility
- Backwards compatibility: `setdefault("lrfp__logical__", 0)` for old wout files
- Removed from `_MISSING_FORTRAN_VARIABLES` list in tests
- Added to `_CPP_WOUT_SPECIAL_HANDLING` to skip during Python<->C++ conversions
- Default value set to `False` in `_from_cpp_wout()` method

This allows loading Fortran VMEC wout files with lrfp flag without requiring special handling, while keeping implementation minimal on Python side only and properly handling C++ interop.

<!-- START COPILOT CODING AGENT SUFFIX -->

<!-- START COPILOT ORIGINAL PROMPT -->

<details>

<summary>Original prompt</summary>

> add the lrfp_logical_ with default to false to the wout, to allow them to avoid having to treat VMEC++ files in any special way. Use the same pattern for adding a boolean flag as for the other flags (accessible as lrfp property from python, but written to netcdf with the logical suffix) and make sure wout files WITHOUT the flags, stay backwards compatible.

</details>

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
@graphite-app graphite-app bot force-pushed the copilot/add-lrfp-logical-flag-to-wout branch from ea56152 to d5582f2 Compare January 12, 2026 10:53
@jurasic-pf jurasic-pf merged commit fe8cd5d into main Jan 12, 2026
23 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.

2 participants