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

Programmatic API as well as / instead of YAML config file ? #7

Open
sjdaines opened this issue Apr 21, 2022 · 1 comment
Open

Programmatic API as well as / instead of YAML config file ? #7

sjdaines opened this issue Apr 21, 2022 · 1 comment

Comments

@sjdaines
Copy link
Member

Overall goal is to make use of PALEO follow best practices in the Julia ecosystem (see eg https://discourse.julialang.org/t/julia-stats-data-ml-expanding-usability/67948
https://docs.google.com/presentation/d/1deIp582Ommw2wQtI1EQaR3lNy8LSLOA2c0FYjKKR-Bo/edit#slide=id.p1 )

This could be straightforward: really just need to define some add methods, with careful attention to syntax to produce code that reads like a config file, eg:

domain_global = add!(model, Domain("global"))
    
add!(
    domain_global,
    "myreaction" => SomeReactionType(
        pars=(
            a:=1,
            b:=2
        ),
        variable_links=(
            "varname" => "varnewname"
        ),
        variable_attributes=(
            "varname:initial_value" => 42
        ),
    ),
)

etc
@sjdaines
Copy link
Member Author

another attempt at an example syntax (see eg https://github.com/ordovician/QtUIParser.jl/blob/master/examples/color-selector.jl for inspiration):

function create_model(external_parameters)
    model = Model(
        parameters = external_parameters,
        domains = [
              :ocean => Domain(
                  reactions = [
                      "reservoir_A" => ReactionReservoir(
                           parameters = [
                               :isotope_type=>PB.IsotopeLinear,
                           ],
                          variable_links = [
                                "R*"=>"A*",
                          ],
                          variable_attributes = [
                              ("R", :initial_value) => 32.0,
                          ],
                      ),
                  ], # reactions
              ), # Domain
          ], # domains
     )  # model

     return model
end

NB: this will need a macro to write Reaction constructors, see eg https://discourse.julialang.org/t/writing-this-inner-constructor-with-a-macro/62945

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