Nexus: replace obj and DevBase classes#6037
Conversation
|
Excellent. I assume we'll be merging on Tuesday or later once our self-hosted CI is back and people have had time to provide feedback. Q. Does this need sequencing around any of the existing PRs? |
brockdyer03
left a comment
There was a problem hiding this comment.
Got through all of the changes in bin, examples, and tests. Lots of leftover comment lines, some prints, some unused functions spotted.
So far I haven't noticed any really critical flaws in the changes, though I haven't seen much of the library code yet.
| @@ -713,7 +713,8 @@ if __name__=='__main__': | |||
| fit_type = args.fit_type | |||
| if fit_type in fit_types: | |||
| fit_functions.clear() | |||
| fit_functions.transfer_from(all_fit_functions[fit_type]) | |||
| #fit_functions.transfer_from(all_fit_functions[fit_type]) | |||
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Slightly excessive whitespace.
| @@ -60,7 +59,8 @@ def test_xsffile(tmp_path): | |||
|
|
|||
| # populate reference object | |||
| ref = XsfFile() | |||
| ref.set( | |||
| #ref.set( | |||
| @@ -178,7 +178,8 @@ def test_poscar_file(tmp_path): | |||
|
|
|||
| # populate reference object | |||
| ref = PoscarFile() | |||
| ref.set( | |||
| #ref.set( | |||
| @@ -247,6 +247,8 @@ def test_analyze(): | |||
| ), | |||
| ) | |||
|
|
|||
| assert(object_eq(ga.to_obj(),ga_ref)) | |||
| print_diff(to_obj(ga),ga_ref) | |||
There was a problem hiding this comment.
Leftover from testing?
| @@ -151,7 +151,8 @@ def check_generated_files( | |||
| #end if | |||
| if failed: | |||
| # report on failures | |||
| from nexus.generic import obj | |||
| #from nexus.generic import obj | |||
| @@ -40,7 +40,9 @@ def format_value(v): | |||
|
|
|||
|
|
|||
| def make_serial_reference(gi): | |||
There was a problem hiding this comment.
This function is unused
| @@ -141,7 +143,8 @@ def get_serial_references(): | |||
| def check_vs_serial_reference(gi,name): | |||
| from ..developer import obj | |||
| sr = obj(get_serial_references()[name]) | |||
| sg = gi.serial() | |||
| #sg = gi.serial() | |||
| @@ -17,7 +17,8 @@ | |||
|
|
|||
|
|
|||
| def test_read(): | |||
| from ..developer import obj | |||
| #from ..developer import obj | |||
| @@ -241,7 +242,8 @@ def test_read(): | |||
| x = readxml(TEST_FILES['vmc.in.xml']) | |||
| assert(isinstance(x,XMLelement)) | |||
| x.remove_hidden() | |||
| o = x.to_obj() | |||
| #o = x.to_obj() | |||
I think this PR should wait until #6030 is merged, but that is already set to happen on Tuesday once the self-hosted CI comes back online. @jtkrogel will need to resolve any merge conflicts too, though I doubt there will be that many truly challenging merge conflicts. |
|
Thanks for the review. Out at the beach. Will address Friday. |
This PR replaces the old obj and DevBase with new streamlined versions. This was done because:
list, making it very hard to reason about the code.A main change it to make the widely used
objclassdict-conformant. It now operates as a standard container class and enables design choices based on use case or preference betweenobjanddict. A natural consequence is that users can now usedictas Nexus inputs whereverobjwas used (and sometimes required) previously. This insulates users from having to be aware of any Nexus-specific container semantics.The
DevBaseclass also no longer inherits directly fromobj. In this sense, it is no longer a generic container (this is too broad for a generic base class), but instead only introduces simpler conveniences like iterability.Extensive efforts have been made to complete the rollover without introducing errors due to the significant change in the
objandDevBaseinterfaces. Defensive measures have been taken to minimize the impact of any uncaptured errors to the Nexus userbase. Intermediate classes have been introduced that inherit a defensive interface: any interaction with the newobjandDevBaseclasses that uses a deprecated part of the old interface will raise an error thatIt is envisioned that the original classes (now
obj_deprecatedandDevBaseDeprecated) will be removed along with the intermediary classes in an upcoming release. This will give the user base some time to report issues before the final rollover occurs. At that point, only theobjandDevBaseclasses will remain - so please tolerate the temporary (but ugly) intermediate class hierarchy. Future refactoring will simplify the currentgeneric.py,developer.py, anddeveloper_tools.py(pureobjandDevBaseclasses) modules in the codebase.This PR was developed with assistance from ChatGPT 5.6 Sol.