镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Merge PySPConfigBlock back into pyutilib.misc.config #8

Open

Description

@jsiirola

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.

Activity

  1. ghackebeil commented on Apr 13, 2018

    @ghackebeil
    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())) # -> ['']
  2. transferred this issue fromPyomo/pyomoon Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions