Usage Scenario | Example Scenarios | Usage |
Dynamic adjustment of a single parameter | The same code needs to be executed repeatedly, but with different input conditions. For example, data from the previous day needs to be queried daily, so the time parameter of the data will vary. | Define the time parameter as a dynamic variable, test by adjusting it without modifying other parts of the code, and avoid writing similar code repeatedly. |
Isolation between development and production | In the development and production environments, different values need to be set for the same parameter. | Define project parameters and set values for debug runs, periodic scheduling, or for the development and production environments respectively, so that different values are retrieved from the corresponding scenarios during task debugging and scheduling runs. |

dlcutils.widgets.get("fav_Food")# output beans

# print project parametersdlcutils.widgets.get("test_parameter")# output 100


# get task_test_param value# When testing and running in the notebook space,# default values need to be set because the notebook file has not yet been associated with a task.try:task_test_param_value = dlcutils.widgets.get("task_param")if not task_test_param_value: # If the obtained value is an empty stringtask_test_param_value = 'task_default_value'except Exception: # If the parameter cannot be obtained at alltask_test_param_value = 'task_default_value'print(f"Using toy value: {task_test_param_value}")
# get workflow_test_param value# When testing and running in the notebook space,# default values need to be set because the notebook file has not yet been associated with a workflow.try:workflow_test_param_value = dlcutils.params.get("workflow_param")if not workflow_test_param_value: # If the obtained value is an empty stringworkflow_test_param_value = 'workflow_default_value'except Exception: # If the parameter cannot be obtained at allworkflow_test_param_value = 'workflow_default_value'print(f"Using toy value: {workflow_test_param_value}")
Usage Scenario | Example Scenarios | Usage |
Workflow Automation | Data processing workflow: In the ETL (Extract, Transform, Load) process, the first Notebook extracts and transforms data, and the second Notebook loads or further analyzes it. Machine learning workflow: The first Notebook trains the model and saves the results, and the second Notebook uses the model for prediction or evaluation. | The output parameters of the first Notebook are directly used as the input for the second Notebook, achieving automated connection between tasks. |
Completion of branch logic | Conditional processing: During data processing or analysis, different logic is executed based on different input conditions. Dynamic decision-making: In machine learning or data science projects, different processing paths are selected based on variations in model predictions or data characteristics. | The second Notebook file selectively runs different code logic by judging the output of the first Notebook. |
# Exit the notebook and output parametersdlcutils.notebook.exit('12345')
# get task_input_param value# When testing and running in the notebook space,# default values need to be set because the notebook file has not yet been associated with a task.try:task_input_param = dlcutils.widgets.get("parameter")if not task_input_param: # If the obtained value is an empty stringtask_input_param = 'task_input_default_value'except Exception: # If the parameter cannot be obtained at alltask_input_param = 'task_input_default_value'print(f"Using toy value: {task_input_param}")



dlcutils.secrets.get("secret_name", "v1", "ap-guangzhou")# output secret_value
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan