Skip to content

Fix parameters

Piergiorgio Pancino requested to merge fix_parameters into master

Addresses #601 (closed)

This is a first WIP request for comments/review, commits will be reorganized to be more meaningful.

DONE

  • .configs should show default as well

  • rename Parameters to BaseParameters or something

    • Currently renamed ParametersWardrobe as like dresses you can change slots as you wish. One another proposal is ParameterSet
  • always associate Parameters with default values

    • Default values are now stored in Redis
  • and optionally with a YAML mapping

    • Not done as we discussed that probably is not what we want
  • allow to save/load parameters values from the YAML mapping

    • Not done as we discussed that probably is not what we want
  • forbid the creation of new keys (?) or add a 'read-only' keys option

    • Where this read-only option is supposed to be activated? From the shell as a method? Or how?
  • added tests

OTHER IMPROVEMENTS

  • Improved representation that now shows all values from all sets and clearly identify which value are stored in Redis Vs which are taken as default
  Out [1]: ParametersWardrobe('a')
           
           'asterisks * means value retrieved from database, no asterisk means default value taken'
           
                         SELECTED    
           |         | 'altrissimo' |  'secondo'   |  'default'   |  'superl...rameter'  |   'primo'    |  'superl...rameter'  |   'altro'    
           -----------------------------------------------------------------------------------------------------------------------------------
           |   primo |     'primo'  |     'primo'* |     'primo'* |             'primo'  |           1* |             'primo'  |     'primo'  
           | secondo |           2* |           2* |           2* |                   2  |           2  |                   2  |           2  
           |   terzo |          10  |          10* |          10* |                  10  |           3* |                  10  |        'te'* 
           |   motor | 'object:m0'  | 'object:m0'* | 'object:m0'* |         'object:m0'  | 'object:m0'  |         'object:m0'  | 'object:m0'  
           |    axis |      'None'  |      'None'* |      'None'* |              'None'  |      'None'  |              'None'  |      'None'  
  • added a copy argument inside switch that makes a new set from an existing one
  • added a freeze method that Freezes all parameters inside the set (writing them on Redis)
  • improved the remove method: now can delete sets or attributes

TODO

OTHER

  • class ParamDescriptorWithDefault probably could be a subclass of ParamDescriptor

  • I hardcoded the 'None' option inside class ParamDescriptorWithDefault and ParametersWardrobe to store a 'None' string and retrieve a None value if None is passed to the parameter. Probably this could be done in different way like at the beginning of the module with boolify

https://gitlab.esrf.fr/bliss/bliss/blob/236adfd56144175ddcbdf1b7ac6c52e83d5ff4d2/bliss/config/settings.py#L1049


        if value == "None":
            # Manages the python None value stored in Redis as a string
            value = None
        return value

https://gitlab.esrf.fr/bliss/bliss/blob/236adfd56144175ddcbdf1b7ac6c52e83d5ff4d2/bliss/config/settings.py#L1253

Inside ParametersWardrobe

    def add(self, name, value=None):
        self.DESCRIPTOR(
            self._proxy_default,
            self._proxy_default,
            name,
            value if value else "None",
            True,
        )
        self._populate(name)
Edited by Piergiorgio Pancino

Merge request reports