Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: can't validate NXDL file now #196

Open
prjemian opened this issue Feb 4, 2022 · 5 comments
Open

BUG: can't validate NXDL file now #196

prjemian opened this issue Feb 4, 2022 · 5 comments
Labels

Comments

@prjemian
Copy link
Owner

prjemian commented Feb 4, 2022

It is an expected feature of punx that it be able to validate NXDL files. Today, this failed:

(bluesky_2022_1) prjemian@zap:~/.../BES/xpcs$ punx val NeXus/NXxpcs.nxdl.xml 

!!! WARNING: this program is not ready for distribution.

Traceback (most recent call last):
  File "/home/prjemian/.conda/envs/bluesky_2022_1/bin/punx", line 33, in <module>
    sys.exit(load_entry_point('punx', 'console_scripts', 'punx')())
  File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 441, in main
    args.func(args)
  File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 198, in func_validate
    result = validate.validate_xml(args.infile)
AttributeError: module 'punx.validate' has no attribute 'validate_xml'

Noting this version:

(bluesky_2022_1) prjemian@zap:~/.../BES/xpcs$ punx --version

!!! WARNING: this program is not ready for distribution.

0.3.0+30.g0e4fe8e
@padraic-shafer
Copy link

I'm running into this same issue with 0.3.0 and python 3.8.13.

Is there a workaround that you would suggest for validating an NXDL XML file?

@prjemian
Copy link
Owner Author

Thanks for the bump on this. The documentation has a big TODO marking and this basic suggestion:

user@host ~ $  xmllint --noout --schema nxdl.xsd base_classes/NXentry.nxdl.xml
base_classes/NXentry.nxdl.xml validates

This works if your working directory is the root of the NeXus definitions repository, so the files nxdl.xsd and nxdlTypes.xsd are in the local directory, as well as the subdrectories: applications, base_classes, contributed_definitions

Once this is re-implemented in punx, then punx will find those files and sub-directories for you. Internally, punx will call the library used by xmllint for this same analysis.

@prjemian
Copy link
Owner Author

Here's a view of that directory on my local development workstation:

(base) prjemian@zap:~/.../prjemian/punx$ ls ../../NeXus/definitions/
applications  contributed_definitions  jenkins_build  manual         package           utils
base_classes  COPYING                  legacy_docs    nxdlTypes.xsd  README.md         www
build         dev_tools                LGPL.txt       NXDL_VERSION   requirements.txt
CHANGES.rst   impatient-guide          Makefile       nxdl.xsd       setup.cfg

@prjemian
Copy link
Owner Author

Here's how it should work (but fails now):


!!! WARNING: this program is not ready for distribution.

Traceback (most recent call last):
  File "/home/prjemian/micromamba/envs/bluesky_2022_3/bin/punx", line 33, in <module>
    sys.exit(load_entry_point('punx', 'console_scripts', 'punx')())
  File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 441, in main
    args.func(args)
  File "/home/prjemian/Documents/projects/prjemian/punx/punx/main.py", line 198, in func_validate
    result = validate.validate_xml(args.infile)
AttributeError: module 'punx.validate' has no attribute 'validate_xml'

The code exists (from a previous revision), but has been parked out of distribution since the last refactoring. It will be coming back:

(bluesky_2022_3) prjemian@zap:~/.../prjemian/punx$ git grep validate_xml
punx/ignore_now/main.py:        result = validate.validate_xml(args.infile)
punx/ignore_now/nxdlstructure.py:    validate.validate_xml(nxdl_file_name)
punx/ignore_now/validate.py:   ~validate_xml
punx/ignore_now/validate.py:def validate_xml(xml_file_name):
punx/main.py:        result = validate.validate_xml(args.infile)
punx/nxdl_manager.py:def validate_xml_tree(xml_tree):
punx/nxdl_manager.py:            validate_xml_tree(lxml_tree)
punx/reserved_code.txt:#             validate_xml_tree(self.lxml_tree)
punx/tests/test_nxdl_manager.py:        nxdl_manager.validate_xml_tree(tree)
punx/tests/test_nxdl_manager.py:    #     nxdl_manager.validate_xml_tree(tree)
tests/ignore_now/validate_test.py_:    def test_validate_xml___with_invalid_xml_file(self):
tests/ignore_now/validate_test.py_:                          punx.validate.validate_xml, self.test_file)
tests/ignore_now/validate_test.py_:    def test_validate_xml___with_invalid_NXDL_file(self):
tests/ignore_now/validate_test.py_:            punx.validate.validate_xml, 

@padraic-shafer
Copy link

Aha, this looks straightforward. Will give it a try with xmllint.

Thanks for pointing this out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants