Fix parameters
Addresses #601 (closed)
This is a first WIP request for comments/review, commits will be reorganized to be more meaningful.
DONE
-
.configs
should showdefault
as well -
rename
Parameters
toBaseParameters
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 insideswitch
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
- @sebastien.petitdemange Review the code
- @sebastien.petitdemange answer if we need the read-only option and YML
- @pancino Write documentation
- @pancino More tests
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 withboolify
if value == "None":
# Manages the python None value stored in Redis as a string
value = None
return value
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)