Skip to content

Example of using variables in command output #18

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

Draft
wants to merge 2 commits into
base: sergiym/doc/var_propagation
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions mlos_bench/mlos_bench/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,19 @@
... "const_arg_from_globals_1",
... "const_arg_from_cli_1"
... ],
... // For a ScriptEnv (like LocalEnv) we can also export some of those
... // variables to the shell environment for use in shell commands during the
... // setup/run/teardown phases.
... "shell_env_params": [
... "const_arg_from_globals_1"
... ],
... "run": [
... "echo Hello world"
... ]
... "echo const_arg_from_globals_1,$const_arg_from_globals_1",
... "echo const_arg_from_globals_2,$const_arg_from_globals_2"
... ],
... // Here we capture the standard output key,value pair to be saved in
... // the trial results.
... "results_stdout_pattern": "([a-zA-Z0-9_-]+),([ a-zA-Z0-9._-]+)"
... }
... }
... '''
Expand Down Expand Up @@ -331,6 +341,10 @@
... "dummy_param_float": 0.5,
... "dummy_param3": 0.999
... }
... (status, ts, results_data) = env.run()
... assert results_data["const_arg_from_globals_1"] == env.parameters["const_arg_from_globals_1"]
... # This one wasn't included in the shell_env_params so isn't available for use.
... assert results_data.get("const_arg_from_globals_2") != env.parameters["const_arg_from_globals_2"]

These are the values visible to the implementations of the ``setup``, ``run``, and ``teardown``
methods. We can see both the constant and tunable parameters combined into a single dictionary
Expand Down