MCPcopy
hub / github.com/microsoft/RD-Agent / r

Method r

rdagent/utils/agent/tpl.py:122–145  ·  view source on GitHub ↗

Render the template with the given context.

(self, **context: Any)

Source from the content-addressed store, hash-verified

120 self.template = load_content(uri, caller_dir=caller_dir, ftype=ftype)
121
122 def r(self, **context: Any) -> str:
123 """
124 Render the template with the given context.
125 """
126 # loader=FunctionLoader(load_conent) is for supporting grammar like below.
127 # `{% include "scenarios.data_science.share:component_spec.DataLoadSpec" %}`
128 rendered = (
129 Environment(undefined=StrictUndefined, loader=FunctionLoader(load_content))
130 .from_string(self.template)
131 .render(**context)
132 .strip("\n")
133 )
134 while "\n\n\n" in rendered:
135 rendered = rendered.replace("\n\n\n", "\n\n")
136 logger.log_object(
137 obj={
138 "uri": self.uri,
139 "template": self.template,
140 "context": context,
141 "rendered": rendered,
142 },
143 tag="debug_tpl",
144 )
145 return rendered
146
147
148T = RDAT # shortcuts

Callers 15

test_agent_infraMethod · 0.80
test_includeMethod · 0.80
backgroundMethod · 0.80
get_scenario_all_descMethod · 0.80
genMethod · 0.80
hypothesis_genMethod · 0.80
genMethod · 0.80
genMethod · 0.80

Calls 2

renderMethod · 0.80
log_objectMethod · 0.80

Tested by 2

test_agent_infraMethod · 0.64
test_includeMethod · 0.64