【问题标题】:How can I roll-back a dataset transaction in Foundry?如何在 Foundry 中回滚数据集事务?
【发布时间】:2022-04-06 21:13:41
【问题描述】:

我在 Foundry 上有一个增量数据集,并且上传了一个包含不正确数据的文件。如何撤消此事务,以便使用正确的数据更新数据集?

【问题讨论】:

    标签: palantir-foundry


    【解决方案1】:

    您可以使用代工厂的目录 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"
    

    【讨论】:

      【解决方案2】:

      我做过的其他选择是:

      1. 使用轮廓抓取选择的交易并导出为 CSV,然后上传为静态数据集。
      2. 更新架构以确保它是所需的类型。
      3. 如果使用 @incremental 声明符,则转到增量代码并将输出数据帧的 set('modify') 更新为 set('replace')。
      4. 使用静态数据引用添加或替换输入引用。更新逻辑以引用输出的新输入。
      5. 构建数据集(这应该使用您的静态数据进行快照)
      6. 将代码改回修改并输入回原始参考和任何其他代码模式回原始。从那里开始的任何新构建都会增加您上次运行的快照。

      它可能不是很优雅,但已经做过很多次了。

      【讨论】:

        【解决方案3】:

        这里有一个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()
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-11-29
          • 1970-01-01
          • 1970-01-01
          • 2017-06-14
          • 2017-09-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多