From 7087e4ffdf925734e5776eca8884aa6e5b595a94 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 24 Jul 2025 16:18:35 +0200 Subject: [PATCH] Make custom_operators.rst tutorial compatible with DPF 25R2 --- .../custom_operators.rst | 4 --- .../custom_operators_and_plugins/index.rst | 3 -- .../python_plugins/custom_operator_example.py | 28 +++++++++++++------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/doc/source/user_guide/tutorials/custom_operators_and_plugins/custom_operators.rst b/doc/source/user_guide/tutorials/custom_operators_and_plugins/custom_operators.rst index 0836c0afa4c..f6d86378738 100644 --- a/doc/source/user_guide/tutorials/custom_operators_and_plugins/custom_operators.rst +++ b/doc/source/user_guide/tutorials/custom_operators_and_plugins/custom_operators.rst @@ -4,10 +4,6 @@ Custom operators ================ -.. note:: - - This tutorial requires DPF 11.0 or above. - This tutorial shows the basics of creating a custom operator in Python and loading it ont a server for use. .. note:: diff --git a/doc/source/user_guide/tutorials/custom_operators_and_plugins/index.rst b/doc/source/user_guide/tutorials/custom_operators_and_plugins/index.rst index 728596e31bb..5de7b41c0bd 100644 --- a/doc/source/user_guide/tutorials/custom_operators_and_plugins/index.rst +++ b/doc/source/user_guide/tutorials/custom_operators_and_plugins/index.rst @@ -45,9 +45,6 @@ For comprehensive examples on writing operator plugins, see :ref:`python_operato This tutorial shows how to create, load, and use a custom plugin containing a single custom operator. - +++ - Requires DPF 11.0 or above - .. grid-item-card:: Create a DPF plugin with multiple operators :text-align: center :class-header: sd-bg-light sd-text-dark diff --git a/src/ansys/dpf/core/examples/python_plugins/custom_operator_example.py b/src/ansys/dpf/core/examples/python_plugins/custom_operator_example.py index 942c5a5bbc4..ca646218f04 100644 --- a/src/ansys/dpf/core/examples/python_plugins/custom_operator_example.py +++ b/src/ansys/dpf/core/examples/python_plugins/custom_operator_example.py @@ -23,7 +23,6 @@ """Example of a custom DPF operator in Python.""" from ansys.dpf import core as dpf -from ansys.dpf.core.changelog import Changelog from ansys.dpf.core.custom_operator import CustomOperatorBase from ansys.dpf.core.operator_specification import ( CustomSpecification, @@ -75,14 +74,25 @@ def specification(self) -> CustomSpecification: category="my_category", # Optional, defaults to 'other' license="any_dpf_supported_increments", # Optional, defaults to None ) - # Set the changelog of the operator to track changes - spec.set_changelog( - Changelog() - .patch_bump("Describe a patch bump.") - .major_bump("Describe a major bump.") - .minor_bump("Describe a minor bump.") - .expect_version("1.1.0") # Checks the resulting version is as expected - ) + + # Operator changelog and versioning is only available after DPF 2025R2 + try: + from ansys.dpf.core.changelog import Changelog + + # Set the changelog of the operator to track changes + spec.set_changelog( + Changelog() + .patch_bump("Describe a patch bump.") + .major_bump("Describe a major bump.") + .minor_bump("Describe a minor bump.") + .expect_version("1.1.0") # Checks the resulting version is as expected + ) + except ModuleNotFoundError as e: + if "ansys.dpf.core.changelog" in e.msg: + pass + else: + raise e + return spec def run(self):