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

Refactor "src/dsl.jl" file #985

Merged
merged 52 commits into from
Feb 13, 2025
Merged

Refactor "src/dsl.jl" file #985

merged 52 commits into from
Feb 13, 2025

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Jul 13, 2024

Also does the "src/expression_utils.jl" file, as that primarily support the dsl file (the other relevant file is the chemistry one).

Primarily four types of changes:

  • Added comment to code which did not have (primarily older code).
  • Rewrite some old code (a lot of stuff in the dsl file is stuff I wrote over 6 years ago, which simply can be rewritten better now).
  • Do some organisations for where the options are handled in the main function. Been meaning to do this pretty much since I introduced them, and now when we have all *for the foreseeable future) it seemed like a good time to do it. Now it should also be easier to see where to add new options in the future.
  • Rewrite so that the @reaction_network and @network_component macros reuse minimal amount of code (where as previously it the second was basically ctrl+copied versions of the first.
  • Add a bunch of error checks to handle things which previously went through but shouldn't.

I also add some tests of all the various ways to create models via the DSL, mostly stuff that was not tested before.

@TorkelE TorkelE changed the title Refactor "srcd/sl.jl" file [wip] Refactor "srcd/sl.jl" file Jul 13, 2024
@TorkelE TorkelE force-pushed the src___refactoring___dsl_file branch from 3f92a31 to b6ba044 Compare July 13, 2024 23:09
src/dsl.jl Outdated
variables = vcat(variables_declared, vars_extracted)

# handle independent variables
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the organisations so that options are handled together (in two sets, some before and some after the reactions are considered, depending on whichever is possible for which option)

src/dsl.jl Outdated
symvec = gensym()
ex = quote
$symvec = $ex
expr = quote
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in some places we used ex and some expr, here I just made it uniform

@TorkelE
Copy link
Member Author

TorkelE commented Jan 20, 2025

This should be ready now. However, Plots fails on precompilation, so have to wait until that is fixed.

Not high priority though, doesn't actually change anything (but should make further updates to the DSL easier).

Once this PR is merged, I will have a follow-up one which reorders the option handling functions to follow the order with which they are called.

@TorkelE TorkelE changed the title [Wip] Refactor "src/dsl.jl" file Refactor "src/dsl.jl" file Jan 21, 2025
Copy link
Member

@isaacsas isaacsas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check that non-scalarization is still working ok for vector parameters, and ensure there isn't a performance regression. See the examples in #1051

exsys = Catalyst.make_reaction_system(ex)
sys = @eval Catalyst $exsys
@test sys isa ReactionSystem
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this added by someone though who wanted a test to check they could get the expressions out and evaluate them? If so we should probably keep some kind of variation on this checking such a process works.

exsys = Catalyst.make_reaction_system(ex)
sys = @eval Catalyst $exsys
@test sys isa ReactionSystem
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we modify the test to eval within a new module? Maybe that would avoid the observed issue?

@isaacsas
Copy link
Member

Ahh, nevermind that comment. For some reason Github showed me an old version of the code... Looks good to me.

@isaacsas isaacsas dismissed their stale review February 12, 2025 20:33

Out of date

@TorkelE TorkelE merged commit d0fea7d into master Feb 13, 2025
13 checks passed
@TorkelE TorkelE deleted the src___refactoring___dsl_file branch February 13, 2025 11:18
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 this pull request may close these issues.

2 participants