QuantEcon / project.lecture-wasm

A project repository to test WASM compatibility and limitations for QuantEcon Lectures
https://quantecon.github.io/project.lecture-wasm/lab/index.html
0 stars 1 forks source link

Next Steps for WASM Project #13

Open mmcky opened 1 year ago

mmcky commented 1 year ago

WASM Project

Goal: Enable QuantEcon to make a decision to use or not to use WASM for Africa July 2023


Compile a report and for each issue we want to identify

Issue Description:

< Describe the issue found >

Issue Type: [Technical, User Facing]

Example Code Snippet:

< self contained code snippet that replicates the issue >

Suggested Solutions:

< list of possible solutions >


Smit-create commented 1 year ago

I'll try to write the report in this thread itself and edit it until we complete it.

Smit-create commented 1 year ago

business_cycle

Issue Description [Technical Issue]

There are two issues. The first one is minor which requires modifying the code and adding a single line: %pip install distutils. This fixes the following issue:

ModuleNotFoundError: The module 'distutils' is unvendored from the Python standard library in the Pyodide distribution.
You can install it by calling:
  await micropip.install("distutils") in Python, or
  await pyodide.loadPackage("distutils") in JavaScript
See https://pyodide.org/en/stable/usage/loading-packages.html for more details.

Once, that is fixed, there's another error arising from the following snippet:

>>> import wbgapi as wb
>>> wb.series.info(q='GDP growth')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[16], line 1
----> 1 wb.series.info(q='GDP growth')

TypeError: info() got an unexpected keyword argument 'q'

Suggested Solutions

One issue might be that it uses an older version. I tried fixing that by using %pip install wbgapi==1.0.12 that gave the following error:

File /lib/python3.11/site-packages/micropip/_micropip.py:373, in Transaction.check_version_satisfied(self, req)
    369 if req.specifier.contains(ver, prereleases=True):
    370     # installed version matches, nothing to do
    371     return True
--> 373 raise ValueError(
    374     f"Requested '{req}', " f"but {req.name}=={ver} is already installed"
    375 )

ValueError: Requested 'wbgapi==1.0.12', but wbgapi==1.1.2 is already installed

I used 1.0.12 as it is the latest version according to https://pypi.org/project/wbgapi/ and is not sure how piplite finds version 1.1.2.

Smit-create commented 1 year ago

commod_price

Issue Description [Technical Issue]

The issue is that the yfinance package is unable to download data. The following cell reproduces the error:

import yfinance as yf
s = yf.download('CT=F', '2016-1-1', '2023-4-1')['Adj Close']

And throws the following error:

[*********************100%***********************]  1 of 1 completed

1 Failed download:
- CT=F: No timezone found, symbol may be delisted

The version installed in pyodide is '0.2.18'.

I verified by installing the same version of yfinance on my local machine and that worked perfectly.

Suggested Solution

It might be good to look into the issue if we can download data or not.

Smit-create commented 1 year ago

heavy_tails & inequality

Issue Description [Technical Issue]

There are 3 primary issues in the lecture.

  1. pip install fails with the --upgrade flag and the fix is easy i.e. to drop the --upgrade flag.
  2. pip install fails for interpolation package, and throws the following error:
    ValueError: Requested 'packaging<22.0,>=21.3', but packaging==23.0 is already installed
  3. pip install fails for quantecon: #15
Smit-create commented 1 year ago

lake_model & markov_chains_I & markov_chains_II & networks

Issue Description [Technical Issue]

Installation of graphviz does work fine but that's not enough to provide its support. It requires explicit installation apart from pip install like the one here: https://github.com/QuantEcon/lecture-python-intro/pull/171.

Suggested Solution

It was discussed that probably the best way to tackle this is to drop graphviz and use static images instead. See: https://github.com/QuantEcon/lecture-python-intro/issues/186

Smit-create commented 1 year ago

lln_clt

Issue Description [Technical Issue]

  1. There are some code cells that take so long to run:

    >>> import scipy.stats as st
    >>> means_violin_plot(st.norm(loc=5, scale=2))   # takes 50 seconds to complete.
    >>> means_violin_plot(st.beta(6, 6))  # takes 2m 27 seconds to complete.
  2. There is a memory error using the following code snippet:

    
    # Set parameters
    n = 250         # Choice of n
    k = 1_000_000        # Number of draws of Y_n
    distribution = st.expon(2) # Exponential distribution, λ = 1/2
    μ, σ = distribution.mean(), distribution.std()

Draw underlying RVs. Each row contains a draw of X_1,..,X_n

data = distribution.rvs((k, n))

Error:
```console
MemoryError: Unable to allocate 1.86 GiB for an array with shape (1000000, 250) and data type float64

Suggested Solution

It might be good to use smaller dimensions to reduce the computations. I tried to fix 2nd issue with k = 10000 and that worked fine.

Smit-create commented 1 year ago

long_run_growth

Issue Description [Technical Issue] / Easy Fix

There's an error while executing the following code cell:

data = pd.read_excel("datasets/mpd2020.xlsx", sheet_name='Full data')
data

Error:

ImportError: Missing optional dependency 'openpyxl'.  Use pip or conda to install openpyxl.

Suggested Solution

The fix is easy. It requires to include the following code cell at the top:

%pip install openpyxl

Once we add this, the whole lecture works fine.

Smit-create commented 1 year ago

lp_intro

Issue Description [Technical Issue]

Installing ortools throws an error with %pip install ortools:

ValueError: Can't find a pure Python 3 wheel for 'ortools'.
See: https://pyodide.org/en/stable/usage/faq.html#micropip-can-t-find-a-pure-python-wheel
You can use `micropip.install(..., keep_going=True)`to get a list of all packages with missing wheels.

Suggested Solution

The fix is a tough one. We can't find a pure Python wheel of ortools as it just has a Python API for performance reasons and the lecture has a major dependency on ortools. We might probably need to drop ortools.

Smit-create commented 1 year ago

prob_dist

Issue Description [Technical Issue]

  1. First issue is a simple one which includes removing --upgrade flag from pip and also install seaborn. So the following line fixes everything:

    %pip install yfinance seaborn
  2. Another issue is that yfinance is unable to download the data, see the following cell:

    import yfinance as yf
    df = yf.download('AMZN', '2000-1-1', '2023-1-1', interval='1mo' )

    This outputs:

    
    [*********************100%***********************]  1 of 1 completed

1 Failed download: