InputPortBinding クラス

ソースからパイプライン ステップの入力へのバインドを定義します。

InputPortBinding は、ステップへの入力として使用できます。 ソースには、PipelineDataPortDataReferenceDataReferencePipelineDataset、または OutputPortBinding を指定できます。

InputPortBinding は、ステップ入力の名前をバインド オブジェクトの名前と異なるものにする必要がある場合 (入力および出力の名前の重複を避けるため、またはステップ スクリプトが特定の名前を持つ入力を必要とするために)、その名前を指定するために便利です。 また、PythonScriptStep 入力の bind_mode を指定するために使用できます。

InputPortBinding を初期化します。

継承
builtins.object
InputPortBinding

コンストラクター

InputPortBinding(name, bind_object=None, bind_mode='mount', path_on_compute=None, overwrite=None, is_resource=False, additional_transformations=None, **kwargs)

パラメーター

名前 説明
name
必須
str

バインドする入力ポートの名前。これには、文字、数字、アンダースコアのみを含めることができます。

bind_object

入力ポートにバインドするオブジェクト。

既定値: None
bind_mode
str

使用するステップが "download" または "mount" メソッドのどちらを使用してデータにアクセスするのかを指定します。

既定値: mount
path_on_compute
str

"download" モードの場合、ステップがデータを読み取るローカル パス。

既定値: None
overwrite

"download" モードの場合は、既存のデータを上書きするかどうかを示します。

既定値: None
is_resource

入力がリソースであるかどうかを示します。 リソースはスクリプト フォルダーにダウンロードされ、実行時にスクリプトの動作を変更する方法を提供します。

既定値: False
additional_transformations
<xref:azureml.dataprep.Dataflow>

入力に適用する追加の変換。 これは、前のステップの出力が Azure Machine Learning データセットである場合にのみ適用されます。

既定値: None
name
必須
str

バインドする入力ポートの名前。これには、文字、数字、アンダースコアのみを含めることができます。

bind_object
必須

入力ポートにバインドするオブジェクト。

bind_mode
必須
str

使用する手順で、データにアクセスするために "ダウンロード" または "マウント" メソッドまたは "ダイレクト" メソッドを使用するかどうかを指定します。

path_on_compute
必須
str

"download" モードの場合、ステップがデータを読み取るローカル パス。

overwrite
必須

"download" モードの場合は、既存のデータを上書きするかどうかを示します。

is_resource
必須

入力がリソースであるかどうかを示します。 リソースはスクリプト フォルダーにダウンロードされ、実行時にスクリプトの動作を変更する方法を提供します。

additional_transformations
必須
<xref:azureml.dataprep.Dataflow>

入力に適用する追加の変換。 これは、前のステップの出力が Azure Machine Learning データセットである場合にのみ適用されます。

注釈

InputPortBinding は、パイプライン内のデータの依存関係を指定するために使用されます。これは、ステップで実行のために必要な入力を表します。 InputPortBindings には、入力データの生成方法を指定する bind_object というソースがあります。

PipelineData および OutputPortBinding を InputPortBinding の bind_object として使用して、ステップへの入力が、パイプライン内の別のステップによって生成されるように指定することができます。

InputPortBinding と PipelineData を使用してパイプラインを作成する例を次に示します。


   from azureml.pipeline.core import PipelineData, InputPortBinding, Pipeline
   from azureml.pipeline.steps import PythonScriptStep

   step_1_output = PipelineData("output", datastore=datastore, output_mode="mount")

   step_1 = PythonScriptStep(
       name='prepare data',
       script_name="prepare_data.py",
       compute_target=compute,
       arguments=["--output", step_1_output],
       outputs=[step_1_output]
   )

   step_2_input = InputPortBinding("input", bind_object=step_1_output)

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

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

この例では、"train" ステップの入力として "prepare data" ステップの出力が必要となります。

PortDataReferenceDataReference、または PipelineDataset を InputPortBinding の bind_object として使用して、ステップへの入力が指定した場所に既に存在することを指定できます。

InputPortBinding と DataReference を使用してパイプラインを作成する例を次に示します。


   from azureml.data.data_reference import DataReference
   from azureml.pipeline.core import InputPortBinding, Pipeline
   from azureml.pipeline.steps import PythonScriptStep

   data_reference = DataReference(datastore=datastore, path_on_datastore='sample_data.txt', mode="mount")
   step_1_input = InputPortBinding("input", bind_object=data_reference)

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

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

この例では、"train" ステップの入力として、DataReference で指定した "sample_data.txt" ファイルが必要です。

メソッド

as_resource

リソースとして使用できる、重複する入力ポート バインドを取得します。

get_bind_object_data_type

バインド オブジェクトのデータ型を取得します。

get_bind_object_name

バインド オブジェクトの名前を取得します。

as_resource

リソースとして使用できる、重複する入力ポート バインドを取得します。

as_resource()

戻り値

説明

is_resource プロパティを True に設定した InputPortBinding。

get_bind_object_data_type

バインド オブジェクトのデータ型を取得します。

get_bind_object_data_type()

戻り値

説明
str

データ型名。

get_bind_object_name

バインド オブジェクトの名前を取得します。

get_bind_object_name()

戻り値

説明
str

バインド オブジェクト名。

属性

additional_transformations

入力データに適用する追加の変換を取得します。

戻り値

説明
<xref:azureml.dataprep.Dataflow>

入力データに適用する追加の変換。

bind_mode

使用するステップがデータにアクセスするために使用するモード ("download" または "mount" または "direct"、"hdfs") を取得します。

戻り値

説明
str

バインド モード ("download" または "mount" または "direct" または "hdfs")。

bind_object

InputPort がバインドされるオブジェクトを取得します。

戻り値

説明

バインド オブジェクト。

data_reference_name

InputPortBinding に関連付けられているデータ参照の名前を取得します。

戻り値

説明
str

データ参照名。

data_type

入力データの型を取得します。

戻り値

説明
str

データ型プロパティ。

is_resource

入力がリソースであるかどうかを取得します。

戻り値

説明

入力がリソースかどうか。

name

入力ポートのバインドの名前。

戻り値

説明
str

名前。

overwrite

"download" モードの場合は、既存のデータを上書きするかどうかを示します。

戻り値

説明

overwrite プロパティ。

path_on_compute

ステップがデータを読み取るローカル パスを取得します。

戻り値

説明
str

コンピューティング上のパス。