Closed joeflack4 closed 3 years ago
@wdduncan For your reference.
@wdduncan Should be fixed now. Give it a go!
As for what I did, we were a bit too hasty at first with our conclusion. It wasn't that %s
functionality was broken with the enhanced_str
class. We were just looking at the wrong line in the stack trace. We should have looked at:
TypeError: Values of type <class 'linkml_runtime.utils.yamlutils.extended_str'> are not supported
instead of:
raise TypeError(“Values of type %s are not supported” % type(value))
Here's the fix. Basically we had already been converting the YAMLRoot
version of the model into a dict
. I converted all instances of enhanced_str
to str
by doing json.loads(json.dumps())
.
model: YAMLRoot = yaml_loader.loads(yaml, target_class=YAMLRoot)
native_class_dict: Dict = model.classes._as_dict
standard_class_dict: Dict = json.loads(json.dumps(native_class_dict)) # <------
class_values = standard_class_dict.values()
for cls in class_values:
...
Description
When running
python -m ccdh.importers.importer
, there is an error.Related issues
https://github.com/py2neo-org/interchange/issues/4 https://github.com/linkml/linkml-runtime/issues/64 https://github.com/cancerDHC/ccdh-terminology-service/issues/115
Error messages
Short err
Long err
Source of issue
1. First thesis
_Edit: We were looking at the wrong error line. This isn't a
%s
issue; this is anextended_str
and Neo4J issue_ ~The Neo4J lib is trying to import data, and it is trying to do some string interpolation using%s
, but the strings that it is trying to do this on are actually of a special LinkML class calledextended_str
which has multiple inheritance w/ bothstr
and another LinkML class calledTypedNode
.~~If I had to guess, something broke during inheritance where the functionality that controls
%s
(would it be the__str__()
method?) broke.~2. Second thesis
Neo4J seems to reject
extended_str
.Possible solutions
1. Rollback LinkML versions (temporary)
This is a temporary solution, because ideally I think we want to be kept up-to-date with the latest LinkML versions. Theoretically, we should be able to use the last stable LinkML versions, but I have thus far not had success here.
I looked on the live server where terminology.ccdh.io is hosted, and checked versions used:
Then, in my local installation of the terminology service, I uninstalled
linkml
andlinkml_runtime
and modifiedrequirements.txt
to use these versions. However, surprisingly there was a dependency mismatch conflict, and pip was unable to install the versions I requested based on thelinkml_runtime
versions required by the corresponding versions oflinkml
that I was trying to install. I tried several different combinations; here are the results from just two of the attempts:This is pretty surprising. I'm not 100% sure what the source of the issue is, but the first thing that comes to mind is that the packages on PyPi for these given versions are not actually those that existed before when this is working for us. That is, my guess is that it's possible that the versions we were using were deleted from PyPi and then updated versions of the packages were re-uploaded under those same version numbers. This would explain why we were able to install this combination of versions before and why we're not able to do so now. But maybe there is some other explanation.
2. Update
linkml_runtime
We could fix the issue at the source. First we have to identify the actual source of the issue, be it in
enhanced_str
,TypedNode
, or otherwise.3. Wrap around
linkml_runtime
classesWe could make a custom class that inherits around
yaml_loader
or other classes, and then see if we can override whatever is breaking%s
and fix it there. And then we use that custom class(s) instead.4. Modify or create new object based on obj returned from
yaml_loader
We can recurse through the object returned by the
yaml_loader
and make fixes necessary. This could potentially be as simple as doingstr(enhanced_str_variable)
for every nested instance ofenhanced_str
in the object.5. Neo4J compatibility
Any way to get Neo4J to accept
enhanced_str
?