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

Fix inconsistent handling of figure names (backport #1430) #1434

Merged
merged 1 commit into from
Mar 31, 2024

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Mar 29, 2024

ExperimentData._clear_results() cleared ExperimentData._figures but not the related ExperimentData._db_data.figure_names exposed as ExperimentData.figure_names. BaseAnalysis.run() calls ExperimentData._clear_results() so when a second analysis run produced a different set of figure names from the first the ExperimentData instance would be left a figure_names property with entries that did not match the underlying figures data. Here, this issue is addressed by also clearing ExperimentData._db_data.figure_names.

This issue was first noticed due to occasional failures of the test.database_service.test_db_experiment_data.TestDbExperimentData.test_copy_figure_artifacts test which runs a fake experiment and then adds a figure and artifact to the experiment data. Then the tests copies the experiment data to test the behavior of copy(). Occasionally, the adding of the figure occurs before the background analysis thread runs. In this case, the figure name gets added to figure_names before the results get cleared by the analysis callback. Because of the bug described above, the old figure name stays around in the original experiment data object but does not copy to the new object because figure names are copied using the data in ExperimentData._figures and not
ExperimentData._db_data.figure_names. A block_for_results() was added to the experiment because in principle the copy() could occur before the analysis clears results and then the two data objects would not match, though this case has not been observed (only adding the figure and then clearing it with analysis before copying so the copy is the one missing the figure name has been observed; not the copy having the name and not the original).

Addtionally, BaseAnalysis.run() handled the figure_names option incorrectly when passes a keyword argument. Keyword arguments to passed to run() cause the analysis class to copy itself and add the options to the copy before running it. However, within the run() method, self.options.figure_names was used for assigning figure names rather than referencing the copy of the analysis class, so figure names could not be set using figure_names as a keyword argument. This issues was fixed by replacing self references with references to the copy.

A regression test was added that fails for either of the above issues being present (figure names not matching after re-running analysis; figure names not settable from a run() keyword argument).


This is an automatic backport of pull request #1430 done by Mergify.

`ExperimentData._clear_results()` cleared `ExperimentData._figures` but
not the related `ExperimentData._db_data.figure_names` exposed as
`ExperimentData.figure_names`. `BaseAnalysis.run()` calls
`ExperimentData._clear_results()` so when a second analysis run produced
a different set of figure names from the first the `ExperimentData`
instance would be left a `figure_names` property with entries that did
not match the underlying figures data. Here, this issue is addressed by
also clearing `ExperimentData._db_data.figure_names`.

This issue was first noticed due to occasional failures of the
`test.database_service.test_db_experiment_data.TestDbExperimentData.test_copy_figure_artifacts`
test which runs a fake experiment and then adds a figure and artifact to
the experiment data. Then the tests copies the experiment data to test
the behavior of `copy()`. Occasionally, the adding of the figure occurs
before the background analysis thread runs. In this case, the figure
name gets added to `figure_names` before the results get cleared by the
analysis callback. Because of the bug described above, the old figure
name stays around in the original experiment data object but does not
copy to the new object because figure names are copied using the data in
`ExperimentData._figures` and not
`ExperimentData._db_data.figure_names`. A `block_for_results()` was
added to the experiment because in principle the `copy()` could occur
before the analysis clears results and then the two data objects would
not match, though this case has not been observed (only adding the
figure and then clearing it with analysis before copying so the copy is
the one missing the figure name has been observed; not the copy having
the name and not the original).

Addtionally, `BaseAnalysis.run()` handled the `figure_names` option
incorrectly when passes a keyword argument. Keyword arguments to passed
to `run()` cause the analysis class to copy itself and add the options
to the copy before running it. However, within the `run()` method,
`self.options.figure_names` was used for assigning figure names rather
than referencing the copy of the analysis class, so figure names could
not be set using `figure_names` as a keyword argument. This issues was
fixed by replacing `self` references with references to the copy.

A regression test was added that fails for either of the above issues
being present (figure names not matching after re-running analysis;
figure names not settable from a `run()` keyword argument).

(cherry picked from commit c4e9a52)
@coruscating coruscating merged commit 32813b8 into stable/0.6 Mar 31, 2024
11 checks passed
@mergify mergify bot deleted the mergify/bp/stable/0.6/pr-1430 branch March 31, 2024 18:51
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.

2 participants