pysal / notebooks

jupyter/ipython notebooks demonstrating PySAL functionality
54 stars 38 forks source link

Move2lite #86

Closed darribas closed 4 years ago

darribas commented 4 years ago

This brings updated code and a new build of the notebooks based on 2.2. I think it's ready to merge although it has features that need to be ironed out/further tested:

In any case, I recommend this is merged because it improves notably what's live now at pysal.org/notebooks

jGaboardi commented 4 years ago

@darribas I am in the process of reviewing this PR at the moment, building locally, etc. Steps 1, 2, and 4 of the Build Process run without issue but with the python lib/build.py --test_run command I am getting the errors listed below (plus many more that are too numerous to put in here).

If we are considering doing the merge without addressing the cell failures, then I would say this PR is good to go, with one minor addition: Can we include the new version of the PySAL logo? Either the logo with text in the root, the logo with text outside the mindmap (1 line), or the logo with text outside the mindmap (2 lines). Also, how about including the new version of the favicon?


jupyter nbconvert --to markdown --stdout notebooks/explore/giddy/Rank_Markov_ergodic_morecomu.ipynb --execute

### Log Msg. ###
[NbConvertApp] Converting notebook notebooks/explore/giddy/Rank_Markov_ergodic_morecomu.ipynb to markdown
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] ERROR | Error while converting 'notebooks/explore/giddy/Rank_Markov_ergodic_morecomu.ipynb'
Traceback (most recent call last):
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 405, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 448, in preprocess_cell
    raise CellExecutionError.from_cell_and_msg(cell, out)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
print(*[], sep=", "
------------------

  File "<ipython-input-19-2accb83ae438>", line 1
    print(*[], sep=", "
                       ^
SyntaxError: unexpected EOF while parsing

SyntaxError: unexpected EOF while parsing (<ipython-input-19-2accb83ae438>, line 1)

jupyter nbconvert --to markdown --stdout notebooks/explore/pointpats/distance_statistics.ipynb --execute

### Log Msg. ###
[NbConvertApp] Converting notebook notebooks/explore/pointpats/distance_statistics.ipynb to markdown
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] ERROR | Timeout waiting for execute reply (30s).
Traceback (most recent call last):
  File "/Users/user/miniconda3/envs/env/bin/jupyter-nbconvert", line 11, in <module>
    sys.exit(main())
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 340, in start
    self.convert_notebooks()
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 510, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 481, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 405, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 438, in preprocess_cell
    reply, outputs = self.run_cell(cell, cell_index, store_history)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 571, in run_cell
    if self._passed_deadline(deadline):
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 541, in _passed_deadline
    self._handle_timeout()
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 504, in _handle_timeout
    raise TimeoutError("Cell execution timed out")
TimeoutError: Cell execution timed out

all spaghetti notebooks are getting the following

jupyter_client.kernelspec.NoSuchKernel: No such kernel named conda-env-py3_spgh_dev-py

jupyter nbconvert --to markdown --stdout notebooks/explore/segregation/decomposition_wrapper_example.ipynb --execute

### Log Msg. ###
[NbConvertApp] Converting notebook notebooks/explore/segregation/decomposition_wrapper_example.ipynb to markdown
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] ERROR | Error while converting 'notebooks/explore/segregation/decomposition_wrapper_example.ipynb'
Traceback (most recent call last):
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 405, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "/Users/user/miniconda3/envs/env/lib/python3.7/site-packages/nbconvert/preprocessors/execute.py", line 448, in preprocess_cell
    raise CellExecutionError.from_cell_and_msg(cell, out)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
df = pd.read_csv(filepath, encoding = "ISO-8859-1", sep = ",")
------------------

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-54196d375d4a> in <module>
----> 1 df = pd.read_csv(filepath, encoding = "ISO-8859-1", sep = ",")

NameError: name 'filepath' is not defined
NameError: name 'filepath' is not defined

Plus many more...

jGaboardi commented 4 years ago

See pysal/pysal.github.io#145 and pysal/pysal.github.io#146 after adding the new logo here.

darribas commented 4 years ago

Fantastic @jGaboardi, excellent idea, I'll add the new logos to this PR I think it makes sense. As for the running, my view is let's merge this, which improves on the current state that's live on the notebooks website, and then let's fix those. Several of those will probably need to be changed not in this repo but in the original sources (ie. each package) which will probably take a bit longer. I think there's value in having the book up to date online in the meantime.

jGaboardi commented 4 years ago

@darribas This sounds reasonable. Once the new logo/favicon are in the PR, let's merge.


EDIT 1: I propose we use the logo with text outside the mindmap (2 lines) since the PySAL acronym is not defined anywhere in the notebooks site. I will go ahead and push the new favicon and that version of the logo to this PR, then we can revert if it looks bad/people disagree.


EDIT 2: I just noticed the following comment regarding the logo in _config.yml:

# A logo to be displayed at the top of your textbook sidebar. Should be square

So I will push up the "traditional" mindmap logo with "PySAL" inside.

jGaboardi commented 4 years ago

@darribas I was having trouble pushing commits directly to this PR, so I opened a PR on this branch in your fork.

jGaboardi commented 4 years ago

OK, I worked out the issue I was having and was able to push my (updated) commits directly here.

knaaptime commented 4 years ago

probably something botched on my end, but its not pulling the docs folder so the build is failing for me

darribas commented 4 years ago

I've pushed the new logo/favicon to the source, need to rebuild

darribas commented 4 years ago

OK @jGaboardi this is good to go afaik!

@knaaptime I've updated the README.md with a bit more info to run it in a reproducible way. Shout if you run into issues!

jGaboardi commented 4 years ago

@darribas I accidentally merged... Shall I revert or leave as is?

darribas commented 4 years ago

That makes the new build live at: http://pysal.org/notebooks I think it looks good! There're things to improve on, but this is better than what we had, so I'd leave it?