-
Notifications
You must be signed in to change notification settings - Fork 13
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
Switching to Pyomo Config System and adding Python API #107
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jsiirola any comments on Prescient's use of the Pyomo config system would be welcome. |
jsiirola
reviewed
Jun 30, 2021
bknueven
commented
Jul 6, 2021
Myself or @darrylmelander have addressed most of @jsiirola's comments except the question of the single pass / double pass parser. I have a |
jsiirola
reviewed
Jul 7, 2021
jsiirola
reviewed
Jul 7, 2021
jsiirola
reviewed
Jul 7, 2021
Closed
This needs to wait on resolution to grid-parity-exchange/Egret#243 |
…el obligated to use any of this commit if you aren't happy with the direction I went with it. * Each Prescient() instance has its own independent PrescientConfig() instance. It starts with standard options and default values, independent of any options set in a previous Prescient run. * Plugin registration is triggered by setting the config.plugin value (or values). Registration is handled by the config instance itself, making sure plugin registration gets handled first when setting multiple options in a single function call, whether via a dictionary or via a list of strings. Plugin registration has to come first so that any new options added by the plugin are recognized by the config object. * Plugins are required to supply a function called "register plugins", which receives a PluginRegistrationContext and a PrescientConfig object as arguments. The PluginRegistrationContext supplies functions the plugin can call to register for callbacks. New command line options can be added to the supplied config object. * Plugin registration is local to a particular Prescient instance, rather than part of the global state. The plugins active in a particular run are those in the run's Prescient.config.plugin list. There is no need to call reset_plugins() between runs because plugins and plugin registration aren't shared.
…; removing pyutilib dependence
* You give each plugin an alias. You use a line of code like `config.plugin.my_alias = 'my_package.plugin'`. This assigns the alias "my_alias" to the plugin, and imports the specified python module. The module can be specified as a python module name, as an actual module object, or as the path to a python file. * Setting up the plugin alias as described above will give the plugin a chance to supply any configuration settings it uses. The plugin-specific configuration is stored in config.plugin.my_alias. * You can set up a plugin on the command line (or a config file) using --plugin=alias:module, where alias is the alias that determines where the plugin's configuration is stored, and module is either the module name or the module file path. The plugin may register new command line options, which are made available immediately. Plugins may choose to incorporate the alias into their option names. * You can also set up a plugin using a dictionary. The alias is put into the dictionary with the key "module". Other plugin configuation values can be put in the same dictionary. * Plugins must supply a register_plugins method that registers whatever callbacks it uses. This method called just before the simulation starts. Here are a couple examples of how you might set up a plugin: import my_plugins.pricing config.plugin.pricing = my_plugins.pricing config.plugin.pricing.option1 = 100 config.plugin.pricing.option2 = 'fast' config.plugin.stats_writer = '../plugins/stats.py' config.plugin.stats_writer.write_hourly = True options = {'plugin': {'ruc_monitor': { 'module': 'my_plugins.ruc', 'verbose':True } } } config.set_value(options)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes:
simulate
method (closes Create a better Python API #105).--traceback
and--profile
options.5.7.26.1.2.Extra functions for handling "global" module-level variables (we should probably re-think this at some point)import_file
, removing dependency onpyutilib