diff --git a/docs/rtd-requirements.txt b/docs/rtd-requirements.txt index 585ea0a78..1553879f6 100644 --- a/docs/rtd-requirements.txt +++ b/docs/rtd-requirements.txt @@ -4,6 +4,5 @@ numpydoc numba>=0.49 numpy>=1.17 scipy>=1.5 -requests matplotlib sphinx_rtd_theme diff --git a/environment.yml b/environment.yml index 6d73df565..e21a1e3df 100644 --- a/environment.yml +++ b/environment.yml @@ -11,7 +11,6 @@ dependencies: - numba>=0.62 - ipython - flake8 - - requests - urllib3>=2 - flit - chardet # python>3.9,osx diff --git a/environment_np2.yml b/environment_np2.yml index d5943811b..a34c6f2b2 100644 --- a/environment_np2.yml +++ b/environment_np2.yml @@ -13,7 +13,6 @@ dependencies: - numba=0.68.0rc1 - ipython - flake8 - - requests - urllib3>=2 - flit - chardet # python>3.9,osx diff --git a/pyproject.toml b/pyproject.toml index 5cded3581..1f6426637 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,6 @@ requires-python = ">=3.12" dependencies = [ 'numba>=0.56.0', 'numpy>=1.17.0', - 'requests', 'scipy>=1.5.0', ] diff --git a/quantecon/__init__.py b/quantecon/__init__.py index 424fb3618..e2afa227f 100644 --- a/quantecon/__init__.py +++ b/quantecon/__init__.py @@ -53,5 +53,5 @@ #<- from ._rank_nullspace import rank_est, nullspace from ._robustlq import RBLQ -from .util import searchsorted, index_dict, fetch_nb_dependencies, \ +from .util import searchsorted, index_dict, \ tic, tac, toc, Timer, timeit diff --git a/quantecon/tests/test_docstring_examples.py b/quantecon/tests/test_docstring_examples.py index a7f3d443b..8f8e849a3 100644 --- a/quantecon/tests/test_docstring_examples.py +++ b/quantecon/tests/test_docstring_examples.py @@ -29,10 +29,7 @@ import quantecon -# `fetch_nb_dependencies` fetches over the network, so its example cannot -# run offline. The module is deprecated and is removed in v1.0 (gh-880), -# which retires this entry with it. -SKIP_MODULES = {'quantecon.util.notebooks'} +SKIP_MODULES = set() def _collect_doctests(): diff --git a/quantecon/util/__init__.py b/quantecon/util/__init__.py index 489cacdcb..b9872a466 100644 --- a/quantecon/util/__init__.py +++ b/quantecon/util/__init__.py @@ -5,6 +5,5 @@ from .array import searchsorted from .indexing import index_dict -from .notebooks import fetch_nb_dependencies from .random import check_random_state, rng_integers from .timing import tic, tac, toc, loop_timer, Timer, timeit diff --git a/quantecon/util/notebooks.py b/quantecon/util/notebooks.py deleted file mode 100644 index 5dc60e51d..000000000 --- a/quantecon/util/notebooks.py +++ /dev/null @@ -1,118 +0,0 @@ -""" -Support functions to Support QuantEcon.notebooks - -The purpose of these utilities is to implement simple support functions to allow for automatic downloading -of any support files (python modules, or data) that may be required to run demonstration notebooks. - -Note ----- -Files on the REMOTE Github Server can be organised into folders but they will end up at the root level of -when downloaded as a support File - -"https://github.com/QuantEcon/QuantEcon.notebooks/raw/master/dependencies/mpi/something.py" --> ./something.py - -TODO ----- -1. Write Style guide for QuantEcon.notebook contributions -2. Write an interface for Dat Server -3. Platform Agnostic (replace wget usage) - -""" - -import os - -#-Remote Structure-# -REPO = "https://github.com/QuantEcon/QuantEcon.notebooks" -RAW = "raw" -BRANCH = "master" -#Hard Coded Dependencies Folder on QuantEcon.notebooks -FOLDER = "dependencies" - - -def fetch_nb_dependencies(files, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDER, overwrite=False, verbose=True): - """ - Retrieve raw files from QuantEcon.notebooks or other Github repo - - Parameters - ---------- - files : list or dict - A list of files to specify a collection of filenames, or a dict of - dir : list(files) to specify a directory - repo : str, optional(default=REPO) - The Github repository to fetch the files from - raw : str, optional(default=RAW) - This is here in case github changes access to their raw files through - web links - branch : str, optional(default=BRANCH) - The branch of the repository to fetch the files from - folder : str, optional(default=FOLDER) - The folder in the repository that contains the requested files - overwrite : bool, optional(default=False) - If True, overwrite a local copy of the file if one is present - verbose : bool, optional(default=True) - If True, then print a status message for each requested file - - Returns - ------- - status : list of bool - One entry per requested file: True if the file was downloaded, and - False if a local copy was found and the download was skipped - - Examples - -------- - Consider a notebook that is dependant on a ``csv`` file to execute. If this file is - located in a Github repository then it can be fetched using this utility - - Assuming the file is at the root level in the ``master`` branch then: - - >>> from quantecon.util import fetch_nb_dependencies - >>> status = fetch_nb_dependencies(["test.csv"], repo="https://") - - More than one file may be requested in the list provided - - >>> status = fetch_nb_dependencies(["test.csv", "data.csv"], repo="https://") - - A folder location can be added using ``folder=`` - - >>> status = fetch_nb_dependencies(["test.csv"], repo="https://", folder="data") - - You can also specify a specific branch using ``branch=`` keyword argument. - - This will download the requested file(s) to your local working directory. The default - behaviour is **not** to overwrite a local file if it is present. This can be switched off - by setting ``overwrite=True``. - - """ - import requests - - #-Generate Common Data Structure-# - if isinstance(files, list): - files = {"" : files} - - status = [] - - #-Obtain each requested file-# - for directory in files.keys(): - if directory != "": - if verbose: print("Parsing directory: %s"%directory) - for fl in files[directory]: - if directory != "": - fl = directory+"/"+fl - #-Check for Local Copy of File (Default Behaviour is to Skip)-# - if not overwrite: - if os.path.isfile(fl): - if verbose: print( - "A file named %s already exists in the specified directory ... skipping download." % fl) - status.append(False) - continue - else: - if verbose: print("Overwriting file %s ..."%fl) - if verbose: print("Fetching file: %s"%fl) - #-Get file in OS agnostic way using requests-# - url = "/".join([repo, raw, branch, folder, fl]) - r = requests.get(url) - with open(fl, "wb") as fl: - fl.write(r.content) - status.append(True) - - return status diff --git a/quantecon/util/tests/test_file.md b/quantecon/util/tests/test_file.md deleted file mode 100644 index 3ec45702f..000000000 --- a/quantecon/util/tests/test_file.md +++ /dev/null @@ -1 +0,0 @@ -This is a Simple Test File for test_notebooks.py \ No newline at end of file diff --git a/quantecon/util/tests/test_notebooks.py b/quantecon/util/tests/test_notebooks.py deleted file mode 100644 index 56d0b195e..000000000 --- a/quantecon/util/tests/test_notebooks.py +++ /dev/null @@ -1,41 +0,0 @@ -""" -Tests for Notebook Utilities - -Functions ---------- -fetch_nb_dependencies - -""" - -from quantecon.util import fetch_nb_dependencies -import os - -FILES = ['test_file.md'] -REPO = "https://github.com/QuantEcon/QuantEcon.py" -RAW = "raw" -BRANCH = "main" -FOLDER = "quantecon/util/tests/" - - -class TestNotebookUtils: - - def test_fetch_nb_dependencies(self): - """ - Run First and Test Download - """ - status = fetch_nb_dependencies( - files=FILES, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDER) - assert(not (False in status)) - - def test_fetch_nb_dependencies_overwrite(self): - """ - Run Second and Ensure file is skipped by checking a False is found in status - """ - status = fetch_nb_dependencies( - files=FILES, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDER) #First will succeed - status = fetch_nb_dependencies( - files=FILES, repo=REPO, raw=RAW, branch=BRANCH, folder=FOLDER) #Second should skip - assert(False in status) - - def teardown_method(self): - os.remove("test_file.md")