Skip to content

Nexus: replace obj and DevBase classes#6037

Open
jtkrogel wants to merge 20 commits into
QMCPACK:developfrom
jtkrogel:nx_new_obj_devbase2
Open

Nexus: replace obj and DevBase classes#6037
jtkrogel wants to merge 20 commits into
QMCPACK:developfrom
jtkrogel:nx_new_obj_devbase2

Conversation

@jtkrogel

@jtkrogel jtkrogel commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This PR replaces the old obj and DevBase with new streamlined versions. This was done because:

  1. The old classes introduced an inordinate amount of functions and baggage.
  2. The old classes included functions that masked other standard Python classes like list, making it very hard to reason about the code.
  3. The new classes provide a cleaner, minimal base for future Nexus development that is also friendlier to incoming/new developers.
  4. The new classes mirror classes developed by me outside of Nexus. With these updates, I will be able to integrate functionality developed externally into Nexus proper (e.g. multideterminant file handling, SHDMC functionality, etc).

A main change it to make the widely used obj class dict-conformant. It now operates as a standard container class and enables design choices based on use case or preference between obj and dict. A natural consequence is that users can now use dict as Nexus inputs wherever obj was used (and sometimes required) previously. This insulates users from having to be aware of any Nexus-specific container semantics.

The DevBase class also no longer inherits directly from obj. 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 obj and DevBase interfaces. 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 new obj and DevBase classes that uses a deprecated part of the old interface will raise an error that

  1. Instructs the user to report the error to the developers.
  2. Provides instructions on how to restore the original functionality by uncommenting two lines in the source.

It is envisioned that the original classes (now obj_deprecated and DevBaseDeprecated) 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 the obj and DevBase classes will remain - so please tolerate the temporary (but ugly) intermediate class hierarchy. Future refactoring will simplify the current generic.py, developer.py, and developer_tools.py (pure obj and DevBase classes) modules in the codebase.

This PR was developed with assistance from ChatGPT 5.6 Sol.

@jtkrogel
jtkrogel requested a review from brockdyer03 July 11, 2026 20:57
@prckent

prckent commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

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 brockdyer03 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread nexus/nexus/bin/qmc-fit
@@ -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])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover comment?





Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Slightly excessive whitespace.

@@ -60,7 +59,8 @@ def test_xsffile(tmp_path):

# populate reference object
ref = XsfFile()
ref.set(
#ref.set(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover comment

@@ -178,7 +178,8 @@ def test_poscar_file(tmp_path):

# populate reference object
ref = PoscarFile()
ref.set(
#ref.set(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And here

@@ -247,6 +247,8 @@ def test_analyze():
),
)

assert(object_eq(ga.to_obj(),ga_ref))
print_diff(to_obj(ga),ga_ref)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover

@@ -40,7 +40,9 @@ def format_value(v):


def make_serial_reference(gi):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover

@@ -17,7 +17,8 @@


def test_read():
from ..developer import obj
#from ..developer import obj

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover

@@ -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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Leftover

@brockdyer03

Copy link
Copy Markdown
Contributor

Q. Does this need sequencing around any of the existing PRs?

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.

@jtkrogel

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Out at the beach. Will address Friday.

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.

3 participants