Skip to content

Commit

Permalink
Test: Check diff-pdf-visually outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet committed Nov 11, 2024
1 parent 3b8c632 commit 8bb123e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/run-tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ jobs:
# This step should only be used when you need dot / graphviz
run: |
sudo dot -c
- name: Clear results in tox environments
run: |
rm -rf .tox/*/tmp
# - name: Clear results in tox environments
# run: |
# rm -rf .tox/*/tmp
- name: Run tox with latest versions
if: ${{ matrix.min_versions == 'latest_versions' }}
run: |
Expand Down
7 changes: 7 additions & 0 deletions tests/test_vacuum_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ def test_ValidateVacuumSynthesis(vacuum_working_directory, data_dir):
data_dir_pattern = str(data_dir) + "/?"
result_dir_pattern = str(result_dir) + "/?"

tmp_dir = result_dir / "tmpdir_for_diff"
tmp_dir.mkdir(parents=True, exist_ok=True)

# Check the results
assert_equal_trees(

Check failure on line 33 in tests/test_vacuum_workflow.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_vacuum_workflow.test_ValidateVacuumSynthesis@group_vacuum

AssertionError: The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/morphometrics/morphometrics_apical_dendrite.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/morphometrics/morphometrics_apical_dendrite.pdf' are different: Kwargs used for computing differences: {'verbosity': 3, 'tempdir': PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/tmpdir_for_diff')} Exception raised: (FileNotFoundError) 2 No such file or directory The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/morphometrics/morphometrics_basal_dendrite.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/morphometrics/morphometrics_basal_dendrite.pdf' are different: Exception raised: (FileNotFoundError) 2 No such file or directory The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/score_matrix_reports.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/score_matrix_reports.pdf' are different: Exception raised: (FileNotFoundError) 2 No such file or directory
Raw output
vacuum_working_directory = (PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out'), PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out'))
data_dir = PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data')

    @pytest.mark.xdist_group("group_vacuum")
    def test_ValidateVacuumSynthesis(vacuum_working_directory, data_dir):
        """Test the synthesis workflow in vacuum."""
        np.random.seed(0)
    
        # Run the workflow
        assert luigi.build([ValidateVacuumSynthesis()], local_scheduler=True)
    
        result_dir, expected_dir = vacuum_working_directory
    
        data_dir_pattern = str(data_dir) + "/?"
        result_dir_pattern = str(result_dir) + "/?"
    
        tmp_dir = result_dir / "tmpdir_for_diff"
        tmp_dir.mkdir(parents=True, exist_ok=True)
    
        # Check the results
>       assert_equal_trees(
            expected_dir,
            result_dir,
            specific_args={
                "validation/morphometrics/morphometrics_apical_dendrite.pdf": {
                    "verbosity": 3,
                    "tempdir": tmp_dir,
                },
                "morphs_df/vacuum_synth_morphs_df.csv": {
                    "format_data_kwargs": {
                        "replace_pattern": {(result_dir_pattern, ""): ["vacuum_synth_morphologies"]}
                    }
                },
                "morphs_df/substituted_morphs_df.csv": {
                    "format_data_kwargs": {
                        "replace_pattern": {(data_dir_pattern, ""): ["path", "morphology_path"]}
                    }
                },
                "morphs_df/morphs_df.csv": {
                    "format_data_kwargs": {
                        "replace_pattern": {(data_dir_pattern, ""): ["path", "morphology_path"]}
                    }
                },
                "synthesis/neurots_input/tmd_distributions.json": {
                    "tolerance": 2e-3,
                    "absolute_tolerance": 1e-15,
                },
            },
        )

/home/runner/work/synthesis-workflow/synthesis-workflow/tests/test_vacuum_workflow.py:33: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

export_formatted_files = '_FORMATTED'
args = (PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out'), PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out'))
kwargs = {'specific_args': {'morphs_df/morphs_df.csv': {'format_data_kwargs': {'replace_pattern': {('/home/runner/work/synthesi...logies']}}}, 'synthesis/neurots_input/tmd_distributions.json': {'absolute_tolerance': 1e-15, 'tolerance': 0.002}, ...}}
different_files = {'validation/morphometrics/morphometrics_apical_dendrite.pdf': "The files '/home/runner/work/synthesis-workflow/synthe...lidation/score_matrix_reports.pdf' are different:\nException raised: (FileNotFoundError) 2\nNo such file or directory"}
sorted_items = [('validation/morphometrics/morphometrics_apical_dendrite.pdf', "The files '/home/runner/work/synthesis-workflow/synth...idation/score_matrix_reports.pdf' are different:\nException raised: (FileNotFoundError) 2\nNo such file or directory")]

    def assert_equal_trees(*args, export_formatted_files=False, **kwargs):
        """Raise an :class:`AssertionError` if differences are found in the two directory trees.
    
        .. note::
            This function has a specific behavior when run with pytest. See the doc of the
            :mod:`dir_content_diff.pytest_plugin`.
    
        Args:
            *args: passed to the :func:`compare_trees` function.
            export_formatted_files (bool, or str): If set to ``True``, the formatted files are exported
                to the directory with the default suffix. If set to a string, it is used as suffix for
                the new directory.
            **kwargs: passed to the :func:`compare_trees` function.
    
        Returns:
            (bool) ``True`` if the trees are equal. If they are not, an :class:`AssertionError` is
            raised.
        """
        # If run with pytest, get the trigger to export formatted data from it
        if export_formatted_files is False and hasattr(
            assert_equal_trees, "_pytest_export_formatted_data"
        ):
            # pylint: disable=no-member
            # pylint: disable=protected-access
            export_formatted_files = assert_equal_trees._pytest_export_formatted_data
            if export_formatted_files is True and assert_equal_trees._pytest_export_suffix:
                export_formatted_files = assert_equal_trees._pytest_export_suffix
    
        different_files = compare_trees(*args, export_formatted_files=export_formatted_files, **kwargs)
    
        # Sort the files according to their relative paths
        sorted_items = sorted(different_files.items(), key=lambda x: x[0])
        # Test that all files are equal and raise the formatted messages if there are differences
        if len(sorted_items) > 0:
>           raise AssertionError("\n\n\n".join([i[1] for i in sorted_items]))
E           AssertionError: The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/morphometrics/morphometrics_apical_dendrite.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/morphometrics/morphometrics_apical_dendrite.pdf' are different:
E           Kwargs used for computing differences: {'verbosity': 3, 'tempdir': PosixPath('/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/tmpdir_for_diff')}
E           Exception raised: (FileNotFoundError) 2
E           No such file or directory
E           
E           
E           The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/morphometrics/morphometrics_basal_dendrite.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/morphometrics/morphometrics_basal_dendrite.pdf' are different:
E           Exception raised: (FileNotFoundError) 2
E           No such file or directory
E           
E           
E           The files '/home/runner/work/synthesis-workflow/synthesis-workflow/tests/data/in_vacuum/out/validation/score_matrix_reports.pdf' and '/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/tmp/popen-gw2/test_ValidateVacuumSynthesis0/out/validation/score_matrix_reports.pdf' are different:
E           Exception raised: (FileNotFoundError) 2
E           No such file or directory

/home/runner/work/synthesis-workflow/synthesis-workflow/.tox/py310/lib/python3.10/site-packages/dir_content_diff/__init__.py:385: AssertionError
expected_dir,
result_dir,
specific_args={
"validation/morphometrics/morphometrics_apical_dendrite.pdf": {
"verbosity": 3,
"tempdir": tmp_dir,
},
"morphs_df/vacuum_synth_morphs_df.csv": {
"format_data_kwargs": {
"replace_pattern": {(result_dir_pattern, ""): ["vacuum_synth_morphologies"]}
Expand Down

0 comments on commit 8bb123e

Please sign in to comment.