From a71703a534ef9b84a994ad5f7a5cf23512323572 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 9 Nov 2026 22:59:40 +0000 Subject: [PATCH 1/4] Test that the Element Data documentation says what is safe with threads --- .../tests/test_elementdata_documentation.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pipeline/fiftyone_pipeline_core/tests/test_elementdata_documentation.py diff --git a/pipeline/fiftyone_pipeline_core/tests/test_elementdata_documentation.py b/pipeline/fiftyone_pipeline_core/tests/test_elementdata_documentation.py new file mode 100644 index 00000000..58d88e28 --- /dev/null +++ b/pipeline/fiftyone_pipeline_core/tests/test_elementdata_documentation.py @@ -0,0 +1,26 @@ + +""" +The documentation of Element Data says it is safe to read from several threads +once the Flow Element that writes it has finished, and is not catered for when +written from several threads or read while another thread writes, as the +thread safety page of the specification requires. +""" + +import unittest + +from fiftyone_pipeline_core.elementdata import ElementData + + +class ElementDataDocumentationTests(unittest.TestCase): + + def test_the_documentation_says_what_is_safe_with_threads(self): + text = " ".join(ElementData.__doc__.split()) + self.assertIn("safe to read from several threads", text) + self.assertIn("once the Flow Element that writes it has finished", text) + self.assertIn("not catered for", text) + self.assertIn("written from several threads", text) + self.assertIn("read while another thread writes", text) + + +if __name__ == "__main__": + unittest.main() From 968d3ccd940138081bd3d80f1c501c1f9f4fe58e Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 9 Nov 2026 23:00:02 +0000 Subject: [PATCH 2/4] Say in the Element Data documentation what is safe with threads --- .../src/fiftyone_pipeline_core/elementdata.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py index 51fc0bc1..cc27c78f 100644 --- a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py +++ b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py @@ -28,6 +28,13 @@ class ElementData(object): Stores information created by a FlowElement based on FlowData. Stored in FlowData + Only the Flow Element that creates an instance writes it, so an instance + does not need to be safe to write from several threads. A finished + instance, once the Flow Element that writes it has finished, is safe to + read from several threads at once, as the members of a parallel group do. + Writing an instance from several threads, or reading it while another + thread writes it, is not catered for. + """ def __init__(self, flow_element): From 62cce3b3b1879cb3a7bbcc325dc8a12dcb1bde32 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 9 Nov 2026 23:00:26 +0000 Subject: [PATCH 3/4] Use the specification's words in the Element Data thread note --- .../src/fiftyone_pipeline_core/elementdata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py index cc27c78f..f7793405 100644 --- a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py +++ b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py @@ -32,7 +32,7 @@ class ElementData(object): does not need to be safe to write from several threads. A finished instance, once the Flow Element that writes it has finished, is safe to read from several threads at once, as the members of a parallel group do. - Writing an instance from several threads, or reading it while another + An instance that is written from several threads, or read while another thread writes it, is not catered for. """ From 3d93705ade3ccb2c0cefc6a2de97e4bb0a32be75 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Tue, 10 Nov 2026 10:29:44 +0000 Subject: [PATCH 4/4] Drop parallel groups, which Python does not have, from the Element Data thread note --- .../src/fiftyone_pipeline_core/elementdata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py index f7793405..5ee546d3 100644 --- a/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py +++ b/pipeline/fiftyone_pipeline_core/src/fiftyone_pipeline_core/elementdata.py @@ -31,8 +31,8 @@ class ElementData(object): Only the Flow Element that creates an instance writes it, so an instance does not need to be safe to write from several threads. A finished instance, once the Flow Element that writes it has finished, is safe to - read from several threads at once, as the members of a parallel group do. - An instance that is written from several threads, or read while another + read from several threads at once, such as the caller's own threads. An + instance that is written from several threads, or read while another thread writes it, is not catered for. """