Skip to content

4174 only read indats using the indat class - #4523

Draft
clmould wants to merge 24 commits into
mainfrom
4174-only-read-indats-using-the-indat-class
Draft

clmould wants to merge 24 commits into
mainfrom
4174-only-read-indats-using-the-indat-class

Conversation

@clmould

@clmould clmould commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

Description

  • Moves validate_input to the InDat class and rename to check_obsolete_variables
  • parse_input_file no longer re-reads the file line by line and instead uses the data read in by InDat
  • Fix PLR1702 errors in these files

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@clmould clmould linked an issue Aug 13, 2026 that may be closed by this pull request
1 of 2 tasks
@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch from bc34539 to eda15dc Compare August 13, 2026 16:26
@clmould clmould mentioned this pull request Aug 14, 2026
1 of 2 tasks
@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch 3 times, most recently from 72a627d to e8a494b Compare August 27, 2026 13:14
@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch 6 times, most recently from 9816a42 to d4d920c Compare September 2, 2026 12:47
@codecov-commenter

codecov-commenter commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.50602% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.34%. Comparing base (0b69cfc) to head (3a44a01).

Files with missing lines Patch % Lines
process/core/io/in_dat/base.py 55.42% 37 Missing ⚠️
process/core/input.py 97.29% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4523      +/-   ##
==========================================
+ Coverage   50.26%   50.34%   +0.08%     
==========================================
  Files         181      181              
  Lines       30629    30604      -25     
==========================================
+ Hits        15395    15407      +12     
+ Misses      15234    15197      -37     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch 2 times, most recently from 756ea41 to 698f4a5 Compare September 11, 2026 18:08
@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch from fec93fb to bcd063a Compare September 21, 2026 12:27
@clmould
clmould marked this pull request as ready for review September 22, 2026 14:06
@clmould
clmould requested a review from a team as a code owner September 22, 2026 14:06

@je-cook je-cook left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

First round, I think there will be a few subsequent reviews, its a lot to unpick!

Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/input.py

@je-cook je-cook left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

a few cleanup ones

Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py
Comment thread process/core/io/in_dat/base.py Outdated
Comment thread process/core/io/in_dat/base.py Outdated
Comment on lines 428 to 434

@je-cook je-cook Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

all of this goes to this one line

Suggested change
parameters[module][item] = {"value": data["i_process_run_mode"].get_value, "comment": f"{PROCESSRunMode(iop_val).description}"}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've kept iop_val in for now to have PROCESSRunMode(iop_val).description, but I can remove that and instead directly use PROCESSRunMode(data["i_process_run_mode"].get_value).description if you'd prefer?

Comment thread process/core/io/in_dat/base.py Outdated

@timothy-nunn timothy-nunn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A couple more in addition to James.

Comment thread process/core/init.py Outdated
Comment thread process/core/input.py Outdated
Comment on lines +1216 to +1244
if variable_name == "bounds":
boundl = {}
boundu = {}
for index, bounds_dict in info.value.items():
try:
idx = int(index)
except ValueError as e:
raise ProcessValidationError(
"The bounds need to be of the form boundl/u(index) = value"
) from e
if "l" in bounds_dict:
boundl[idx] = bounds_dict["l"]
if "u" in bounds_dict:
boundu[idx] = bounds_dict["u"]
# TODO could change them into arrays here?

info_boundl = info
info_boundl.value = boundl
info_boundl.name = "boundl"
variables = set_on_datastructure(
variable_name="boundl",
info=info_boundl,
data_structure_obj=data_structure_obj,
variables=variables,
)

# matches (variable name, array index, value)
# NOTE: array index is Fortran-based hence starts at 1.
line_match = re.match(
r"([a-zA-Z0-9_]+)(?:\(([0-9]+)\))?[ ]*=[ ]*([ +\-a-zA-Z0-9.,]+).*",
stripped_line,
)
info_boundu = info
info_boundu.value = boundu
info_boundu.name = "boundu"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this be an additional action, rather than an if statement in the parser?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Have discussed and decided, for now, to add a new function _handle_bounds - the additional actions are not performed until after the variable validating and cleaning, which means it would be tricky to move this to an additional action and still be able to clean and validate the variable. Can always change once we have decided on how to handle bounds in future

@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch from c9765aa to 43c5333 Compare October 23, 2026 16:43
@clmould
clmould marked this pull request as draft October 23, 2026 18:12
@clmould
clmould force-pushed the 4174-only-read-indats-using-the-indat-class branch from cbd35eb to 3a44a01 Compare October 23, 2026 18:12
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.

Only read IN.DATs using the InDat class

4 participants