I think the Tango CLI is really nice and would really like if we could support Python-defined experiments with CLI-style execution. So I modularized the CLI run functions and decoupled them from __main__.py.
Now we can also run scripts like:
from tango import StepGraph
from tango.cli import tango_cli, execute_step_graph, prepare_workspace, prepare_executor
from examples.euler.complex_arithmetic import *
from tango.steps import PrintStep
i = [0.0, 1.0]
pi = [3.1415926535, 0.0]
i_times_pi = MultiplyStep(a=i, b=pi)
pow_e = ExponentiateStep(x=i_times_pi)
plus_one = AdditionStep(a=pow_e, b=[1,0])
print_step = PrintStep(input=plus_one)
step_graph = StepGraph({
"i_times_pi": i_times_pi,
"pow_e": pow_e,
"plus_one": plus_one,
"print": print_step
})
if __name__ == '__main__':
with tango_cli():
workspace = prepare_workspace()
executor = prepare_executor(workspace)
execute_step_graph(step_graph, workspace, executor)
This should be the same as tango run examples/euler/euler.jsonnet!
If we want to use the default TangoGlobalSettings, we can also shorten the block to
with tango_cli():
execute_step_graph(step_graph)
This includes the changes from (@BigRedT) Tanmay's PR #491. CLI functionality should be completely the same. I ran the tests in tests/main_test.py successfully. Formatted with isort and black and checked with ruff and mypy. Docs needed.
What do you think? Happy to make adjustments as you see fit!
Hey!
I think the Tango CLI is really nice and would really like if we could support Python-defined experiments with CLI-style execution. So I modularized the CLI run functions and decoupled them from
__main__.py
.Now we can also run scripts like:
This should be the same as
tango run examples/euler/euler.jsonnet
!If we want to use the default
TangoGlobalSettings
, we can also shorten the block toThis includes the changes from (@BigRedT) Tanmay's PR #491. CLI functionality should be completely the same. I ran the tests in
tests/main_test.py
successfully. Formatted withisort
andblack
and checked withruff
andmypy
. Docs needed.What do you think? Happy to make adjustments as you see fit!