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

Pass the param dict directly to the backend? #53

Open
2 of 4 tasks
leofang opened this issue Jun 14, 2019 · 3 comments
Open
2 of 4 tasks

Pass the param dict directly to the backend? #53

leofang opened this issue Jun 14, 2019 · 3 comments

Comments

@leofang
Copy link
Contributor

leofang commented Jun 14, 2019

Currently we maintain, effectively, 4 distinct dicts:

  1. https://github.com/leofang/ptycho_gui/blob/b64326d7d0db5f05bda684a55f295bf1fdeb57e2/nsls2ptycho/core/ptycho_param.py#L23
  2. An instance of the above Param() class here: https://github.com/leofang/ptycho_gui/blob/b64326d7d0db5f05bda684a55f295bf1fdeb57e2/nsls2ptycho/ptycho_gui.py#L104-L108
  3. configparser: https://github.com/leofang/ptycho/blob/b0b39bd849ad65842659e29dc446f9629fa1433e/utils.py#L8
  4. The backend ptycho_trans class https://github.com/leofang/ptycho/blob/b0b39bd849ad65842659e29dc446f9629fa1433e/ptycho_trans_ml.py#L79

This has caused a significant headache every time we want to pass new attributes from the fronted to the backend: We have to update all the four files above plus https://github.com/leofang/ptycho/blob/master/recon_ptycho_gui.py to get it work, which is too tedious from the maintenance point of view.

The goal is to maintain a single dictionary across both frontend and backend. Steps to resolve this are:

  • Instantiate the backend ptycho_trans class directly in the frontend, and dump its attributes to disk as before
  • Eliminate the intermediate Param class
  • Investigate the possibility of making the instance in-memory for the backend to reuse
  • Eliminate the usage of configparser
@leofang
Copy link
Contributor Author

leofang commented Jun 14, 2019

Instantiate the backend ptycho_trans class directly in the frontend, and dump its attributes to disk as before

This will do:

from nsls2ptycho.core.ptycho.ptycho_trans_ml import ptycho_trans
pty = ptycho_trans(None)

leofang added a commit that referenced this issue Jun 15, 2019
This is the first two steps in #53:
- Instantiate the backend ptycho_trans class directly in the frontend,
  and dump its attributes to disk as before
- Eliminate the intermediate Param class
@leofang
Copy link
Contributor Author

leofang commented Jun 17, 2019

We needed to dump the dict as a text file for the backend to read because otherwise the backend had no way to tell the working directory (and shm_name):
https://github.com/leofang/ptycho_gui/blob/b64326d7d0db5f05bda684a55f295bf1fdeb57e2/nsls2ptycho/ptycho_gui.py#L504-L505
But, if we let the Qt thread to define a few environmental variables at the start time of the backend, this need will be eliminated. Then, we can consider passing around a ptycho_trans instance in-memory.

@leofang
Copy link
Contributor Author

leofang commented Jun 23, 2019

Problems:

  1. some bugs due to conflicting attributes showed up
  2. when the reconstruction is done, has to instantiate a new param in the GUI (now = ptycho_trans) to avoid potential conflicts -> more complicated than I thought
  3. with shared memory, how to address the problem above? close the existing segment and open a new one?

This effort is currently in this branch: https://github.com/leofang/ptycho_gui/tree/refactor

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

1 participant