Type | Description | Applicable Scope |
DLCUtils library | A Python utility library that works with Notebook to simplify operations such as parameter handling, key management, and task communication. | All Notebook files. |
Magic commands | Special commands provided by Jupyter for switching syntax, referencing other Notebooks, installing dependencies, and more. | All Notebook files. |
Module | Main Functions | Purpose |
dlcutils.widgets | text(name, defaultValue, label),get(name),remove(name),removeAll(),getAll() | Define and obtain dynamic parameters. |
dlcutils.notebook | exit(value),run(path, timeout, parameters) | Pass exit parameters between notebooks and execute across files. |
dlcutils.jobs.taskValues | set(key, value),get(taskKey, key, debugValue) | Pass results between Workflow tasks through taskValues. |
dlcutils.secrets | get(secretName, secretVersion, region) | Obtain encrypted credentials from the Tencent Cloud SSM credential management service. |
# Define text parametersdlcutils.widgets.text(name='your_name', defaultValue='Ricky', label='Your name')# Obtain parametersprint(dlcutils.widgets.get('your_name'))# Output: Ricky
# Obtain task parameterstry:task_value = dlcutils.widgets.get('task_param')if not task_value:task_value = 'default_value'except Exception:task_value = 'default_value'print(task_value)# Obtain workflow parameterstry:workflow_value = dlcutils.widgets.get('workflow_param')if not workflow_value:workflow_value = 'default_value'except Exception:workflow_value = 'default_value'print(workflow_value)
# upstream.ipynbdlcutils.notebook.exit('12345')
# downstream.ipynbresult = dlcutils.notebook.run('/folder/upstream.ipynb', 60)print(result)# Output: 12345
# Upstream task notebook_upstreamdlcutils.jobs.taskValues.set(key='favorite_food', value='apple')
# Downstream task notebook_downstream (with notebook_upstream configured as upstream)value = dlcutils.jobs.taskValues.get(taskKey='notebook_upstream',key='favorite_food',debugValue='banana')print(value)# Output during Studio debugging: banana# Output during Workflow scheduling: apple
taskValues.get only during Workflow scheduling. During Studio debugging, debugValue is obtained instead.secret = dlcutils.secrets.get('my_secret', 'v1', 'ap-guangzhou')print(secret)
Command | Function |
%sql | Switch the current cell to Spark SQL syntax. |
%md | Switch the current cell to Markdown for display only. |
%scala | Switch the current cell to Scala syntax (engine-dependent). |
%sqlSELECT count(*) FROM your_catalog.your_schema.your_table;
%run /path/to/another_notebook.ipynb
%pip install pandas==2.2.0 jieba
dlcutils.widgets.text(...) and dlcutils.notebook.exit(...) directly in a Python cell without additional imports.%sql / %md / %scala in the first line of a Python cell.dlcutils.widgets.text and those defined visually.dlcutils.notebook.run / dlcutils.jobs.taskValues return debugValue during Studio debugging. They can obtain real upstream and downstream values only in Workflow scheduling scenarios.%pip install are not persistent. They become invalid after you create a new session or reset the environment.dlcutils.widgets.get consistently. The ${param_key} placeholder syntax is not supported because it applies only to SQL.dlcutils.widgets.get('xxx') returns a NameError?
This usually occurs because the parameter name is not defined. You can use the dlcutils.widgets.widgets() function to define parameter names and values, or click the Parameters button on the page and define the parameter name and value in the pop-up window.%run How do I write the path of the referenced Notebook?/workspace_1/your_username/folder/upstream.ipynb.folder/upstream.ipynb (relative to the current file).ap-guangzhou / ap-shanghai. You can view the region to which a credential belongs in the SSM console.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan