cancerDHC / example-data

This repository is intended to act as a store of example data files from across the NCI Cancer Research Data Commons (CRDC) nodes in a number of formats.
MIT License
0 stars 3 forks source link

Updated Pipfile to include `crdch-model` from PyPI #21

Closed gaurav closed 2 years ago

gaurav commented 2 years ago

When I discovered that PyPI generation in the ccdhmodel repo was broken (see https://github.com/cancerDHC/ccdhmodel/pull/122 for fix), I needed some way to test whether the PyPI package had been generated correctly. This PR replaces the included CRDC-H model with the Pipfile crdch-model downloaded from PyPI in the Python test file. Since this model has changed significantly from CRDC-H v1.0, this PR also changes the test to use CodeableConcepts instead of enumerations everywhere.

Note that installing numpy broke my Pipenv, so I've deleted pandas from the Pipfile. We'll need this for the Jupyter Notebook, so if we merge this, we'll need to open an issue to get the Jupyter Notebooks working again (#18 will help with that). It looks like @turbomam might be able to restore this, which would be great!

turbomam commented 2 years ago

added jupyter back to Pipfile

rm Pipfile.lock
pipenv --rm
pipenv install
pipenv shell
jupyter notebook

swapped import crdch_model as ccdh for from ccdh import ccdhmodel as ccdh at Loading the Python classes for the CCDH model

kernel -> Restart & Clear Output kernel -> Restart & Run All

no complaint about jupyter or numpy

now can import crdch_model but

AttributeError Traceback (most recent call last) /var/folders/vt/f297tpjn6n1b6dwkcwhhnmxm0000gp/T/ipykernel_8373/1901640063.py in 3 4 # Documentation for an entity. ----> 5 print(f"Documentation for Specimen: {ccdh.Specimen.doc}") 6 7 # Documentation for an enumeration. AttributeError: module 'crdch_model' has no attribute 'Specimen'

import inspect
inspect.getmembers(ccdh)

No mention of our expected classes like BodySite. For contrast, see inspect.getmembers(json). Not shown here.

[('builtins', {'name': 'builtins', 'doc': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the nil' object; Ellipsis represents...' in slices.", 'package': '', 'loader': _frozen_importlib.BuiltinImporter, 'spec': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'), 'build_class': <function build_class>, 'import': , 'abs': <function abs(x, /)>, 'all': <function all(iterable, /)>, 'any': <function any(iterable, /)>, 'ascii': <function ascii(obj, /)>, 'bin': <function bin(number, /)>, 'breakpoint': , 'callable': <function callable(obj, /)>, 'chr': <function chr(i, /)>, 'compile': <function compile(source, filename, mode, flags=0, dont_inherit=False, optimize=-1, , _feature_version=-1)>, 'delattr': <function delattr(obj, name, /)>, 'dir': , 'divmod': <function divmod(x, y, /)>, 'eval': <function eval(source, globals=None, locals=None, /)>, 'exec': <function exec(source, globals=None, locals=None, /)>, 'format': <function format(value, format_spec='', /)>, 'getattr': , 'globals': <function globals()>, 'hasattr': <function hasattr(obj, name, /)>, 'hash': <function hash(obj, /)>, 'hex': <function hex(number, /)>, 'id': <function id(obj, /)>, 'input': <bound method Kernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x1102183a0>>, 'isinstance': <function isinstance(obj, class_or_tuple, /)>, 'issubclass': <function issubclass(cls, class_or_tuple, /)>, 'iter': , 'len': <function len(obj, /)>, 'locals': <function locals()>, 'max': , 'min': , 'next': , 'oct': <function oct(number, /)>, 'ord': <function ord(c, /)>, 'pow': <function pow(base, exp, mod=None)>, 'print': , 'repr': <function repr(obj, /)>, 'round': <function round(number, ndigits=None)>, 'setattr': <function setattr(obj, name, value, /)>, 'sorted': <function sorted(iterable, /, , key=None, reverse=False)>, 'sum': <function sum(iterable, /, start=0)>, 'vars': , 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': bool, 'memoryview': memoryview, 'bytearray': bytearray, 'bytes': bytes, 'classmethod': classmethod, 'complex': complex, 'dict': dict, 'enumerate': enumerate, 'filter': filter, 'float': float, 'frozenset': frozenset, 'property': property, 'int': int, 'list': list, 'map': map, 'object': object, 'range': range, 'reversed': reversed, 'set': set, 'slice': slice, 'staticmethod': staticmethod, 'str': str, 'super': super, 'tuple': tuple, 'type': type, 'zip': zip, 'debug': True, 'BaseException': BaseException, 'Exception': Exception, 'TypeError': TypeError, 'StopAsyncIteration': StopAsyncIteration, 'StopIteration': StopIteration, 'GeneratorExit': GeneratorExit, 'SystemExit': SystemExit, 'KeyboardInterrupt': KeyboardInterrupt, 'ImportError': ImportError, 'ModuleNotFoundError': ModuleNotFoundError, 'OSError': OSError, 'EnvironmentError': OSError, 'IOError': OSError, 'EOFError': EOFError, 'RuntimeError': RuntimeError, 'RecursionError': RecursionError, 'NotImplementedError': NotImplementedError, 'NameError': NameError, 'UnboundLocalError': UnboundLocalError, 'AttributeError': AttributeError, 'SyntaxError': SyntaxError, 'IndentationError': IndentationError, 'TabError': TabError, 'LookupError': LookupError, 'IndexError': IndexError, 'KeyError': KeyError, 'ValueError': ValueError, 'UnicodeError': UnicodeError, 'UnicodeEncodeError': UnicodeEncodeError, 'UnicodeDecodeError': UnicodeDecodeError, 'UnicodeTranslateError': UnicodeTranslateError, 'AssertionError': AssertionError, 'ArithmeticError': ArithmeticError, 'FloatingPointError': FloatingPointError, 'OverflowError': OverflowError, 'ZeroDivisionError': ZeroDivisionError, 'SystemError': SystemError, 'ReferenceError': ReferenceError, 'MemoryError': MemoryError, 'BufferError': BufferError, 'Warning': Warning, 'UserWarning': UserWarning, 'DeprecationWarning': DeprecationWarning, 'PendingDeprecationWarning': PendingDeprecationWarning, 'SyntaxWarning': SyntaxWarning, 'RuntimeWarning': RuntimeWarning, 'FutureWarning': FutureWarning, 'ImportWarning': ImportWarning, 'UnicodeWarning': UnicodeWarning, 'BytesWarning': BytesWarning, 'ResourceWarning': ResourceWarning, 'ConnectionError': ConnectionError, 'BlockingIOError': BlockingIOError, 'BrokenPipeError': BrokenPipeError, 'ChildProcessError': ChildProcessError, 'ConnectionAbortedError': ConnectionAbortedError, 'ConnectionRefusedError': ConnectionRefusedError, 'ConnectionResetError': ConnectionResetError, 'FileExistsError': FileExistsError, 'FileNotFoundError': FileNotFoundError, 'IsADirectoryError': IsADirectoryError, 'NotADirectoryError': NotADirectoryError, 'InterruptedError': InterruptedError, 'PermissionError': PermissionError, 'ProcessLookupError': ProcessLookupError, 'TimeoutError': TimeoutError, 'open': <function io.open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)>, 'copyright': Copyright (c) 2001-2021 Python Software Foundation. All Rights Reserved.

Copyright (c) 2000 BeOpen.com. All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved., 'credits': Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object., 'execfile': <function _pydev_imps._pydev_execfile.execfile(file, glob=None, loc=None)>, 'runfile': <function _pydev_bundle.pydev_umd.runfile(filename, args=None, wdir=None, namespace=None)>, 'IPYTHON': True, 'display': <function IPython.core.display.display(*objs, include=None, exclude=None, metadata=None, transient=None, display_id=None, **kwargs)>, 'get_ipython': <bound method InteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x110247040>>}), ('cached', '/Users/MAM/.local/share/virtualenvs/example-data-WqQDUTxX/lib/python3.9/site-packages/crdch_model/pycache/init.cpython-39.pyc'), ('doc', None), ('file', '/Users/MAM/.local/share/virtualenvs/example-data-WqQDUTxX/lib/python3.9/site-packages/crdch_model/init.py'), ('loader', <_frozen_importlib_external.SourceFileLoader at 0x1102a7820>), ('name', 'crdch_model'), ('package', 'crdch_model'), ('path', ['/Users/MAM/.local/share/virtualenvs/example-data-WqQDUTxX/lib/python3.9/site-packages/crdch_model']), ('spec', ModuleSpec(name='crdch_model', loader=<_frozen_importlib_external.SourceFileLoader object at 0x1102a7820>, origin='/Users/MAM/.local/share/virtualenvs/example-data-WqQDUTxX/lib/python3.9/site-packages/crdch_model/init.py', submodule_search_locations=['/Users/MAM/.local/share/virtualenvs/example-data-WqQDUTxX/lib/python3.9/site-packages/crdch_model']))]

turbomam commented 2 years ago

I don't think @sujaypatil96's package has code in it either!

pip install ../sheet2linkml/dist/sheet2linkml-1.0.0-py3-none-any.whl`

then

import crdch_model
import inspect
inspect.getmembers(crdch_model)

[('doc', None), ('file', None), ('loader', <_frozen_importlib_external._NamespaceLoader object at 0x10bbb94f0>), ('name', 'crdch_model'), ('package', 'crdch_model'), ('path', _NamespacePath(['/usr/local/lib/python3.9/site-packages/crdch_model'])), ('spec', ModuleSpec(name='crdch_model', loader=<_frozen_importlib_external._NamespaceLoader object at 0x10bbb94f0>, submodule_search_locations=_NamespacePath(['/usr/local/lib/python3.9/site-packages/crdch_model'])))]

crdch_model.BodySite()

Traceback (most recent call last): File "", line 1, in AttributeError: module 'crdch_model' has no attribute 'BodySite'

turbomam commented 2 years ago

If you go back to importing from the local filesystem

from ccdh import ccdhmodel

RDFLib Version: 5.0.0

ccdhmodel.BodySite(site="Liver")

BodySite(site=(text='Liver', description='Liver'), qualifier=[])

gaurav commented 2 years ago

@turbomam Thanks for reviewing this PR! Do you have time to confirm that the updated Pipfile works as expected and delete rdflib-jsonld? If so, please feel free to approve this PR and then merge it in. Otherwise, I should be able to tackle this early next week.

turbomam commented 2 years ago

...and delete rdflib-jsonld

I don't think rdflib-jsonld is an explicit requirement of example-data. I'll check the dependency graph tomorrow.

turbomam commented 2 years ago

The jsonld warning happens right after g.parse(data=jsonld, format="json-ld"), not after any import. Merging now. Will determine options for avoiding warning tomorrow.