Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error reading module classes that change name between cmake build and installation from hdf5 #11

Open
HugoStrand opened this issue Feb 26, 2018 · 3 comments

Comments

@HugoStrand
Copy link
Member

Dear Olivier,

I am having trouble reading the cthyb solver from hdf5, but only when using it outside the cmake testing environment. In the cmake test phase the newly built cthyb solver is accessible as cthyb.solver_core.SolverCore while when we then install it the module path is triqs_cthyb.solver_core.SolverCore. In the wrapped solver_core_wrap.cxx the first module path is hard coded.

When I store the solver to hdf5 and try to read it again it fails complaining that:

Traceback (most recent call last):
  File "h5_read_write.py", line 41, in <module>
    solver_ref = A['solver']
  File "/mnt/home/hstrand/apps/x86_64/triqs_unstable/lib/python2.7/site-packages/pytriqs/archive/hdf_archive.py", line 228, in __getitem__
    return self.__getitem1__(key,self._reconstruct_python_objects)
  File "/mnt/home/hstrand/apps/x86_64/triqs_unstable/lib/python2.7/site-packages/pytriqs/archive/hdf_archive.py", line 263, in __getitem1__
    exec("from %s import %s as r_class" %(r_module_name,r_class_name)) in globals(), locals()
  File "<string>", line 1, in <module>
ImportError: No module named cthyb.solver_core

How do we make these two things work together, 1. running the cmake test with different module name path and 2. getting the cpp2py wrapping to pick up the correct module path for the actual installation?

Best, Hugo

@parcollet
Copy link
Member

@Wentzell
Why is it different from the ctint code ?

@HugoStrand
Copy link
Member Author

Because it existed before the ctint code. The rationale for having a separately named python module in the cmake test phase is also to avoid picking up any previously installed version of the application. Right now the tests of ctint will be using whatever ctint python module that comes first in the pythonpath, rather than the one that has been built...

@Wentzell
Copy link
Member

ctint python module that comes first in the pythonpath, rather than the one that has been built...

ctint explicitly puts the installed module first in the pythonpath for all the tests

set_property(TEST ${all_tests} PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} )

In the cmake test phase the newly built cthyb solver is accessible as cthyb.solver_core.SolverCore while when we then install it the module path is triqs_cthyb.solver_core.SolverCore.

In my opinion we should not use different names in the first place. I find this quite inconsistent.
I was just looking at the structure of the cthyb application. I will make a pull request for these changes in a bit.

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

No branches or pull requests

3 participants