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

Config should be fetched at startup #10

Open
GDYendell opened this issue May 5, 2023 · 2 comments
Open

Config should be fetched at startup #10

GDYendell opened this issue May 5, 2023 · 2 comments
Assignees

Comments

@GDYendell
Copy link
Collaborator

Call read_all_config in __init__, currently only used after an initialize.

@GDYendell GDYendell self-assigned this May 5, 2023
@JamesOHeaDLS
Copy link
Collaborator

JamesOHeaDLS commented Sep 9, 2024

I saw this today and thought it might be something straightforward I could pick up.

I see that __init__ performs more checks as part of the loop through DETECTOR_CONFIG. Can this whole loop be introduced to read_all_config and then the code block in __init__ can be replaced by a call to it?

In init

        # Initialise configuration parameters and populate the parameter tree
        for cfg in self.DETECTOR_CONFIG:
            param =  self.read_detector_config(cfg)
            if param is not None:
                setattr(self, cfg, param)
                # Check if the config item is read/write
                writeable = False
                if 'access_mode' in param:
                    if param['access_mode'] == 'rw':
                        writeable = True

                if writeable is True:
                    param_tree[self.STR_DETECTOR][self.STR_API][self._api_version][self.STR_CONFIG][cfg] = (lambda x=cfg: self.get_value(getattr(self, x)),
                                                                                                            lambda value, x=cfg: self.set_value(x, value),
                                                                                                            self.get_meta(getattr(self, cfg)))
                else:
                    param_tree[self.STR_DETECTOR][self.STR_API][self._api_version][self.STR_CONFIG][cfg] = (lambda x=cfg: self.get_value(getattr(self, x)), self.get_meta(getattr(self, cfg)))
            else:
                logging.error("Parameter {} has not been implemented for API {}".format(cfg, self._api_version))
                self.missing_parameters.append(cfg)

read_all_config

    def read_all_config(self):
        for cfg in self.DETECTOR_CONFIG:
            param =  self.read_detector_config(cfg)
            setattr(self, cfg, param)

@GDYendell
Copy link
Collaborator Author

Yeah that does seem wrong. I think it makes sense to only do those checks at the start when deciding to add things to the parameter tree, but it should then read the configs in the parameter tree, not DETECTOR_CONFIG. I don't know how easy it is to get the list of configs back out from the parameter tree, though.

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

2 participants