【发布时间】:2022-04-06 21:13:41
【问题描述】:
我在 Foundry 上有一个增量数据集,并且上传了一个包含不正确数据的文件。如何撤消此事务,以便使用正确的数据更新数据集?
【问题讨论】:
标签: palantir-foundry
我在 Foundry 上有一个增量数据集,并且上传了一个包含不正确数据的文件。如何撤消此事务,以便使用正确的数据更新数据集?
【问题讨论】:
标签: palantir-foundry
您可以使用代工厂的目录 API。您首先需要找到要恢复到的事务的资源 id (rid),当您在 Monocle 中选择数据集时,可以在历史选项卡下找到它。 您还需要删除您的数据集,以及您在代工厂实例上生成的不记名令牌。 在 unix 命令行中运行以下命令,或者使用 python requests library。 (如果您在 Windows 机器上,请求库可能会很有用)
curl -X POST \
"https://<CATALOG_URL>/api/catalog/datasets/<DATASET_RID>/branchesUpdate2/master" \
-H "Authorization: Bearer <TOKEN>" \
-H "Content-type: application/json" \
-d '"'<TRANSACTION_RID>'"' \
-k \
-w "\n"
用您的相关变量替换 之间的内容,我在下面展示了一些示例,以便您在看到变量时识别它们。请务必对您的不记名令牌保密。
<CATALOG_URL> <- your.url.com/foundry-catalog
<DATASET_RID> <- ri.foundry.main.dataset.00000000-bbbb-cccc-dddd-000000000000
<TOKEN> <- ey00000000...00000000
<TRANSACTION_RID> <- "ri.foundry.main.transaction.00000000-bbbb-cccc-dddd-000000000000"
【讨论】:
我做过的其他选择是:
它可能不是很优雅,但已经做过很多次了。
【讨论】:
这里有一个python函数可以实现和FJ_OC的curl一样的例子:
from urllib.parse import quote_plus
import requests
def update_branch(dataset_rid: str,
branch: str,
parent_branch_or_transaction_rid: str = None,
api_base,
token) -> dict:
"""
Updates the latest transaction of branch 'branch' to the latest transaction
of branch 'parent_branch' OR to the transaction on the same branch given as parameter
Args:
dataset_rid: Unique identifier of the dataset
branch: The branch to update (e.g. master)
parent_branch_or_transaction_rid: the name of the branch to copy the last transaction
from or the transaction on the same branch to reset the dataset to
Returns: branch response, e.g.:
{'id': '..',
'rid': 'ri.foundry.main.branch...',
'ancestorBranchIds': [],
'creationTime': '',
'transactionRid': 'ri.foundry.main.transaction....'
}
"""
response = requests.post(f"{api_base}/foundry-catalog/api/catalog/datasets/{dataset_rid}/"
f"branchesUpdate2/{quote_plus(branch)}",
headers={'Content-Type': 'application/json', 'Authorization': f'Bearer {token}'},
data=f'"{parent_branch_or_transaction_rid}"'
)
response.raise_for_status()
return response.json()
【讨论】: