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

How to Implement New Module in STATE system #127

Open
rburghol opened this issue Dec 20, 2023 · 0 comments
Open

How to Implement New Module in STATE system #127

rburghol opened this issue Dec 20, 2023 · 0 comments

Comments

@rburghol
Copy link
Contributor

rburghol commented Dec 20, 2023

  • Create object handler for new model component
    • Add a file to hold component class definition, parser and runtime code in the HSP2 directory
    • Create class as sub-class of ModelObject in om_[new_component_name].py:
      • name object as CamelCase i.e. [NewComponentName]
      • Give a unique, integer optype in the __init__() method
      • extend method NewComponentName.parse_model_props() if supporting custom json-type model_props array
      • extend NewComponentName.tokenize() method to add necessary integer keys to run in @njit runtime
      • tbd: extend method NewComponentName.parseUCI() if loadable from classic UCI
      • ex: class SpecialAction(ModelObject):
    • Add @njit compatible runtime evaluation function with prefix step_ (ex: step_[new_component_name]())
      • minimum arguments: (op, state_ix)
      • may have any/all of the following arguments: ( op, state_ix, dict_ix, op_tokens, step)
      • Ex: step_special_action()
    • (optional) Add @njit compatible runtime pre-eval function with prefix prestep_
  • Add Model Tokenizer and Run-time Support in om.py:
    • Import the file containing the class def and runtime code
    • Insure support in function model_class_loader()
      • Most often, all that is needed here is to add the following 2 lines:
        • if object_class =='NewModelObject':
        • model_object = NewModelObject(model_props.get('name'), container, model_props)
        • Ex: SpecialAction
    • Add execution handling in
      • step_one()
      • (optional) pre_step_model()
        • This is used for things that need to happen at the very beginning of a timestep
  • (optional) Insure that components are loaded into the state['model_data] dictionary at model startup in main.py
    • If the new model component data is not stored in the already loaded json file, or is stored in an hdf5 table that is not already loaded via a function, add function to load this data in main.py
This was referenced Dec 27, 2023
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

No branches or pull requests

1 participant