viktor.result
SetParametersResult
- class
viktor.result.
SetParametersResult
(params)¶ -
Container for the output of a
SetParamsButton
.In order to set the content of the field Tab 1 > Section 1 > NumberField 1 to 1234 use the format:
SetParametersResult({ "tab_1": { "section_1": { "numberfield_1": 1234 } } })
To clear one or more fields one has to explicitly set the params to the empty state, the empty value is different for each field and can be found in their docs:
SetParametersResult({ "tab_1": { "section_1": { "numberfield_1": None, } } })
- Parameters
params (
dict
) – the values you want to set to the user input, if you do not specify a value, it will be kept as is.
-
get
(key)¶
DownloadResult
- class
viktor.result.
DownloadResult
(file_content, file_name, encoding='utf-8')¶ -
Container for the output of a
DownloadButton
.- Parameters
file_content (
Union
[str
,bytes
,File
,BytesIO
]) – if type str and encoding is not utf-8, specify in additional argumentfile_name (
str
) – name to be used for download (including extension)encoding (
str
) – optional argument to specify file encoding when file_content is provided with type str
OptimisationResultElement
- class
viktor.result.
OptimisationResultElement
(params, analysis_result=None)¶ -
- Parameters
params (
Union
[dict
,Munch
]) – a complete parameter setanalysis_result (
Optional
[dict
]) – the accompanying results.
For an example, see
OptimisationResult
OptimisationResult
- class
viktor.result.
OptimisationResult
(results, result_column_names_input=None, output_headers=None, image=None)¶ -
Container for the output of an
OptimiseButton
.- Parameters
results (
List
[OptimisationResultElement
]) – list of results, order is kept in user interface.result_column_names_input (
Optional
[List
[str
]]) – specifies which input parameters should be shown the table. The parametrization class defined the label which is shownoutput_headers (
Optional
[dict
]) – specifies which results should be shown in the results table. Key should match the key of the analysis_result inside each result. Value is the corresponding label which the end user sees.image (
Union
[PNGResult
,JPGResult
,SVGResult
,None
]) – image which is shown next to the results. Could be JPG, PNG or SVG.
Example:
params1 = {'tab': {'section': {'field1': 'a', 'field2': 5}}} params2 = {'tab': {'section': {'field1': 'b', 'field2': 8}}} analysis1 = {'result1': 10, 'result2': 20} analysis2 = {'result1': 100, 'result2': 150} results = [ OptimisationResultElement(params1, analysis1), OptimisationResultElement(params2, analysis2), ] OptimisationResult(results, result_column_names_input=['field1'], output_headers={'result1': 'Result 1'})
This renders as the following table for the end-user:
#
Field 1
Result 1
1
a
10
2
b
100
ViktorResult
- class
viktor.result.
ViktorResult
(optimisation_result=None, set_parameters_result=None, download_result=None)¶ -
Standard output object of a ViktorController method, which serialises and combines several individual results into the standard automation output. All inputs are optional to facilitate many combinations of results where needed in the future. Currently, the serialisation only accounts for the following (backward compatible) combinations:
a single optimisation result
a single set_parameter result
a single download result
- Parameters
optimisation_result (
Optional
[OptimisationResult
]) – OptimisationResult objectset_parameters_result (
Optional
[SetParametersResult
]) – SetParametersResult objectdownload_result (
Optional
[DownloadResult
]) – DownloadResult object