PortDataReference 類別

建立與已完成 StepRun 輸出相關聯的模型資料。

PortDataReference 物件可用來下載 所產生的 StepRun 輸出資料。 它也可作為未來管線中的步驟輸入。

初始化 PortDataReference。

繼承
builtins.object
PortDataReference

建構函式

PortDataReference(context, pipeline_run_id, data_reference, step_run=None)

參數

context
<xref:azureml.pipeline.core._GraphContext>
必要

圖形內容物件。

pipeline_run_id
str
必要

產生輸出之管線執行的識別碼。

data_reference
DataReference
必要

資料參考物件。

step_run
StepRun
預設值: None

產生資料的 StepRun 物件。

context
<xref:azureml.pipeline.core._GraphContext>
必要

圖形內容物件。

pipeline_run_id
str
必要

產生輸出之管線執行的識別碼。

data_reference
DataReference
必要

資料參考物件。

step_run
StepRun
必要

產生資料的 StepRun 物件。

備註

PortDataReference 指向已完成 StepRun 所產生的資料。

PipelineRun 取得 PortDataReference 並下載輸出資料,如下所示:


   from azureml.pipeline.core import PipelineRun, StepRun, PortDataReference

   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")
   step_run = pipeline_run.find_step_run("<node_name>")[0]
   port_data_reference = step_run.get_output_data("<output_name>")
   port_data_reference.download(local_path="path")

PortDataReference 可作為 中 Pipeline 步驟的輸入,類似于使用 DataReference

使用 PortDataReference 作為步驟輸入的範例如下:


   from azureml.pipeline.core import PortDataReference, Pipeline, PipelineRun
   from azureml.pipeline.steps import PythonScriptStep

   pipeline_run = PipelineRun(experiment, "<pipeline_run_id>")
   step_run = pipeline_run.find_step_run("<node_name>")[0]
   port_data_reference = step_run.get_output_data("<output_name>")

   step_1 = PythonScriptStep(
       name='train',
       script_name="train.py",
       compute_target=compute,
       arguments=["--input", port_data_reference],
       inputs=[port_data_reference]
   )

   pipeline = Pipeline(workspace=workspace, steps=[step_1])

在此範例中,新建構的 Pipeline 會使用已完成 PipelineRun 所建立的輸出作為定型步驟的輸入。

方法

as_download

透過「下載」模式,使用 PortDataReference 作為步驟輸入。

as_input

建立 InputPortBinding 並指定輸入名稱 (,但使用預設模式) 。

as_mount

透過「掛接」模式,使用 PortDataReference 作為步驟輸入。

create_input_binding

使用此 PortDataReference 作為來源建立輸入系結。

download

下載 PortDataReference 所代表的資料。

as_download

透過「下載」模式,使用 PortDataReference 作為步驟輸入。

as_download(input_name=None, path_on_compute=None, overwrite=None)

參數

input_name
str
預設值: None

指定此輸入的名稱。

path_on_compute
str
預設值: None

要下載資料之計算的路徑。

overwrite
bool
預設值: None

使用 來指出是否要覆寫現有的資料。

傳回

使用這個 PortDataReference 作為來源的 InputPortBinding。

傳回類型

as_input

建立 InputPortBinding 並指定輸入名稱 (,但使用預設模式) 。

as_input(input_name)

參數

input_name
str
必要

使用 來指定此輸入的名稱。

傳回

使用這個 PortDataReference 作為來源的 InputPortBinding。

傳回類型

as_mount

透過「掛接」模式,使用 PortDataReference 作為步驟輸入。

as_mount(input_name=None)

參數

input_name
str
預設值: None

使用 來指定此輸入的名稱。

傳回

使用這個 PortDataReference 作為來源的 InputPortBinding。

傳回類型

create_input_binding

使用此 PortDataReference 作為來源建立輸入系結。

create_input_binding(input_name=None, mode=None, path_on_compute=None, overwrite=None)

參數

input_name
str
預設值: None

輸入的名稱。

mode
str
預設值: None

存取 PortDataReference (「mount」 或 「download」) 的模式。

path_on_compute
str
預設值: None

針對「下載」模式,資料將位於計算上的路徑。

overwrite
bool
預設值: None

針對「下載」模式,是否要覆寫現有的資料。

傳回

使用這個 PortDataReference 作為來源的 InputPortBinding。

傳回類型

download

下載 PortDataReference 所代表的資料。

download(local_path, overwrite=None, show_progress=None)

參數

local_path
str
必要

要下載到的本機路徑。

overwrite
bool
預設值: None

如果為 true,請覆寫現有的檔案,預設值為 False。

show_progress
bool
預設值: None

在主控台中顯示下載進度,預設為 True。

傳回

已成功下載的檔案數目。

傳回類型

int

屬性

datastore

取得與 PortDataReference 相關聯的資料存放區。

傳回

資料存放區物件。

傳回類型

datastore_name

取得與 PortDataReference 相關聯的資料存放區名稱。

傳回

資料存放區名稱。

傳回類型

str

name

取得此資料參考的名稱。

傳回

資料參考名稱。

傳回類型

str

path_on_datastore

取得 PortDataReference 的資料存放區路徑。

傳回

資料存放區上的路徑。

傳回類型

str