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

Unit tests for makers, container and component modules (part 1/X) #163

Merged
merged 39 commits into from
Jan 16, 2025

Conversation

guillaumegrolleron
Copy link
Contributor

This PR is the first part of the implementation of the unit tests for :

nectarchain.data.container
nectarchain.makers (ChargesMakers, WaveformsMakers)

It also includes modification of the core containers class to make more robust the I/O methods. Thus the pedestal workflow has been changed to fully use the Necrtachain containers (instead of the pytable module).

The LightNectarcamEventSource has been removed because you are now using the implementation of ctapipe_io_nectarcam

There are also improvement of user scripts for waveforms, charges and photostat computation

guillaume.grolleron added 30 commits June 23, 2024 15:55
ds to find computed calibration quatities
…anted one

-update pp and n values to last studies
-display wfs -> mean instead of sum
-Agg backend is not forced in Pstat calibnration
exluse user_scripts to pytest
improvement split_run method
pyproject.toml Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@jlenain
Copy link
Collaborator

jlenain commented Jan 15, 2025

Hi @guillaumegrolleron ,

Many thanks for this PR !

Just one question: did you check that Despeina's GUI and scripts for the TRR are still running fine ? I understand you refactored these scripts to avoid any clash with pytest.

Otherwise, ready to merge or do you want to add things in this PR ?

Copy link
Collaborator

@jlenain jlenain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK... As is, the GUI for the TRR cannot be launched properly. @guillaumegrolleron , could you please either revert your changes in Despina's scripts, or fix it ? At the moment, the different imports are failing. Quickly hacking, but not cleanly, into it, for instance the linearity test fails with:

2025-01-15 21:04:27,329 �[1;32mINFO�[0m [tools_components.LinearityTestTool] (tool.finish): Goodbye
2025-01-15 21:04:27,329 �[1;33mWARNING�[0m [tools_components.LinearityTestTool] (core.finish): Shutting down.
Traceback (most recent call last):
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/linearity.py", line 450, in <module>
    main()
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/linearity.py", line 134, in main
    output = tool.finish()
             ^^^^^^^^^^^^^
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/tools_components.py", line 255, in finish
    dataset = group["ChargeContainer"]
              ~~~~~^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/jlenain/local/opt/mambaforge/envs/nectar-dev/lib/python3.11/site-packages/h5py/_hl/group.py", line 357, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 241, in h5py.h5o.open
KeyError: "Unable to synchronously open object (object 'ChargeContainer' doesn't exist)"

I guess this is related to the refactoring from ChargeContainer to ChargeContainers, is that correct ?

@jlenain
Copy link
Collaborator

jlenain commented Jan 15, 2025

If you allow me to commit here, I have a patch ready at least to fix the imports for the TRR GUI test suite. I have put that into a new branch in my fork: https://github.com/jlenain/nectarchain/tree/trr-gui-fix

jlenain added a commit to jlenain/nectarchain that referenced this pull request Jan 15, 2025
@jlenain
Copy link
Collaborator

jlenain commented Jan 15, 2025

I guess this is related to the refactoring from ChargeContainer to ChargeContainers, is that correct ?

Hum... not related to that. The same kind of error occurs on the deadtime test:

Traceback (most recent call last):
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 424, in <module>
    main()
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 135, in main
    output = tool.finish()
             ^^^^^^^^^^^^^
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/tools_components.py", line 1246, in finish
    dataset = group["UCTSContainer"]
              ~~~~~^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/jlenain/local/opt/mambaforge/envs/nectar-dev/lib/python3.11/site-packages/h5py/_hl/group.py", line 357, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 241, in h5py.h5o.open
KeyError: "Unable to synchronously open object (object 'UCTSContainer' doesn't exist)"

@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

I guess this is related to the refactoring from ChargeContainer to ChargeContainers, is that correct ?

Hum... not related to that. The same kind of error occurs on the deadtime test:

Traceback (most recent call last):
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 424, in <module>
    main()
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 135, in main
    output = tool.finish()
             ^^^^^^^^^^^^^
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/tools_components.py", line 1246, in finish
    dataset = group["UCTSContainer"]
              ~~~~~^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/jlenain/local/opt/mambaforge/envs/nectar-dev/lib/python3.11/site-packages/h5py/_hl/group.py", line 357, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 241, in h5py.h5o.open
KeyError: "Unable to synchronously open object (object 'UCTSContainer' doesn't exist)"

OK, got it... It is linked to the change from XXXContainer to XXXContainer_0, but caused by what ?

@guillaumegrolleron
Copy link
Contributor Author

Hi @jlenain !
Indeed I forgot to reactive the TRR tests, however the location of this tests in user_scripts is maybe not the best part, what do you think to move this part of the code in a nectarchain module, with associated tests runs by pytest ?
I can do it and fix errors linked to the changes in container I/O methods.

@guillaumegrolleron
Copy link
Contributor Author

I guess this is related to the refactoring from ChargeContainer to ChargeContainers, is that correct ?

Hum... not related to that. The same kind of error occurs on the deadtime test:

Traceback (most recent call last):
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 424, in <module>
    main()
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/deadtime.py", line 135, in main
    output = tool.finish()
             ^^^^^^^^^^^^^
  File "/home/jlenain/local/src/python/cta-observatory/nectarchain/src/nectarchain/user_scripts/dmousadi/TRR_scripts/src/tools_components.py", line 1246, in finish
    dataset = group["UCTSContainer"]
              ~~~~~^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "/home/jlenain/local/opt/mambaforge/envs/nectar-dev/lib/python3.11/site-packages/h5py/_hl/group.py", line 357, in __getitem__
    oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
  File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
  File "h5py/h5o.pyx", line 241, in h5py.h5o.open
KeyError: "Unable to synchronously open object (object 'UCTSContainer' doesn't exist)"

OK, got it... It is linked to the change from XXXContainer to XXXContainer_0, but caused by what ?

This change is done the make more robust the I/O methods for containers and to have the same behaviour with one or multiple slices.

@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

Hi @guillaumegrolleron !

Concerning the errors linked to the changes in container I/O methods, I am currently working on fixes for it in the branch https://github.com/jlenain/nectarchain/tree/trr-gui-fix. I'll open a PR on top on your PR, if manageable, for that.

@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

Whether the TRR test suite should be kept on user_scripts or not, I have no strong preference about it.

@guillaumegrolleron
Copy link
Contributor Author

Hi @guillaumegrolleron !

Concerning the errors linked to the changes in container I/O methods, I am currently working on fixes for it in the branch https://github.com/jlenain/nectarchain/tree/trr-gui-fix. I'll open a PR on top on your PR, if manageable, for that.

Ok so we first merge this PR and then yours ?

@jlenain
Copy link
Collaborator

jlenain commented Jan 16, 2025

Hi @guillaumegrolleron !
Concerning the errors linked to the changes in container I/O methods, I am currently working on fixes for it in the branch https://github.com/jlenain/nectarchain/tree/trr-gui-fix. I'll open a PR on top on your PR, if manageable, for that.

Ok so we first merge this PR and then yours ?

Yep, we can do that. Green light on your side that I merge this PR ?

@guillaumegrolleron
Copy link
Contributor Author

Yes you can merge !

@jlenain jlenain merged commit 5151e86 into cta-observatory:main Jan 16, 2025
11 checks passed
jlenain added a commit to jlenain/nectarchain that referenced this pull request Jan 16, 2025
@jlenain jlenain mentioned this pull request Jan 16, 2025
jlenain added a commit to jlenain/nectarchain that referenced this pull request Jan 16, 2025
This was referenced Jan 16, 2025
jlenain added a commit to ArmelleJB/nectarchain that referenced this pull request Jan 16, 2025
jlenain added a commit that referenced this pull request Jan 17, 2025
* Try to fix TRR GUI test suite following PR #163

* Fixed bug in selection of fit function to be used for linearity
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

Successfully merging this pull request may close these issues.

Drop LightNectarCAMEventSource from nectarchain
2 participants