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

Integration testing mechanics. #36

Merged
merged 9 commits into from
Mar 16, 2023
Merged

Integration testing mechanics. #36

merged 9 commits into from
Mar 16, 2023

Conversation

samcunliffe
Copy link
Member

@samcunliffe samcunliffe commented Feb 16, 2023

As discussed in #27, we also want "end-to-end" tests/integrations tests that actually start the web app and ... do things.

I'm not sure about the doing things part yet, but I can get the mechanics of dash's basic example to work.

To run locally:

  • Install google chrome.
  • Download the relevant chrome driver and put it into your path.
  • Tell MacOS that it's safe.
  • python -m pip install "dash[testing]"
  • Run tox or pytest as you normally would.

Apparently selenium and chromedriver are already installed on the GH
runners. So just need "dash[testing]" as a dev dependency and everything
should just work™️.
https://community.plotly.com/t/dash-integration-testing-with-selenium-and-github-actions/43602
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

Merging #36 (bc7d145) into main (e3e0deb) will increase coverage by 31.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            main      #36       +/-   ##
==========================================
+ Coverage   9.38%   40.39%   +31.00%     
==========================================
  Files          4        9        +5     
  Lines        373      458       +85     
==========================================
+ Hits          35      185      +150     
+ Misses       338      273       -65     
Impacted Files Coverage Δ
wazp/app.py 94.11% <100.00%> (+94.11%) ⬆️
wazp/callbacks.py 19.29% <100.00%> (+19.29%) ⬆️

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@samcunliffe
Copy link
Member Author

The Windows build fails because chrome.exe is not in the PATH (why!?). I can get tox to run if I manually add it. So now need to decide where to put the hack.

Either set selenium.webdriver.chrome.options.binary_location in python, or add a Windows-only hack in the GH workflow YML.

@samcunliffe
Copy link
Member Author

samcunliffe commented Feb 20, 2023

@sfmig let me open this for review now in the spirit of short PRs and finding our team's zen 🧘‍♂️ (This PR does almost nothing).

I'll make this smoke test actually do meaningful stuff at a slightly lower priority than unit-testing.

One boring train ride later: 0fac8d4 does a (still minimal but) meaningful test of the wazp.app.

@samcunliffe samcunliffe marked this pull request as ready for review February 20, 2023 12:36
@samcunliffe samcunliffe added task Something to be done or set up that doesn't really involve coding. enhancement Optional feature labels Feb 20, 2023
samcunliffe and others added 5 commits March 1, 2023 11:28
A first integration test that starts a WAZP app server in a thread, and
checks that it can be started error-free.
Merge remote-tracking branch 'origin/main' into end2end-test-attempt-v0
@@ -14,6 +14,8 @@ dynamic = ["version"]
license = {text = "BSD-3-Clause"}

dependencies = [
"tables",
"blosc2",
Copy link
Member Author

Choose a reason for hiding this comment

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

☝️ After merging main into this branch in 4ff5406 (then I fixed a trivial error), it seems the smoke test actually flagged up a missing dependency (👍).

It's an error about missing optional pytables. So this also fixes that.

I think this makes sense as we've added some HDF5 input since I made this branch.

Copy link
Member

Choose a reason for hiding this comment

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

The problem about pytables is that pip install doesn't work on many machines (Adam mentioned this might be due to missing hdf5 library, which pip cannot install).
That's why I have recommended creating a conda environment with pytables in install instructions (conda install works).

Does "blosc2" solve the above issue? If yes, we can simply get rid of the whole conda thing

Copy link
Member Author

@samcunliffe samcunliffe Mar 7, 2023

Choose a reason for hiding this comment

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

No. blocsc2 is some compression for hdf5. It won't solve any (py)tables installation woes.

Trouble is, for the tests we'll need tables (it's fine for the tests because hdf5 is on the runners).

