linkml icon indicating copy to clipboard operation
linkml copied to clipboard

Module failures when running examples notebook

Open wdduncan opened this issue 6 years ago • 9 comments

When running the examples.ipynb notebook, it failed to successfully load the as_json_obj and the yamlmagic would not work correctly. Specifically:

import jsonasobj.as_json_obj ## ERROR: I'm getting error  No module named 'jsonasobj.as_json_obj'

and

%%yaml --loader DupCheckYamlLoader yaml

## ERROR: running this cell produces 2 errors: 
## 1. Javascript Error: require is not defined
## 2. File "<ipython-input-3-f6f890ca4330>", line 4
##    id: http://example.org/sample/example1
            ^
## SyntaxError: invalid syntax

I order to work around these errors I had to make a number of changes. I am attaching my notebook exapmple-debug.ipynb (in a zip file) to show how I did this. Comment marked ## ERROR: show where I had issues.

examples-debug.ipynb.zip

wdduncan avatar Nov 29 '19 15:11 wdduncan

can you clarify, did you run the necessary install steps?

cmungall avatar Jun 08 '20 04:06 cmungall

Steps:

  • install a venv: python -m venv .env
  • activate the venv
  • install requirement.txt
  • run jupyter lab
  • within jupyter lab, open and run examples.ipynb

This results in the error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-f82244ba019b> in <module>
      2 from types import ModuleType
      3 from json import loads, dumps
----> 4 from jsonasobj import JsonObj, as_json_object
      5 from rdflib import Graph
      6 

ImportError: cannot import name 'as_json_object' from 'jsonasobj' (/Users/wdduncan/opt/anaconda3/lib/python3.7/site-packages/jsonasobj/__init__.py)

To fix (locally) I changed import JsonObj, as_json_object to import JsonObj, as_json_obj. image

And I had to changes call to as_json_object to as_json_obj image

However, this now causes and error with rdflib.graph() because the variable jsonld is a dict:

TypeError: a bytes-like object is required, not 'dict'

image

To fix this, I used json.dumps() to convert the jsonld dict into a json string: image

wdduncan avatar Mar 05 '21 14:03 wdduncan

Another error ....
Cell magic %%yaml --loader DupCheckYamlLoader yaml to work I had to remove the --loader DupCheckYamlLoader yaml image

I also get this strange error Javascript Error: require is not defined: image

wdduncan avatar Mar 05 '21 14:03 wdduncan

can we close this?

cmungall avatar Jun 15 '21 19:06 cmungall

I don't know. Do the errors occur when running the new linkml? I'd have to run the notebook to find out ...

wdduncan avatar Jun 16 '21 19:06 wdduncan

Cataloging errors as I attempt to run examples.ipynb.
Setup before running:

  • created a virtual environment: python -m venv .env
  • installed both the requirements.txt and requirements-dev.txtfiles usingpip`.

I get the error: ModuleNotFoundError: No module named 'linkml.dumpers'

image

wdduncan avatar Jun 16 '21 20:06 wdduncan

dumpers have moved to linkml-runtime. I'd forgotten that we'd turned off the notebooks test case, so apologies for missing this. Will turn it back on (for some reason I can't get it to work in the github actions...) and update and submit the changes.

Thanks for catching this!

hsolbrig avatar Jun 17 '21 13:06 hsolbrig

Can this be closed?

nlharris avatar Aug 15 '23 04:08 nlharris

no, the notebook needs fixed, and more broadly we need a strategy for notebooks. Either get rid of them or commit to keeping them complete and informative, use papermill + CI to check

cmungall avatar Nov 10 '23 22:11 cmungall

Are we keeping the notebooks?

nlharris avatar Oct 10 '25 00:10 nlharris