-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hide parameter value in logs and tracking on demand
* add `hidden` attr to `ParameterDefinition` * hide parameter value if needed in TaskBanner and TaskRunParamInfo * fix misleading type hint * add tests
- Loading branch information
1 parent
7567c9a
commit b7030c4
Showing
5 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
modules/dbnd/test_dbnd/parameters/test_hidden_parameter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from dbnd import task | ||
from dbnd._core.parameter.parameter_builder import parameter | ||
from dbnd._core.task_ctrl.task_visualiser import TaskVisualiser | ||
from dbnd._core.tracking.tracking_info_convertor import build_task_run_info | ||
|
||
|
||
@task | ||
def t_f(input_=parameter[str](hidden=True)): | ||
print("testing...") | ||
return "random string" | ||
|
||
|
||
class TestHiddenParameter(object): | ||
def test_parameter_value_stays_hidden_in_task_run_info_object(self): | ||
my_task = t_f.t("test_string") | ||
task_run = my_task.dbnd_run().root_task_run | ||
|
||
task_run_info = build_task_run_info(task_run) | ||
|
||
input_task_param_info = [ | ||
task_param_info | ||
for task_param_info in task_run_info.task_run_params | ||
if task_param_info.parameter_name == "input_" | ||
] | ||
assert len(input_task_param_info) == 1 | ||
assert input_task_param_info[0].value == "***" | ||
|
||
def test_parameter_value_stays_hidden_in_banner(self): | ||
my_task = t_f.t("test_string") | ||
my_task.dbnd_run() | ||
|
||
banner = TaskVisualiser(my_task).banner("some_msg") | ||
print(banner) | ||
assert "***" in banner and "test_string" not in banner |