Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Merge PySPConfigBlock back into pyutilib.misc.config #8

Open
jsiirola opened this issue Feb 15, 2018 · 1 comment
Open

Merge PySPConfigBlock back into pyutilib.misc.config #8

jsiirola opened this issue Feb 15, 2018 · 1 comment

Comments

@jsiirola
Copy link
Member

In an effort to simplify / standardize configuration / options in Pyomo, we should ensure that we only use a single configuration management system. The customizations / overrides in PySPConfigBlock and PySPConfigValue should be reviewed and, if appropriate, merged into pyutilib.misc.config. PySP should then directly use the pyutilib.misc.config system.

@ghackebeil
Copy link
Member

@jsiirola: There are still a few methods on PySPConfigBlock that add or change functionality from ConfigBlock. Two of those could be move off of the class and just be made helper functions that I use in PySP (or potentially elsewhere). However, there are three other methods that make some pretty fundamental differences in behavior. The following example should summarize what those differences are:

from pyomo.pysp.util.config import PySPConfigBlock
from pyutilib.misc.config import ConfigBlock

#                                                                                                                                                                                                                
# Overriding __setattr__                                                                                                                                                                                         
#                                                                                                                                                                                                                
print("")
b = PySPConfigBlock(implicit=True)
b.entry_1 = True
print('entry_1' in b) # -> True                                                                                                                                                                                  
print('entry 1' in b) # -> False                                                                                                                                                                                 

b = ConfigBlock(implicit=True)
b.entry_1 = True
print('entry_1' in b) # -> False                                                                                                                                                                                 
print('entry 1' in b) # -> True                                                                                                                                                                                  

#                                                                                                                                                                                                                
# Adding __delattr__                                                                                                                                                                                             
#                                                                                                                                                                                                                
print("")
b = PySPConfigBlock(implicit=True)
b.entry = True
print('entry' in b) # -> True                                                                                                                                                                                    
del b.entry
print('entry' in b) # -> False                                                                                                                                                                                   

b = ConfigBlock(implicit=True)
b.entry = True
print('entry' in b) # -> True                                                                                                                                                                                    
try:
    del b.entry # -> AttributeError                                                                                                                                                                              
except AttributeError:
    print("Caught AttributeError on 'del b.entry'")

#                                                                                                                                                                                                                
# Override add                                                                                                                                                                                                   
#                                                                                                                                                                                                                
print("")
b = PySPConfigBlock(implicit=True)
b.entry = True
print(list(v.name() for v in b.user_values())) # -> ['entry']                                                                                                                                                    

b = ConfigBlock(implicit=True)
b.entry = True
print(list(v.name() for v in b.user_values())) # -> ['']

jsiirola referenced this issue in jsiirola/pyomo Apr 8, 2021
Report the original (or first seen) key format to the user, but
internally store all keys without spaces.  The partially fixes #352.
jsiirola referenced this issue in jsiirola/pyomo Apr 8, 2021
This partially fixed #352
jsiirola referenced this issue in jsiirola/pyomo Apr 8, 2021
@mrmundt mrmundt transferred this issue from Pyomo/pyomo Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants