|
4 | 4 | This is proprietary source code of DataRobot, Inc. and its affiliates. |
5 | 5 | Released under the terms of DataRobot Tool and Utility Agreement. |
6 | 6 | """ |
| 7 | +import logging |
| 8 | + |
7 | 9 | # Use this helper class to access the runtime parameter values in your model |
8 | 10 | from datarobot_drum import RuntimeParameters |
9 | 11 |
|
10 | 12 |
|
| 13 | +logger = logging.getLogger(__name__) |
| 14 | + |
| 15 | + |
11 | 16 | # This is a naive function so as to not dump the full credential values |
12 | 17 | # during this demonstration. |
13 | 18 | def mask(value, visible=3): |
14 | 19 | return value[:visible] + ("*" * len(value[visible:])) |
15 | 20 |
|
16 | 21 |
|
17 | 22 | def transform(data, model): |
18 | | - print("=" * 40) |
19 | | - print("Loading the following Runtime Parameters:") |
| 23 | + logger.info("=" * 40) |
20 | 24 | option1 = RuntimeParameters.get("option1") |
21 | | - print(f"\toption1: {option1}") |
22 | 25 | option2 = RuntimeParameters.get("option2") |
23 | | - print(f"\toption2: {option2}") |
24 | 26 | option3 = RuntimeParameters.get("option3") |
25 | | - print(f"\toption3: {option3}") |
| 27 | + logger.info( |
| 28 | + "Loading the following Runtime Parameters: " |
| 29 | + f"option1: {option1}, option2: {option2}, option3: {option3}", |
| 30 | + ) |
26 | 31 |
|
27 | 32 | credential = RuntimeParameters.get("encryption_key") |
28 | 33 | if credential is not None: |
29 | 34 | credential_type = credential.pop("credentialType") |
30 | | - print( |
31 | | - f"\tapi_key(type={credential_type}): " |
32 | | - + str({k: mask(v) for k, v in credential.items()}) |
| 35 | + logger.info( |
| 36 | + "Using credentials api_key: ", |
| 37 | + extra={ |
| 38 | + "credential_type": credential_type, |
| 39 | + "api_key": str({k: mask(v) for k, v in credential.items()}), |
| 40 | + }, |
33 | 41 | ) |
34 | 42 | else: |
35 | | - print("No credential data set") |
| 43 | + logger.info("No credential data set") |
36 | 44 |
|
37 | 45 | # boolean runtime param |
38 | 46 | bool_var = RuntimeParameters.get("bool_var") |
39 | | - print(f"\tbool_var: {bool_var}") |
| 47 | + logger.info("\tbool_var: %s", bool_var) |
40 | 48 |
|
41 | 49 | # numeric runtime param |
42 | 50 | number1 = RuntimeParameters.get("number1") |
43 | | - print(f"\tnumber1: {number1}") |
| 51 | + logger.info("\tnumber1: %s", number1) |
44 | 52 | number2 = RuntimeParameters.get("number2") |
45 | | - print(f"\tnumber2: {number2}") |
| 53 | + logger.info("\tnumber2: %s", number2) |
46 | 54 |
|
47 | | - print("=" * 40) |
| 55 | + logger.info("=" * 40) |
48 | 56 |
|
49 | 57 | # This transform function is just for illustrative purposes so just |
50 | 58 | # return the data back unaltered. |
|
0 commit comments