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

Move reference data from test_rxd.py to rxd_data.json. #3143

Merged
merged 8 commits into from
Oct 24, 2024

Conversation

adamjhn
Copy link
Member

@adamjhn adamjhn commented Oct 24, 2024

Added --save flag to regenerate test data.

@adamjhn adamjhn added the rxd reaction-diffusion label Oct 24, 2024
Copy link
Member

@nrnhines nrnhines left a comment

Choose a reason for hiding this comment

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

Are you sure the json file is appearing in the installed module?
I was working on this as well (using from neuron.tests.utils.checkresult import Chk) and can't figure out so far how to install the json file

@bbpbuildbot

This comment has been minimized.

Copy link
Member

@nrnhines nrnhines left a comment

Choose a reason for hiding this comment

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

It appears that the following can be used to install the json file

$ git diff setup.py
diff --git a/setup.py b/setup.py
index ba0922b27..05e8ca67e 100644
--- a/setup.py
+++ b/setup.py
@@ -500,7 +500,7 @@ def setup_package():
         name=package_name,
         package_dir={"": NRN_PY_ROOT},
         packages=py_packages,
-        package_data={"neuron": ["*.dat"]},
+        package_data={"neuron": ["*.dat", "tests/*.json"]},
         ext_modules=extensions,
         scripts=[
             os.path.join(NRN_PY_SCRIPTS, f)

I don't know if that is the best solution. I did not check a wheel build.

Copy link

✔️ e3c4a1f -> Azure artifacts URL

@adamjhn
Copy link
Member Author

adamjhn commented Oct 24, 2024

It appears that the following can be used to install the json file

$ git diff setup.py
diff --git a/setup.py b/setup.py
index ba0922b27..05e8ca67e 100644
--- a/setup.py
+++ b/setup.py
@@ -500,7 +500,7 @@ def setup_package():
         name=package_name,
         package_dir={"": NRN_PY_ROOT},
         packages=py_packages,
-        package_data={"neuron": ["*.dat"]},
+        package_data={"neuron": ["*.dat", "tests/*.json"]},
         ext_modules=extensions,
         scripts=[
             os.path.join(NRN_PY_SCRIPTS, f)

I don't know if that is the best solution. I did not check a wheel build.

Looks like that worked. Thanks

src/nrnpython/CMakeLists.txt Outdated Show resolved Hide resolved
Copy link

Copy link

✔️ 77f0c6b -> Azure artifacts URL

@nrnhines nrnhines merged commit f8e94c5 into master Oct 24, 2024
34 of 35 checks passed
@nrnhines nrnhines deleted the rxd_test_update branch October 24, 2024 18:59
@pramodk
Copy link
Member

pramodk commented Oct 25, 2024

@nrnhines nrnhines restored the rxd_test_update branch October 25, 2024 10:50
@nrnhines
Copy link
Member

nrnhines commented Oct 25, 2024

@pramodk
Interesting. I just installed neuron-nightly for python3.12 and the ./env/lib/python3.12/site-packages/neuron/tests/test_rxd.json is present. But I do get an error for python -c 'import neuron;neuron.test_rxd()' for each of the 4 subprocesses.

$ python -c 'import neuron;neuron.test_rxd()'
test_ecs_diffusion_fixed_step (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_fixed_step) ... 
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.1.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "<string>", line 1, in <module>
  File "/home/hines/.pyenv/versions/3.12.4/lib/python3.12/multiprocessing/spawn.py", line 122, in spawn_main
...
  File "/home/hines/neuron/nrn/build/install/lib/python/neuron/rxd/geometry3d/surface.py", line 1, in <module>
    from . import ctng

Don't know what it means for the CI failure but downgrading numpy on my virtual environment fixed the issue.

$ pip install "numpy<2.0.0"

$ python -c 'import neuron;neuron.test_rxd()'
test_ecs_diffusion_fixed_step (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_fixed_step) ... ok
test_ecs_diffusion_variable_step_coarse (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_variable_step_coarse) ... ok
test_ecs_diffusion_variable_step_fine (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_variable_step_fine) ... ok
test_rxd (neuron.tests.test_rxd.RxDTestCase.test_rxd) ... ok

----------------------------------------------------------------------
Ran 4 tests in 4.026s

OK

The CI failure seems to be for python3.11. With a virtual environment for 3.11.8 and pip install neuron-nightly
I'm getting

~/tmp$ python -c 'import neuron;neuron.test_rxd()'
test_ecs_diffusion_fixed_step (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_fixed_step) ... ok
test_ecs_diffusion_variable_step_coarse (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_variable_step_coarse) ... ok
test_ecs_diffusion_variable_step_fine (neuron.tests.test_rxd.RxDTestCase.test_ecs_diffusion_variable_step_fine) ... ok
test_rxd (neuron.tests.test_rxd.RxDTestCase.test_rxd) ... ok

----------------------------------------------------------------------
Ran 4 tests in 4.610s

OK
(env) hines@hines-ThinkStation-P5:~/tmp$ python
Python 3.11.8 (main, Jul 14 2024, 15:22:56) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'2.1.2'
>>> 

@JCGoran
Copy link
Collaborator

JCGoran commented Nov 1, 2024

Here's a reproducer dockerfile:

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y python3-venv python3-pip wget
# get one of the "broken" wheels for Python 3.10 (they are not on PyPI since CI failed)
# taken from:
# https://app.circleci.com/pipelines/github/neuronsimulator/nrn/9439/workflows/419f7eb5-d63d-4b07-87d4-b7b9ca39f9e5/jobs/4668/artifacts
RUN wget 'https://output.circle-artifacts.com/output/job/76a56ccb-419e-4952-8784-6ea2a95cf62a/artifacts/0/artifacts/NEURON_nightly-9.0a1.dev380-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl'
RUN python3 -m venv env
RUN env/bin/python -m pip install NEURON*.whl
RUN env/bin/python -c 'import neuron; neuron.test_rxd()'

Build using docker build -t reproducer --platform linux/arm64 . The build will fail with exactly the issue as in the CI, namely:

test_ecs_diffusion_fixed_step (neuron.tests.test_rxd.RxDTestCase) ... ok
test_ecs_diffusion_variable_step_coarse (neuron.tests.test_rxd.RxDTestCase) ... FAIL
test_ecs_diffusion_variable_step_fine (neuron.tests.test_rxd.RxDTestCase) ... FAIL
test_rxd (neuron.tests.test_rxd.RxDTestCase) ... ok

======================================================================
FAIL: test_ecs_diffusion_variable_step_coarse (neuron.tests.test_rxd.RxDTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/env/lib/python3.10/site-packages/neuron/tests/test_rxd.py", line 163, in test_ecs_diffusion_variable_step_coarse
    assert p.exitcode == 0
AssertionError

======================================================================
FAIL: test_ecs_diffusion_variable_step_fine (neuron.tests.test_rxd.RxDTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/env/lib/python3.10/site-packages/neuron/tests/test_rxd.py", line 170, in test_ecs_diffusion_variable_step_fine
    assert p.exitcode == 0
AssertionError

----------------------------------------------------------------------
Ran 4 tests in 16.973s

FAILED (failures=2)

Note that if your underlying platform is x86_64, you need to install QEMU support using:

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

@JCGoran JCGoran mentioned this pull request Nov 1, 2024
29 tasks
@nrnhines
Copy link
Member

nrnhines commented Nov 1, 2024

Just for a permanent record... Thanks @JCGoran ! Because of many false starts some of the below may not be needed. Please edit if some details are misleading.

sudo apt update

sudo apt install docker.io
sudo systemctl start docker
docker run --rm --privileged docker.io/multiarch/qemu-user-static --reset -p yes
docker run -ti --rm --platform linux/arm64 docker.io/ubuntu:22.04 /bin/bash

@JCGoran
Copy link
Collaborator

JCGoran commented Nov 1, 2024

Looks like a similar issue occurs on MacOS as well, at least on arm64: https://github.com/neuronsimulator/nrn/actions/runs/11632330511/job/32395225512?pr=3168#step:7:285

For context, I tried setting up the CI so we can have nightly/release wheels on MacOS on arm, here's the CI file: https://github.com/neuronsimulator/nrn/actions/runs/11632330511/workflow?pr=3168 (Python 3.9 had the same error, and I assume the others would as well if I could figure out how to not cancel the workflow jobs if one of them fail).

JCGoran added a commit that referenced this pull request Nov 3, 2024
This was referenced Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rxd reaction-diffusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants