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

Tests are failing with an exception #17

Closed
altendky opened this issue Aug 15, 2016 · 4 comments
Closed

Tests are failing with an exception #17

altendky opened this issue Aug 15, 2016 · 4 comments

Comments

@altendky
Copy link
Contributor

Are the tests passing for other people? They fail with an exception for me. I'll work this out but figured it would be worth checking here.

/epc/t/313/pysunspec/venv/bin/python scripts/pysunspec_test.py
pySunSpec version: 1.0.7
Test device path: /epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/devices

Traceback (most recent call last):
  File "scripts/pysunspec_test.py", line 13, in <module>
    test.test_all()
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_all.py", line 58, in test_all
    (count_run, count_passed, count_failed) = module.test_all(pathlist, stop_on_failure)
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_device.py", line 577, in test_all
    if test(pathlist) is True:
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_device.py", line 418, in test_device_from_pics
    d1.from_pics(filename='pics_test_device_1.xml', pathlist=pathlist)
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/device.py", line 127, in from_pics
    raise SunSpecError('Error loading PICS: %s' % str(e))
sunspec.core.util.SunSpecError: Error loading PICS: Block index out of range: 1

Or, with an except removed to see the original trace:

/epc/t/313/pysunspec/venv/bin/python scripts/pysunspec_test.py
pySunSpec version: 1.0.7
Test device path: /epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/devices

Traceback (most recent call last):
  File "scripts/pysunspec_test.py", line 13, in <module>
    test.test_all()
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_all.py", line 58, in test_all
    (count_run, count_passed, count_failed) = module.test_all(pathlist, stop_on_failure)
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_device.py", line 577, in test_all
    if test(pathlist) is True:
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/test/test_device.py", line 418, in test_device_from_pics
    d1.from_pics(filename='pics_test_device_1.xml', pathlist=pathlist)
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/device.py", line 120, in from_pics
    model.from_pics(m)
  File "/epc/t/313/pysunspec/venv/lib/python2.7/site-packages/sunspec/core/device.py", line 481, in from_pics
    raise SunSpecError('Block index out of range: %s' % (str(block_index)))
sunspec.core.util.SunSpecError: Block index out of range: 1
@altendky
Copy link
Contributor Author

You must checkout the sunspec/models repository then things work better. In my fork I added it as a submodule (7e483f9).

@tank-2
Copy link

tank-2 commented Sep 28, 2016

This error is not at all obvious, I just spent too much time tracking this down on my own, until thinking to take a look at the closed issues. I discovered the fix only after reverting to 1.0.6 and noticing the models directory. Why not just include the models directory in 1.0.7 to save people like me trouble?

@bobfox
Copy link
Contributor

bobfox commented Oct 3, 2016

I am sorry this caused you to waste some time. The models are included with every release. The pysunspec-1.07.zip is the 1..0.7 release in the standard Python format. If you install the release in the standard way, the models are included. If you pull the source code directly, you will only get the source code. The models are in a separate repository because they are used in other places and are independent of any on the Python projects.

@altendky
Copy link
Contributor Author

altendky commented Oct 4, 2016

As in 7e483f9, the models could be included as Git submodules. That would at least use the 'standard' Git tool for linking repositories. That said, many people would still likely miss it (myself included). Seems to me that it would be reasonable to have an explicit check for that directory which raises an exception when it is not found and provides both a direct message as to what is wrong ('Models are not available in standard location') as well as instructions to correct the issue ('Checkout http://github.com/sunspec/models into the ... directory'). Or, Git submodules instructions, if that is how they will be acquired. Libraries and applications also often allow for environment variables to specify non-standard locations for 'external' resources.

Another approach focusing on the Python side would be to integrate fetching of the modules into setup.py. Though, the checks and error reporting listed above would likely still be applicable.

If models isn't going to become a Git submodule I would recommend it exist outside of the checked-out pysunspec Git repository rather than as a subdirectory. I personally find nested unrelated repositories confusing.

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

No branches or pull requests

3 participants