Пример #1
0
    def _test_checksums(self):
        # If no call to `dl_manager.download`, then no need to check url presence.
        if not self._download_urls:
            return

        err_msg = ("If you are developping outside TFDS and want to opt-out, "
                   "please add `SKIP_CHECKSUMS = True` to the "
                   "`DatasetBuilderTestCase`")

        url_infos = self.DATASET_CLASS.url_infos
        if url_infos is None:
            filepath = os.path.join(checksums._get_path(self.builder.name))  # pylint: disable=protected-access
            with utils.try_reraise(suffix=err_msg):
                url_infos = checksums._get_url_infos(filepath)  # pylint: disable=protected-access
        else:
            # TODO(tfds): Improve doc for dataset-as-folder (and remove
            # try_reraise above)
            filepath = str(self.DATASET_CLASS.code_path.parent /
                           "checksums.tsv")

        missing_urls = self._download_urls - set(url_infos.keys())
        self.assertEmpty(
            missing_urls, "Some urls checksums are missing at: {} "
            "Did you forget to record checksums with `--register_checksums` ? "
            "See instructions at: "
            "https://www.tensorflow.org/datasets/add_dataset#2_run_download_and_prepare_locally"
            "\n{}".format(filepath, err_msg))
Пример #2
0
    def _test_checksums(self):
        # If no call to `dl_manager.download`, then no need to check url presence.
        if not self._download_urls:
            return

        err_msg = ("If you are developping outside TFDS and want to opt-out, "
                   "please add `SKIP_CHECKSUMS = True` to the "
                   "`DatasetBuilderTestCase`")

        with utils.try_reraise(suffix=err_msg):
            filepath = os.path.join(checksums._get_path(self.builder.name))  # pylint: disable=protected-access
            sizes_checksums = checksums._get_sizes_checksums(filepath)  # pylint: disable=protected-access
            urls = sizes_checksums.keys()

        missing_urls = self._download_urls - set(urls)
        self.assertEmpty(
            missing_urls, "Some urls checksums are missing at: {} "
            "Did you forgot to record checksums with `--register_checksums` ? "
            "See instructions at: "
            "https://www.tensorflow.org/datasets/add_dataset#2_run_download_and_prepare_locally"
            "\n{}".format(filepath, err_msg))