建立資料流程

最後一個步驟是在來源連線中所指定的資料集和目標連線中所指定的目的地檔案路徑之間建立資料流。

每種可用的雲端儲存型別都透過流量規格ID識別:

雲端儲存型別流量規格ID
Amazon S3269ba276-16fc-47db-92b0-c1049a3c131f
Azure Blob 儲存體95bd8965-fc8a-4119-b9c3-944c2c2df6d2
Azure資料湖17be2013-2549-41ce-96e7-a70363bec293
資料登陸區域cd2fc47e-e838-4f38-a581-8fff2f99b63a
Google Cloud Storage585c15c4-6cbf-4126-8f87-e26bff78b657
SFTP354d6aad-4754-46e4-a576-1b384561c440

下列程式碼會建立資料流程,其中排程設定為從遙遠的未來開始。 這可讓您在模型開發期間觸發隨機流程。 當您擁有受過訓練的模型後,您可以更新資料流的排程,以按照所需的排程共用功能資料集。

import time

on_schedule = False
if on_schedule:
    schedule_params = {
        "interval": 3,
        "timeUnit": "hour",
        "startTime": int(time.time())
    }
else:
    schedule_params = {
        "interval": 1,
        "timeUnit": "day",
        "startTime": int(time.time() + 60*60*24*365) # Start the schedule far in the future
    }

flow_spec_id = "cd2fc47e-e838-4f38-a581-8fff2f99b63a"
flow_obj = {
    "name": "Flow for Feature Dataset to DLZ",
    "flowSpec": {
        "id": flow_spec_id,
        "version": "1.0"
    },
    "sourceConnectionIds": [
        source_connection_id
    ],
    "targetConnectionIds": [
        target_connection_id
    ],
    "transformations": [],
    "scheduleParams": schedule_params
}
flow_res = flow_conn.createFlow(
    obj = flow_obj,
    flow_spec_id = flow_spec_id
)
dataflow_id = flow_res["id"]

建立資料流程後,您現在可以觸發隨機流程執行,以隨選共用功能資料集:

from aepp import connector

connector = connector.AdobeRequest(
  config_object=aepp.config.config_object,
  header=aepp.config.header,
  loggingEnabled=False,
  logger=None,
)

endpoint = aepp.config.endpoints["global"] + "/data/core/activation/disflowprovider/adhocrun"

payload = {
    "activationInfo": {
        "destinations": [
            {
                "flowId": dataflow_id,
                "datasets": [
                    {"id": created_dataset_id}
                ]
            }
        ]
    }
}

connector.header.update({"Accept":"application/vnd.adobe.adhoc.dataset.activation+json; version=1"})
activation_res = connector.postData(endpoint=endpoint, data=payload)
activation_res