[英]passing the parameters from adf to notebook
我正在通過 api 調用獲取數據,並希望對widgets
進行參數化。 在 azure 中,我進行了以下設置:
我有attribute_code
的列表,使用lookup
活動讀取它們並將這些參數傳遞到數據塊筆記本代碼中。 數據塊中的代碼:
data, response = get_data_url(url=f"https://p.cloud.com/api/rest/v1/attributes/{attribute_code}/options",access_token=access_token)
#Removing the folder in Data Lake
dbutils.fs.rm(f'/mnt/bronze/attribute_code/{day}',True)
#Creating the folder in the Data Lake
dbutils.fs.mkdirs(f'/mnt/bronze/attribute_code/{day}')
count = 0
#Putting the response inside of the Data Lake folder
dbutils.fs.put(f'/mnt/bronze/attribute_code/{day}/data_{count}.json', response.text)
我的問題是,由於它在ForEach
循環中,每次傳遞新參數時,它都會刪除包含先前加載數據的整個文件夾。 現在有人可以說要刪除我放置的行並創建 spacific daily 文件夾,但管道應該每天運行多次,我需要在那天刪除以前加載的數據並加載新數據。
我的目標是迭代整個attribute_code
列表並將它們全部加載到一個名為“data_{count}.json”的文件夾中
除了在筆記本中使用dbutils.fs.rm
,您還可以對每個活動使用 delete activity before 以獲得所需的結果。
使用dbutils.fs.rm
,每次在內部觸發筆記本時都會刪除該文件夾,因為每個循環也會刪除以前創建的文件。
因此,僅在每個循環之前使用刪除活動來刪除文件夾(僅在存在時刪除),您可以根據需要加載數據。
attribute/@{formatDateTime(utcNow(),'yyyy-MM-dd')}
#I used similar code
data, response = get_data_url(url=f"https://p.cloud.com/api/rest/v1/attributes/{attribute_code}/options",access_token=access_token)
#Creating the folder in the Data Lake
dbutils.fs.mkdirs(f'/mnt/bronze/attribute_code/{day}')
count = 0
#Putting the response inside of the Data Lake folder
dbutils.fs.put(f'/mnt/bronze/attribute_code/{day}/data_{count}.json', response.text)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.