PolicyEngine / policyengine-uk

The UK's only open-source static tax-benefit microsimulation model.
https://policyengine.github.io/policyengine-uk/
GNU Affero General Public License v3.0
23 stars 24 forks source link

Attempting to use `policyengine-uk` code in Colab notebook throws fetch error #828

Open anth-volk opened 4 months ago

anth-volk commented 4 months ago

When attempting to use code from policyengine-uk in a Colab notebook or other Python platform, the code raises the following error:

---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

[<ipython-input-4-c88b9fc1a9ef>](https://localhost:8080/#) in <cell line: 20>()
     18     def apply(self):
     19         self.modify_parameters(modify_parameters)
---> 20 baseline = Microsimulation()
     21 reformed = Microsimulation(reform=reform)
     22 baseline_person = baseline.calc("household_net_income",

3 frames

[/usr/local/lib/python3.10/dist-packages/policyengine_core/data/dataset.py](https://localhost:8080/#) in download(self, url)
    298             response = requests.get(url, headers=auth_headers)
    299             if response.status_code != 200:
--> 300                 raise ValueError(
    301                     f"Invalid response code {response.status_code} for url {url}."
    302                 )

ValueError: Invalid response code 404 for url https://api.github.com/repos/policyengine/non-public-microdata/releases/tags/uk-2023-dec-calibration.

This is almost certainly from the non-public microdata. Even so, this presents a confusing output to users who may have taken the code from the Reproduce in Python page of the app, so I feel it'd be a good idea to develop a strategy to dealing with this.