DARPA-ASKEM / terarium

https://app.terarium.ai
Apache License 2.0
15 stars 2 forks source link

[BUG]: The output panel of Edit Model shows no change after I click `Run` on some code, no error/warning/etc. surfaced #4967

Closed liunelson closed 3 days ago

liunelson commented 1 month ago

Describe the bug I have this model: Prob 5 Model C (new params).json

I want to edit its rate laws using the Edit Model operator:

import sympy

def replace_rate_law_sympy(model, template_name, new_rate_law):
    """Replace the rate law of transition. The new rate law passed in will be a sympy.Expr object

    Parameters
    ----------
    template_name :
        The ID of the transition whose rate law is to be replaced, this is
        typically the name of the transition
    new_rate_law :
        The new rate law to replace the existing rate law with

    Returns
    -------
    :
        The updated model as an AMR JSON
    """
    assert isinstance(model, TemplateModel)
    tm = model
    local_dict = { key:sympy.Symbol(key) for key, _value in tm.parameters.items() }
    for k, v in tm.get_concepts_name_map().items():
        local_dict[k] = sympy.Symbol(k)

    for template in tm.templates:
        if template.name == template_name:
            template.set_rate_law(new_rate_law, local_dict=local_dict)
    return tm

# Transmission by direct (fluid) contact
model = replace_rate_law_sympy(
    model, 
    "t2", 
    "i * omega * epsilonD * (1 - (1/e)**(Cvs * Vsputum / k)"
)

# Transmission by aerosols
model = replace_rate_law_sympy(
    model, 
    "t1", 
    "i * omega * (1 - (1/e)**(theta * IR**2 * Cv * Ci * IR * Vdrop * tContact / ((AER + lambda + S) * Vair))"
)

When I click Run, the code seems to have been run successfully. However, the right/output panel still shows the same input model (same graph, same state and parameter tables).

Context

This is the operator where I encountered this problem: https://app.staging.terarium.ai/projects/a9d892c8-7ed0-4589-b286-49ef15b71c52/workflow/42c0f2d4-b24b-41e8-b5e2-6efc800b4367?operator=b693870d-2f61-4b1c-9cfc-fcd85ab77286

mwdchang commented 1 month ago

The rate laws provided here

Do not have balanced brackets, they probably should be

"i * omega * epsilonD * (1 - (1/e)**(Cvs * Vsputum / k))"
"i * omega * (1 - (1/e)**(theta * IR**2 * Cv * Ci * IR * Vdrop * tContact / ((AER + lambda + S) * Vair)))"