Skip to content
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

Enable extensions (loader) #99

Closed
6 of 13 tasks
barneydobson opened this issue Sep 4, 2024 · 0 comments · Fixed by #104
Closed
6 of 13 tasks

Enable extensions (loader) #99

barneydobson opened this issue Sep 4, 2024 · 0 comments · Fixed by #104
Assignees

Comments

@barneydobson
Copy link
Collaborator

barneydobson commented Sep 4, 2024

Implement this separately

Original implementation: wsimod/orchestration/model.py

@dalonsoa suggests:

  • List of filepaths under extensions entry in the config file.
for extension_file in config.get('extensions',[]):
   # use the import module (see swmmanywhere)`

Nodes

  • Check that the node register function updates the model.nodes_type information.
  • By importing a node module, it should now be available via the register

Decorators

  • Ignore ExtensionHandler from Extensions: decorators #97 , decorators now stored in extensions_register, which makes extensions available to the model.
  • A custom decorator will call register_node_method, on import, which will add it to the extensions_register.
  • extensions_register will need to be iterated over after the nodes have been instantiated inside model.load, as demonstrated below.
extensions_register = {
    'node_name' : 
      {
         'method' : method,
      }
}

def apply_decorators(model):
   for node_name, decorator in extensions_register.items():
      if 'sub_object' in decorator:
         setattr(getattr(model.nodes[node_name], decorator['sub_object']), method_name, method)
         continue   
      setattr(model.nodes[node_name], method_name, method)

Sequence

  1. Enter model.load
  2. Instantiate extensions_register
  3. Import extensions
  4. Instantiate nodes
  5. Apply decorators

To do list

Within #97 - @dalonsoa

  • Create extensions_register
  • Create register_node_method (optional arg for sub_object).
  • Add apply_decorators
  • Tests (make tests that can be used in docs)

Within this PR - @dalonsoa

  • Implement sequence above
  • Tests (make tests that can be used in docs)

Close #54 , make a new PR - @liuly12

  • Keep the custom orchestration stuff, bin else

Documentation (new issue)

  • Overview of all new functionality (overrides, subclassing, decorators). - @dalonsoa
  • Enable decoration of handlers (easy to code - a distinct decorator, e.g., register_node_handler) - us to revisit
  • update documentation for 'customise interactions' and 'river reservoir'. @barneydobson
  • Take down old documentation on customisation ('customise a node').
  • Release here! @dalonsoa
  • Longer term issue to update customise a node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants