scikit-hep / mplhep

Extended histogram plotting on top of matplotlib and HEP collaboration compatible styling
https://mplhep.readthedocs.io
MIT License
188 stars 64 forks source link

Upload of pytest_results artifact 'fails with no files were found' #375

Closed matthewfeickert closed 2 years ago

matthewfeickert commented 2 years ago

When I ran the workflow in which matplotlib should fail on test_histplot_kwargs, at the upload stage I got

Warning: No files were found with the provided path: pytest_results. No artifacts will be uploaded.

c.f. https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true

Logs: ``` Run pytest -r sa --mpl --mpl-results-path=pytest_results ============================= test session starts ============================== platform linux -- Python 3.10.2, pytest-[7](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:7).1.1, pluggy-1.0.0 Matplotlib: 3.6.0.dev194[8](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:8)+gd8ede1a710 Freetype: 2.6.1 rootdir: /home/runner/work/mplhep/mplhep plugins: mock-3.7.0, github-actions-annotate-failures-0.1.6, mpl-0.14.0 collected [9](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:9)1 items Error: test_histplot_kwargs ValueError: At least one value in the dash list must be positive tests/test_basic.py ...............F.............................. [ 50%] tests/test_inputs.py ...ss.. [ 58%] tests/test_mock.py .. [ 60%] tests/test_styles.py .....ssssssssssssssssssssssssssss..s [[10](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:10)0%] =================================== FAILURES =================================== _____________________________ test_histplot_kwargs _____________________________ args = (), kwargs = {}, fig =
test_name = 'test_basic.test_histplot_kwargs' summary = {'baseline_hash': None, 'baseline_image': None, 'diff_image': None, 'result_hash': None, ...} result_dir = PosixPath('/home/runner/work/mplhep/mplhep/pytest_results/test_basic.test_histplot_kwargs') @wraps(item.function) def item_function_wrapper(*args, **kwargs): with plt.style.context(style, after_reset=True), switch_backend(backend): # Run test and get figure object if inspect.ismethod(original): # method # In some cases, for example if setup_method is used, # original appears to belong to an instance of the test # class that is not the same as args[0], and args[0] is the # one that has the correct attributes set up from setup_method # so we ignore original.__self__ and use args[0] instead. fig = original.__func__(*args, **kwargs) else: # function fig = original(*args, **kwargs) if remove_text: remove_ticks_and_titles(fig) test_name = self.generate_test_name(item) summary = { 'status': None, 'status_msg': None, 'baseline_image': None, 'diff_image': None, 'rms': None, 'tolerance': None, 'result_image': None, 'baseline_hash': None, 'result_hash': None, } # What we do now depends on whether we are generating the # reference images or simply running the test. if self.generate_dir is not None: summary['status'] = 'skipped' summary['status_msg'] = 'Skipped test, since generating image.' self.generate_baseline_image(item, fig) if self.generate_hash_library is None: self._test_results[str(pathify(test_name))] = summary pytest.skip("Skipping test, since generating image.") if self.generate_hash_library is not None: image_hash = self.generate_image_hash(item, fig) self._generated_hash_library[test_name] = image_hash summary['result_hash'] = image_hash # Only test figures if not generating images if self.generate_dir is None: result_dir = self.make_test_results_dir(item) # Compare to hash library if self.hash_library or compare.kwargs.get('hash_library', None): msg = self.compare_image_to_hash_library(item, fig, result_dir, summary=summary) # Compare against a baseline if specified else: > msg = self.compare_image_to_baseline(item, fig, result_dir, summary=summary) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/pytest_mpl/plugin.py:638: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/pytest_mpl/plugin.py:433: in compare_image_to_baseline fig.savefig(str(test_image), **savefig_kwargs) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/figure.py:3080: in savefig self.canvas.print_figure(fname, **kwargs) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backend_bases.py:2266: in print_figure result = print_method( /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backend_bases.py:2[13](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:13)2: in print_method = functools.wraps(meth)(lambda *args, **kwargs: meth( /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/_api/deprecation.py:410: in wrapper return func(*inner_args, **inner_kwargs) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:522: in print_png self._print_pil(filename_or_obj, "png", pil_kwargs, metadata) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:468: in _print_pil FigureCanvasAgg.draw(self) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py:409: in draw self.figure.draw(self.renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/artist.py:73: in draw_wrapper result = draw(artist, renderer, *args, **kwargs) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/artist.py:50: in draw_wrapper return draw(artist, renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/figure.py:2872: in draw mimage._draw_list_compositing_images( /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/image.py:131: in _draw_list_compositing_images a.draw(renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/artist.py:50: in draw_wrapper return draw(artist, renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/axes/_base.py:3078: in draw mimage._draw_list_compositing_images( /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/image.py:131: in _draw_list_compositing_images a.draw(renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/artist.py:50: in draw_wrapper return draw(artist, renderer) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/patches.py:589: in draw with cbook._setattr_cm( /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/contextlib.py:135: in __enter__ return next(self.gen) /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/patches.py:551: in _bind_draw_path_function gc.set_dashes(*self._dash_pattern) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = dash_offset = 0, dash_list = [0.0, 0.0] def set_dashes(self, dash_offset, dash_list): """ Set the dash style for the gc. Parameters ---------- dash_offset : float The offset (usually 0). dash_list : array-like or None The on-off sequence as points. None specifies a solid line. All values must otherwise be non-negative (:math:`\\ge 0`). Notes ----- See p. 107 of to PostScript `blue book`_ for more info. .. _blue book: https://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF """ if dash_list is not None: dl = np.asarray(dash_list) if np.any(dl < 0.0): raise ValueError( "All values in the dash list must be non-negative") if not np.any(dl > 0.0): > raise ValueError( 'At least one value in the dash list must be positive') E ValueError: At least one value in the dash list must be positive /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/backend_bases.py:928: ValueError =============================== warnings summary =============================== ../../../../../opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mplhep/alice.py:5 /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/mplhep/alice.py:5: MatplotlibDeprecationWarning: The matplotlib.docstring module was deprecated in Matplotlib 3.6 and will be removed two minor releases later. from matplotlib import docstring tests/test_styles.py: 24 warnings /opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/_pytest/python.py:[19](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:19)2: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect. result = testfunction(**testargs) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ SKIPPED [30] ../../../../../opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/testing/compare.py:262: Don't know how to convert .pdf files to png SKIPPED [1] ../../../../../opt/hostedtoolcache/Python/3.10.2/x64/lib/python3.10/site-packages/matplotlib/testing/compare.py:262: Don't know how to convert .svg files to png FAILED tests/test_basic.py::test_histplot_kwargs - ValueError: At least one v... ============ 1 failed, 59 passed, 31 skipped, [25](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:25) warnings in 27.[26](https://github.com/scikit-hep/mplhep/runs/5793696689?check_suite_focus=true#step:7:26)s ============ Error: Process completed with exit code 1. Run actions/upload-artifact@v3 Warning: No files were found with the provided path: pytest_results. No artifacts will be uploaded. ```

Not sure why that is.

@andrzejnovak Can you link to an example where this worked in the past?

_Originally posted by @matthewfeickert in https://github.com/scikit-hep/mplhep/pull/374#discussion_r840871497_

andrzejnovak commented 2 years ago

It's possible something went wrong with the config unnoticed, but IIRC it was only producing pytest_results if there were image comparison failures. Since the test you are linking above is failing with a ValueError the behaviour should be fine.

matthewfeickert commented 2 years ago

Since the test you are linking above is failing with a ValueError the behaviour should be fine.

Okay, then I guess this can get closed, right?

(P.S. I saw that for some reason the "pages build and deployment" workflow failed for PR #374, so I went ahead and restarted it and it passed, so that PR is all green on master now. :+1:)

andrzejnovak commented 2 years ago

👍 I'll keep an eye for the ValueError as it shows up in the cron.