Options that come to mind:

  1. Leave it like this. (I think I prefer this option because it's "pytables' fault" if it won't install.)
    • Perhaps we add a "you might have errors from pytables, here's where to go for help"-type sentence to the docs.
  2. Move tables to a dev dependency (which it really isn't, so I don't like this). But could then add an explicit conda installation step of tables to the instructions.
  3. @dstansby showed me this which might help.

Copy link
Member

Choose a reason for hiding this comment

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

That's annoying.
Tagging @adamltyson because we have discussed this before, and it's also relevant to other NIU projects.
Question: if we add tables as a regular (pip) dependency, will pip install wazp fail when users run it? Or will it just install wazp without pytables and let them know that the latter is missing?

Copy link
Member

Choose a reason for hiding this comment

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

Sort of dodging the question, but if tables is going to be necessary for proper functioning of the app, then I would target conda-forge as the main release mechanism.

Copy link

Choose a reason for hiding this comment

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

My (univited but I've been tagged so sort of invited) two cents here is it would be best specify pandas[hdf5] if you're only loading HDF5 via pandas, and not explicitly have tables as a dependency. This way if pandas change the library they're using to load HDF5 files you don't have to change anything.

re. installing a hdf5 library:

  • For testing, I've used tox-conda before and would recommend.
  • For users I agree that targeting conda-forge as the main release channel is a good way to go. This way you can specify a hdf5 dependency in the conda-forge recipe.

And finally, FWIW, if you try and install tables on a platform that doesn't have wheels and tries to build from source, and don't have a HDF5 library you get:

Collecting tables
  Using cached tables-3.8.0.tar.gz (8.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      cpuinfo failed, assuming no CPU features: 'flags'
      * Using Python 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:26:40) [Clang 14.0.6 ]
      * Found cython 0.29.33
      * USE_PKGCONFIG: True
      * Found conda env: ``/Users/dstansby/mambaforge/envs/pytables``
      ld: library not found for -lhdf5
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      .. ERROR:: Could not find a local HDF5 installation.
         You may need to explicitly state where your local HDF5 headers and
         library can be found by setting the ``HDF5_DIR`` environment
         variable or by using the ``--hdf5`` command-line option.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Looking at the PyPI files for tables this just looks like it's because there's no wheel for macOS arm, so here I'd say asking for one of those upstream in the tables repo might be a good thing to do.

Copy link
Member Author

@samcunliffe samcunliffe Mar 8, 2023

Choose a reason for hiding this comment

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

it would be best specify pandas[hdf5] if you're only loading HDF5 via pandas
[...] This way if pandas change the library they're using to load HDF5 files you don't have to change anything.

That would be nice but I don't think we can have nice things...

(wazp-env) ➤ grep dependencies\ = pyproject.toml
dependencies = ["pandas[hdf5]", "dash", "dash-bootstrap-components"]
(wazp-env) ➤ tox -e py310 -vv 

eventually you get a:

WARNING: pandas 1.5.3 does not provide the extra 'hdf5'

About the pyTables wheel, seems like they did make it: PyTables/PyTables#887 and PyTables/PyTables#944.

Copy link
Member

Choose a reason for hiding this comment

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

I have a silicon Mac, so I created a fresh conda environment, ran pip install . on this branch, and got the error that David posted. I tried the same on an ubuntu machine and it worked (presumably because there is a system-level install of hdf5 ?).
Anyhow, at least some users will get the error when running pip install wazp.

So how about this action plan:

  • We release on pip as is, but users have to follow the current installation instructions:
    conda create -n wazp-env -c conda-forge python=3 pytables
    conda activate wazp-env
    pip install wazp
    (alternatively we could create a conda environment.yml file)
  • In parallel we start the process of releasing on conda-forge
  • Re testing, Sam decides how to handle it, because I don't understand it well enough to offer an opinion

Copy link
Member Author

Choose a reason for hiding this comment

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

The test job should be as-close-as-possible environment to the users. So if we install tables via conda-force, then the GH workflow ideally does that.

I'd suggest merging this PR as-is. I claim that installing via conda as per the instructions, and then reinstalling as a dependency via pip works. Even though it's double-work.

We can fix pyproject.toml accordingly later if we fix the GH workflow or release some other way or...

@samcunliffe
Copy link
Member Author

samcunliffe commented Mar 7, 2023

Codecov seems stuck "processing". But this should be a 15.75% 30% (ish) increase in coverage.

Copy link
Collaborator

@sfmig sfmig left a comment

Choose a reason for hiding this comment

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

sorry this is quite late! but looking good ✨

tests/__init__.py Outdated Show resolved Hide resolved
@sfmig sfmig merged commit 9ae154c into main Mar 16, 2023
@sfmig sfmig deleted the end2end-test-attempt-v0 branch March 16, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Optional feature task Something to be done or set up that doesn't really involve coding.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants