ParSet Refactor#2097
Conversation
|
Getting some test failures: The unit test failure is the issue with the number of LDT/DeVeny DV1 files, but the rest are new. I'll work on these and run the tests again. |
|
I ran into a stumbling block with this implementation. TLDR, path parameters are now a callable function ( The headache boils down to the The fix I have implemented means that the >>> from pypeit.par import pypeitpar
>>> p = pypeitpar.PypeItPar()
>>> p['rdx']['redux_path']
PosixPath('/Users/westfall/Work/packages/PypeIt-development-suite')This is because I've added a recursive function that fills in the callable values as part of the >>> rdxp = pypeitpar.ReduxPar()
>>> rdxp['redux_path']
<bound method PathBase.cwd of <class 'pathlib._local.Path'>>
>>> rdxp.fill_callable()
>>> rdxp['redux_path']
PosixPath('/Users/westfall/Work/packages/PypeIt-development-suite')This is admittedly a bit janky, but I think the benefits of the refactored As a by-product of this, I also went through the uses of |
|
Tests pass The unit test failure is because of the number of ldt_deveny/DV1 files. |
profxj
left a comment
There was a problem hiding this comment.
Looked carefully at parset.py and bit at pypeitpar.py
Would be good to convince ourselves all the default values
stayed the same before/after. Am betting Kyle has already
checked that..
Am approving
badpandabear
left a comment
There was a problem hiding this comment.
Looks good. My main concern is about what appears to be unnecessary changes to the way PypeItPar is imported, but maybe I'm missing something and there's a good reason for it. I also had a comment about collate_1d's command line usage which is really my fault.
| @@ -1,2 +0,0 @@ | |||
|
|
|||
| from pypeit.par.pypeitpar import PypeItPar | |||
There was a problem hiding this comment.
This change caused a lot of the changes in this PR. Why was it done? Was it considered a circular dependency? Because I believe from .pypeitpar import PypeItPar would work without having to change a lot of code.
There was a problem hiding this comment.
Yeah, I appreciate that this is a bit obnoxious. I've soured on this kind of convenience import in __init__.py files. It does create a "cycle" that pydeps identified, and I was also trying to unify how we import pypeitpar across the code base. If you have really strong objection to this, I can revert it.
|
This has two approvals, but don't merge it yet. I'm re-running the dev-suite, and I think we should try to get current PRs that make changes to parameters in before this one. |
|
Tests still pass. |
This is a major refactor of the
ParSetbase class.Many files are touched but the primary changes are in
pypeit/par/parset.pyandpypeit/par/pypeitpar.py. Branches that include changes to these files will likely have significant conflicts. I apologize for the headaches, and I'm happy to help with merges. Beyond those two files, the refactor is virtually invisible to the rest of the code, only requiring some changes to imports and some auto-generated doc scripts.The main accomplishment of this PR is that it dramatically cleans up and streamlines the construction of
ParSetsubclasses. Instead of defining the parameters based on the combination of the call sequence of the__init__function and the subsequent body of the function, everything is defined as part of a dictionary class attribute calledparameters. This allows the refactoredParSetclass to handle everything except the definition of those parameters and any validation methods. I.e., none of the currentParSetsubclasses require a bespoke__init__function; they all can make do with the base class method.I used AI to help with this, and a script that compared the old and new versions of the
ParSetsubclasses (the parameters, types, options, and descriptions). After the initial refactor, in which I explicitly made both the old and new subclasses identical, I edited all of the descriptions. Most of this was to ensure a fixed line length, but I also edited the content of some.All the unit tests pass, and I'll set the dev-suite going now.