def wait_for_ingestion()

in webinars/snowflake_2021-09/finspace.py [0:0]


    def wait_for_ingestion(self, dataset_id: str, changeset_id: str, sleep_sec=10):
        """
        function that will continuously poll the changeset creation to ensure it completes or fails before returning.

        :param dataset_id: GUID of the dataset
        :type: str

        :param changeset_id: GUID of the changeset
        :type: str

        :param sleep_sec: seconds to wait between checks
        :type: int

        """
        while True:
            status = self.describe_changeset(dataset_id=dataset_id, changeset_id=changeset_id)['status']
            if status == 'SUCCESS':
                print(f"Changeset complete")
                break
            elif status == 'PENDING' or status == 'RUNNING':
                print(f"Changeset status is still PENDING, waiting {sleep_sec} sec ...")
                time.sleep(sleep_sec)
                continue
            else:
                raise Exception(f"Bad changeset status: {status}, failing now.")