PolicyEngine / policyengine-us

The PolicyEngine US Python package contains a rules engine of the US tax-benefit system, and microdata generation for microsimulation analysis.
https://policyengine.org/us
GNU Affero General Public License v3.0
100 stars 174 forks source link

Windows test_microsim.py error on GitHub #2062

Closed martinholmer closed 1 year ago

martinholmer commented 1 year ago

@nikhilwoodruff, Why is this Window error happening on GitHub? I don't get this error locally on a Mac.

policyengine_us\tests\microsimulation\test_microsim.py F                 [ 99%]
policyengine_us\tests\microsimulation\data\test_imports.py ..            [ 99%]
policyengine_us\tests\microsimulation\data\cps\test_cps.py ss            [100%]

================================== FAILURES ===================================
___________________________ test_microsim_runs_cps ____________________________

    def test_microsim_runs_cps():
        from policyengine_us import Microsimulation

>       sim = Microsimulation()

policyengine_us\tests\microsimulation\test_microsim.py:4: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\policyengine_core\simulations\simulation.py:134: in __init__
    self.dataset: Dataset = dataset()
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\policyengine_core\data\dataset.py:71: in __init__
    self.download()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <policyengine_us.data.datasets.cps.uprated_cps.UpratedCPS.from_dataset.<locals>.UpratedCPSFromDataset object at 0x0000023DE82A0C40>
url = 'https://api.github.com/repos/PolicyEngine/policyengine-us/releases/assets/101541472'

    def download(self, url: str = None):
        """Downloads a file to the dataset's file path.

        Args:
            url (str): The url to download.
        """

        if url is None:
            url = self.url

        if "POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN" not in os.environ:
            response = requests.get(
                url,
                headers={"Accept": "application/octet-stream"},
            )
        else:
            # Download from GitHub using a personal access token
            response = requests.get(
                url,
                headers={
                    "Authorization": f"token {os.environ['POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN']}",
                    "Accept": "application/octet-stream",
                },
            )

        if response.status_code != 200:
>           raise ValueError(
                f"Invalid response code {response.status_code} for url {url}."
            )
E           ValueError: Invalid response code 403 for url https://api.github.com/repos/PolicyEngine/policyengine-us/releases/assets/101541472.

C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\policyengine_core\data\dataset.py:288: ValueError
=========================== short test summary info ===========================
FAILED policyengine_us/tests/microsimulation/test_microsim.py::test_microsim_runs_cps
================== 1 failed, 1303 passed, 7 skipped in 9.10s ==================
mingw32-make: *** [makefile:11: test] Error 1
nikhilwoodruff commented 1 year ago

Sorry could you point to where this happens? Just looked at your North Dakota PR and all the tests seem to pass there?

martinholmer commented 1 year ago

Happened late yesterday in PR #2030.

martinholmer commented 1 year ago

Seems to be not happening now.