How to use the numerapi.utils.ensure_directory_exists function in numerapi

To help you get started, we’ve selected a few numerapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uuazed / numerapi / tests / test_utils.py View on Github external
def test_ensure_directory_exists(tmpdir):
    path = str(tmpdir.join("somedirectory"))
    utils.ensure_directory_exists(path)
    assert os.path.exists(path)
    # doing it again with the same (existing) path
    utils.ensure_directory_exists(path)
    assert os.path.exists(path)
github uuazed / numerapi / tests / test_utils.py View on Github external
def test_ensure_directory_exists(tmpdir):
    path = str(tmpdir.join("somedirectory"))
    utils.ensure_directory_exists(path)
    assert os.path.exists(path)
    # doing it again with the same (existing) path
    utils.ensure_directory_exists(path)
    assert os.path.exists(path)
github uuazed / numerapi / numerapi / numerapi.py View on Github external
def _unzip_file(self, src_path, dest_path, filename):
        """unzips file located at src_path into destination_path"""
        self.logger.info("unzipping file...")

        # construct full path (including file name) for unzipping
        unzip_path = os.path.join(dest_path, filename)
        utils.ensure_directory_exists(unzip_path)

        # extract data
        with zipfile.ZipFile(src_path, "r") as z:
            z.extractall(unzip_path)

        return True
github uuazed / numerapi / numerapi / numerapi.py View on Github external
round_number = self.get_current_round(tournament)
            except ValueError:
                round_number = "x"
            dest_filename = "numerai_dataset_{0}.zip".format(round_number)
        else:
            # ensure it ends with ".zip"
            if unzip and not dest_filename.endswith(".zip"):
                dest_filename += ".zip"
        dataset_path = os.path.join(dest_path, dest_filename)

        if os.path.exists(dataset_path):
            self.logger.info("target file already exists")
            return dataset_path

        # create parent folder if necessary
        utils.ensure_directory_exists(dest_path)

        url = self.get_dataset_url(tournament)
        utils.download_file(url, dataset_path, self.show_progress_bars)

        # unzip dataset
        if unzip:
            # remove the ".zip" in the end
            dataset_name = dest_filename[:-4]
            self._unzip_file(dataset_path, dest_path, dataset_name)

        return dataset_path