Conversation
|
Please edit this to provide a proper title and description |
PeterC-DLS
left a comment
There was a problem hiding this comment.
Tree does not need to be so deep.
Remove the empty README.md.
code/nxsOnto/setup.py
Outdated
| packages=['nxsOnto'], | ||
| license='Apache 2', | ||
| install_requires=[ | ||
| "owlready2", |
There was a problem hiding this comment.
This duplicates requirements.txt so should read that file
code/nxsOnto/setup.py
Outdated
| version='1.1', | ||
| description='Generates an ontology from nxdl files', | ||
| author='Steve Collins', | ||
| url="https://github.com/nexusformat/NeXusOntology/script", |
There was a problem hiding this comment.
|
The README does not explicitly say how I run this and what the outcome is. |
PeterC-DLS
left a comment
There was a problem hiding this comment.
I've add more comments from #2
Also please delete the notebook.
code/nxsOnto/nxsOnto/generator.py
Outdated
| ''' | ||
|
|
||
| ''' | ||
| # To avoid re-parsing NeXus files after initial run, execute this |
There was a problem hiding this comment.
All of this is commented out code! Not sure why you want it too as you run this script once.
code/nxsOnto/nxsOnto/generator.py
Outdated
|
|
||
| base_class_url = [] | ||
| for file in repo.get_contents("base_classes"): | ||
| if str(file).split('.')[-2] == 'nxdl': |
There was a problem hiding this comment.
What if file name does not have two '.'?
code/nxsOnto/nxsOnto/generator.py
Outdated
|
|
||
| deprecationAttribute = field.getAttribute('deprecated') | ||
| if not deprecationAttribute == '': |
There was a problem hiding this comment.
Not a Pythonic way to test for an empty string
code/nxsOnto/nxsOnto/generator.py
Outdated
| deprecationAttribute = field.getAttribute('deprecated') | ||
| if not deprecationAttribute == '': | ||
| print("=== Deprecation warning %s in %s: %s" % (field_name, className, deprecationAttribute)) | ||
| print("=== Deprecation warning %s in %s: %s" % (field_name, className, deprecationAttribute)) |
code/nxsOnto/nxsOnto/generator.py
Outdated
| @@ -184,12 +175,12 @@ def addFieldToDict(classDict, field, defn_name): # make a function to be reused | |||
| #print('~~~ field did not exist: %s' % long_name) | |||
| classDict[className]['fields'][long_name] = {} # create dictionary for field if doesn't exist | |||
There was a problem hiding this comment.
Nicer to get the sub-dictionary classDict[className]['fields'] once rather than using the same copy and pasted expression. This applies for all dictionary access below too.
code/nxsOnto/nxsOnto/generator.py
Outdated
|
|
||
| class unitCategory(NeXus): | ||
| comment = 'NeXus unit category. Can be considered instances of a measure. Assign data properties ' 'hasValue(any), hasMinValue(any), hasMaxValue(any), hasUnits(str)' |
code/nxsOnto/nxsOnto/generator.py
Outdated
| base_class_url = [] | ||
| for file in repo.get_contents("base_classes"): | ||
| if str(file).split('.')[-2] == 'nxdl': | ||
| base_class_url += [file.download_url] |
| print("=== Deprecation warning %s in %s: %s" % (field_name, className, deprecationAttribute)) | ||
| print("=== Deprecation warning %s in %s: %s" % (field_name, className, deprecationAttribute)) | ||
|
|
||
| long_name = className + join_string + field_name |
code/nxsOnto/nxsOnto/generator.py
Outdated
| import json | ||
| import xml.dom.minidom | ||
| import pickle | ||
| from owlready2 import * |
code/nxsOnto/nxsOnto/generator.py
Outdated
| # create individuals - these are just for testing | ||
|
|
||
|
|
||
| with onto: |
There was a problem hiding this comment.
Test code should be in a separate function
#token = '' # insert your github token #out_path = 'ontology' #tmp_file_path = 'tmp'
Comment: #3 (comment)
Comment: #3 (comment)
|
Following the instructions in the README, I setup the conda environments and ran this code as instructed. Worked for me. Output text file was readable: (NeXusOntology) prjemian@zap:~/.../code/nxsOnto$ ll /tmp/onto/
total 904K
-rw-rw-r-- 1 prjemian prjemian 904K Dec 15 09:30 NeXusOntology.owlAside from this PR: Must add the font size of the Protege software running on Windows with a 4k monitor is much too small. Even setting the preference for larger font, still there is tiny text in the window corners that is unreadable. Not an issue for this PR to resolve. |
|
example: (NeXusOntology) prjemian@zap:/tmp/onto$ python -m nxsOnto.generator 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 /tmp/onto /tmp
Deprecation warning definition_local in NXentry: see same field in :ref:`NXsubentry` for preferred use
Deprecation warning average_value_error in NXlog: see: https://github.com/nexusformat/definitions/issues/639
Deprecation warning wavelength_error in NXmonochromator: see https://github.com/nexusformat/definitions/issues/820
Deprecation warning energy_error in NXmonochromator: see https://github.com/nexusformat/definitions/issues/820
Deprecation warning radiation in NXsource: Use either (or both) ``probe`` or ``type`` fields from ``NXsource`` (issue #765)
Deprecation warning incident_wavelength_weight in NXbeam: use incident_wavelength_weights, see https://github.com/nexusformat/definitions/issues/837 |
|
I would like to see these commands: NeXusOntology/code/nxsOnto/nxsOnto/generator.py Lines 449 to 454 in 2ccdd90 wrapped into a function such as: def main():
dictionary_from_types()
dictionary_from_base_class_files()
parse_base_classes()
parse_application_definitions()
write_ontology()
create_test_individuals()then add this code at the end of the file: if __name__ == "__main__":
main()These changes enable nexusontology [token] [output_dir] [temporary_dir]With the changes above, here is my suggested revised #!/usr/bin/env python
#
# To use this file type:
#
# python setup.py install
from setuptools import setup
__entry_points__ = {
"console_scripts": [
"nexusontology = nxsOnto.generator:main",
],
# 'gui_scripts': [],
}
setup(name='NeXusOntologyGenerator',
version='1.1',
description='Generates an ontology from nxdl files',
author='Steve Collins',
url="https://github.com/nexusformat/NeXusOntology/code/nxsOnto",
packages=['nxsOnto'],
license='Apache 2',
entry_points=__entry_points__,
) |
|
Can the branches be merged? Or are there some objections? |
Uh oh!
There was an error while loading. Please reload this page.