Skip to content

Commit

Permalink
#6022 - cleaned up jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeilman committed Aug 9, 2023
1 parent e4ab070 commit 2709c4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 4 additions & 10 deletions sirepo/package_data/template/srw/parameters.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ try:
except:
pass

{% if in_server %}
import sirepo.template
{% endif %}

import srwl_bl
import srwlib
import srwlpy
Expand Down Expand Up @@ -431,21 +435,11 @@ def _rsopt_set_params({{ rsOptFuctionSignature() }}):

def epilogue():
{% if in_server %}
import sirepo.template
sirepo.template.run_epilogue('srw')
{% else %}
pass
{% endif %}

{% if isBeamlineAnimation %}
def process_watch(**kwargs):
{% if in_server %}
import sirepo.template
sirepo.template.run_on_server("srw", "process_watch", **kwargs)
{% else %}
pass
{% endif %}
{% endif %}

def main():
{{srwMain}}
Expand Down
4 changes: 2 additions & 2 deletions sirepo/template/srw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ def _generate_srw_main(data, plot_reports, beamline_info):
content.append("op = set_optics(v, names, {})".format(is_last_watch))
if not is_last_watch:
content.append("srwl_bl.SRWLBeamline(_name=v.name).calc_all(v, op)")
content.append(f"process_watch(wid={prev_watch})")
content.append(f"sirepo.template.import_module('srw').process_watch(wid={prev_watch})")
prev_watch = beamline_info.watches[n]

elif run_all or (
Expand Down Expand Up @@ -2096,7 +2096,7 @@ def _generate_srw_main(data, plot_reports, beamline_info):
content.append("srwl_bl.SRWLBeamline(_name=v.name).calc_all(v, op)")
if report == "beamlineAnimation":
content.append(
f"process_watch(wid={beamline_info.watches.get(final_watch, 0)})"
f"sirepo.template.import_module('srw').process_watch(wid={beamline_info.watches.get(final_watch, 0)})"
)
return "\n".join(
[f" {x}" for x in content] + [""] + ([] if is_for_rsopt else ["main()", ""])
Expand Down

0 comments on commit 2709c4b

Please sign in to comment.