NASA-Openscapes / earthdata-cloud-cookbook

A tutorial book of workflows for research using NASA EarthData in the Cloud created by the NASA-Openscapes team
https://nasa-openscapes.github.io/earthdata-cloud-cookbook
Other
83 stars 30 forks source link

Add External notebooks #221

Open mjami00 opened 1 year ago

mjami00 commented 1 year ago

There are couple of issues with current workflow for adding remote resources:

  1. when I try to add my external notebooks, the workflow pull other existing notebooks listed in "assets.json" again.
  2. when ran the "python quarto_import.py -f assets.json" to add my notebook, and it failed with the error added below.
Traceback (most recent call last):
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/nbformat/__init__.py", line 138, in read
buf = fp.read()
AttributeError: 'str' object has no attribute 'read'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/ipython_genutils/ipstruct.py", line 132, in __getattr__
result = self[key]
KeyError: 'cells'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "quarto_import.py", line 74, in <module>
result = main(assets)
File "quarto_import.py", line 58, in main
process_document(document)
File "quarto_import.py", line 49, in process_document
inject_content(preamble_cell, local_target)
File "quarto_import.py", line 25, in inject_content
nb = nbf.read(f'{IMPORTED_PATH}/{notebook}', as_version=4)
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/nbformat/__init__.py", line 141, in read
return reads(f.read(), as_version, **kwargs)
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/nbformat/__init__.py", line 75, in reads
nb = convert(nb, as_version)
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/nbformat/converter.py", line 46, in convert
converted = convert_function(nb)
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/nbformat/v2/convert.py", line 41, in upgrade
for cell in nb.cells:
File "/srv/conda/envs/quarto-import/lib/python3.8/site-packages/ipython_genutils/ipstruct.py", line 134, in __getattr__
raise AttributeError(key)
AttributeError: cells

I got the same error when I deleted all the items in assets.json and only kept @betolink, could you please provide some feedback on the issue we are experiencing here?

mjami00 commented 1 year ago

I could make this work part of another branch - https://github.com/NASA-Openscapes/earthdata-cloud-cookbook/tree/mahsa_AddExternalResources - I removed the nbformat from "environment.yml" and set the "process" fields to false for all the assets in "assets.json" @stefaniebutland

stefaniebutland commented 1 year ago

Will that affect future Cookbook stuff if that's removed in main? I tagged you in an update in Slack

mjami00 commented 1 year ago

One more thing needed to be updated was the URL that needed to be link to raw content. for some reason, I was not able to get raw content for https://github.com/nasa/AppEEARS-Data-Resources/blob/main/Python/tutorials/COG_AppEEARS_S3_Direct_Access.ipynb. SO I did not add that one.

mjami00 commented 1 year ago

Here is the pull request: https://github.com/NASA-Openscapes/earthdata-cloud-cookbook/pull/222

stefaniebutland commented 1 year ago

Thank you Mahsa! It's live in the Cookbook now. I'll leave this issue open till I've ensured the documentation is clear on how to do this