ansys-fluent-core 0.28.dev0__py3-none-any.whl → 0.28.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-fluent-core might be problematic. Click here for more details.
- ansys/fluent/core/__init__.py +15 -16
- ansys/fluent/core/_version.py +1 -1
- ansys/fluent/core/codegen/allapigen.py +0 -3
- ansys/fluent/core/codegen/builtin_settingsgen.py +5 -20
- ansys/fluent/core/codegen/print_fluent_version.py +9 -14
- ansys/fluent/core/codegen/walk_api.py +57 -0
- ansys/fluent/core/fluent_connection.py +26 -22
- ansys/fluent/core/generated/api_tree/api_objects.json +1 -1
- ansys/fluent/core/generated/datamodel_252/meshing.py +21 -0
- ansys/fluent/core/generated/datamodel_252/preferences.py +14 -0
- ansys/fluent/core/generated/fluent_version_252.py +3 -3
- ansys/fluent/core/generated/meshing/tui_252.py +1451 -1396
- ansys/fluent/core/generated/solver/settings_252.py +9300 -6625
- ansys/fluent/core/generated/solver/settings_252.pyi +6625 -5423
- ansys/fluent/core/generated/solver/tui_252.py +5898 -5057
- ansys/fluent/core/journaling.py +4 -4
- ansys/fluent/core/launcher/fluent_container.py +31 -7
- ansys/fluent/core/launcher/launcher.py +3 -2
- ansys/fluent/core/launcher/launcher_utils.py +9 -0
- ansys/fluent/core/launcher/process_launch_string.py +8 -6
- ansys/fluent/core/launcher/pyfluent_enums.py +6 -3
- ansys/fluent/core/launcher/server_info.py +25 -2
- ansys/fluent/core/launcher/slurm_launcher.py +6 -3
- ansys/fluent/core/launcher/standalone_launcher.py +11 -9
- ansys/fluent/core/post_objects/post_helper.py +16 -10
- ansys/fluent/core/services/__init__.py +2 -0
- ansys/fluent/core/services/api_upgrade.py +11 -9
- ansys/fluent/core/services/app_utilities.py +408 -0
- ansys/fluent/core/services/datamodel_se.py +172 -58
- ansys/fluent/core/services/datamodel_tui.py +5 -2
- ansys/fluent/core/services/field_data.py +1 -0
- ansys/fluent/core/services/reduction.py +2 -0
- ansys/fluent/core/services/settings.py +5 -2
- ansys/fluent/core/session.py +27 -4
- ansys/fluent/core/session_pure_meshing.py +1 -1
- ansys/fluent/core/session_solver.py +0 -1
- ansys/fluent/core/solver/__init__.py +6 -0
- ansys/fluent/core/solver/flobject.py +15 -27
- ansys/fluent/core/solver/function/reduction.py +3 -0
- ansys/fluent/core/solver/settings_builtin_data.py +1 -1
- ansys/fluent/core/streaming_services/datamodel_event_streaming.py +13 -13
- ansys/fluent/core/streaming_services/events_streaming.py +336 -52
- ansys/fluent/tests/conftest.py +30 -0
- ansys/fluent/tests/test_builtin_settings.py +1 -1
- ansys/fluent/tests/test_codegen.py +0 -410
- ansys/fluent/tests/test_datamodel_api.py +429 -0
- ansys/fluent/tests/test_datamodel_service.py +64 -64
- ansys/fluent/tests/test_events_manager.py +24 -6
- ansys/fluent/tests/test_field_data.py +32 -0
- ansys/fluent/tests/test_launcher.py +30 -2
- ansys/fluent/tests/test_mapped_api.py +766 -0
- ansys/fluent/tests/test_reduction.py +30 -0
- ansys/fluent/tests/test_session.py +16 -1
- ansys/fluent/tests/test_settings_api.py +21 -0
- ansys/fluent/tests/test_solution_variables.py +27 -0
- ansys/fluent/tests/util/__init__.py +36 -0
- {ansys_fluent_core-0.28.dev0.dist-info → ansys_fluent_core-0.28.2.dist-info}/METADATA +4 -3
- {ansys_fluent_core-0.28.dev0.dist-info → ansys_fluent_core-0.28.2.dist-info}/RECORD +61 -58
- {ansys_fluent_core-0.28.dev0.dist-info → ansys_fluent_core-0.28.2.dist-info}/WHEEL +1 -1
- ansys/fluent/core/codegen/settingsgen_old.py +0 -535
- ansys/fluent/tests/fluent/test_version/test.py +0 -2
- {ansys_fluent_core-0.28.dev0.dist-info → ansys_fluent_core-0.28.2.dist-info}/AUTHORS +0 -0
- {ansys_fluent_core-0.28.dev0.dist-info → ansys_fluent_core-0.28.2.dist-info}/LICENSE +0 -0
|
@@ -6,7 +6,7 @@ import itertools
|
|
|
6
6
|
import logging
|
|
7
7
|
import os
|
|
8
8
|
from threading import RLock
|
|
9
|
-
from typing import Any, Callable, Iterator, NoReturn, Sequence
|
|
9
|
+
from typing import Any, Callable, Iterator, NoReturn, Sequence, TypeVar
|
|
10
10
|
|
|
11
11
|
from google.protobuf.json_format import MessageToDict, ParseDict
|
|
12
12
|
import grpc
|
|
@@ -28,7 +28,8 @@ from ansys.fluent.core.solver.error_message import allowed_name_error_message
|
|
|
28
28
|
from ansys.fluent.core.utils.fluent_version import FluentVersion
|
|
29
29
|
|
|
30
30
|
Path = list[tuple[str, str]]
|
|
31
|
-
|
|
31
|
+
PyMenuT = TypeVar("PyMenuT", bound="PyMenu")
|
|
32
|
+
ValueT = None | bool | int | float | str | Sequence["ValueT"] | dict[str, "ValueT"]
|
|
32
33
|
logger: logging.Logger = logging.getLogger("pyfluent.datamodel")
|
|
33
34
|
|
|
34
35
|
member_specs_oneof_fields = [
|
|
@@ -301,7 +302,7 @@ class DatamodelServiceImpl:
|
|
|
301
302
|
return self._stub.unsubscribeEvents(request, metadata=self._metadata)
|
|
302
303
|
|
|
303
304
|
|
|
304
|
-
def _convert_value_to_variant(val:
|
|
305
|
+
def _convert_value_to_variant(val: ValueT, var: Variant) -> None:
|
|
305
306
|
"""Convert a Python data type to Fluent's variant type."""
|
|
306
307
|
if isinstance(val, bool):
|
|
307
308
|
var.bool_state = val
|
|
@@ -322,7 +323,7 @@ def _convert_value_to_variant(val: _TValue, var: Variant) -> None:
|
|
|
322
323
|
_convert_value_to_variant(v, var.variant_map_state.item[k])
|
|
323
324
|
|
|
324
325
|
|
|
325
|
-
def _convert_variant_to_value(var: Variant) ->
|
|
326
|
+
def _convert_variant_to_value(var: Variant) -> ValueT:
|
|
326
327
|
"""Convert Fluent's variant type to a Python data type."""
|
|
327
328
|
if var.HasField("bool_state"):
|
|
328
329
|
return var.bool_state
|
|
@@ -495,7 +496,7 @@ class DatamodelService(StreamingService):
|
|
|
495
496
|
self.cache = DataModelCache() if pyfluent.DATAMODEL_USE_STATE_CACHE else None
|
|
496
497
|
self.version = version
|
|
497
498
|
|
|
498
|
-
def get_attribute_value(self, rules: str, path: str, attribute: str) ->
|
|
499
|
+
def get_attribute_value(self, rules: str, path: str, attribute: str) -> ValueT:
|
|
499
500
|
"""Get attribute value."""
|
|
500
501
|
request = DataModelProtoModule.GetAttributeValueRequest(
|
|
501
502
|
rules=rules, path=path, attribute=attribute
|
|
@@ -503,7 +504,7 @@ class DatamodelService(StreamingService):
|
|
|
503
504
|
response = self._impl.get_attribute_value(request)
|
|
504
505
|
return _convert_variant_to_value(response.result)
|
|
505
506
|
|
|
506
|
-
def get_state(self, rules: str, path: str) ->
|
|
507
|
+
def get_state(self, rules: str, path: str) -> ValueT:
|
|
507
508
|
"""Get state."""
|
|
508
509
|
request = DataModelProtoModule.GetStateRequest(rules=rules, path=path)
|
|
509
510
|
response = self._impl.get_state(request)
|
|
@@ -568,7 +569,7 @@ class DatamodelService(StreamingService):
|
|
|
568
569
|
version=self.version,
|
|
569
570
|
)
|
|
570
571
|
|
|
571
|
-
def set_state(self, rules: str, path: str, state:
|
|
572
|
+
def set_state(self, rules: str, path: str, state: ValueT) -> None:
|
|
572
573
|
"""Set state."""
|
|
573
574
|
request = DataModelProtoModule.SetStateRequest(
|
|
574
575
|
rules=rules, path=path, wait=True
|
|
@@ -601,7 +602,7 @@ class DatamodelService(StreamingService):
|
|
|
601
602
|
self,
|
|
602
603
|
rules: str,
|
|
603
604
|
path: str,
|
|
604
|
-
dict_state: dict[str,
|
|
605
|
+
dict_state: dict[str, ValueT],
|
|
605
606
|
recursive=False,
|
|
606
607
|
) -> None:
|
|
607
608
|
"""Update the dict."""
|
|
@@ -633,8 +634,8 @@ class DatamodelService(StreamingService):
|
|
|
633
634
|
)
|
|
634
635
|
|
|
635
636
|
def execute_command(
|
|
636
|
-
self, rules: str, path: str, command: str, args: dict[str,
|
|
637
|
-
) ->
|
|
637
|
+
self, rules: str, path: str, command: str, args: dict[str, ValueT]
|
|
638
|
+
) -> ValueT:
|
|
638
639
|
"""Execute the command."""
|
|
639
640
|
request = DataModelProtoModule.ExecuteCommandRequest(
|
|
640
641
|
rules=rules, path=path, command=command, wait=True
|
|
@@ -651,8 +652,8 @@ class DatamodelService(StreamingService):
|
|
|
651
652
|
return _convert_variant_to_value(response.result)
|
|
652
653
|
|
|
653
654
|
def execute_query(
|
|
654
|
-
self, rules: str, path: str, query: str, args: dict[str,
|
|
655
|
-
) ->
|
|
655
|
+
self, rules: str, path: str, query: str, args: dict[str, ValueT]
|
|
656
|
+
) -> ValueT:
|
|
656
657
|
"""Execute the query."""
|
|
657
658
|
request = DataModelProtoModule.ExecuteQueryRequest(
|
|
658
659
|
rules=rules, path=path, query=query
|
|
@@ -722,7 +723,7 @@ class DatamodelService(StreamingService):
|
|
|
722
723
|
self.subscriptions.unsubscribe_all()
|
|
723
724
|
|
|
724
725
|
def add_on_child_created(
|
|
725
|
-
self, rules: str, path: str, child_type: str,
|
|
726
|
+
self, rules: str, path: str, child_type: str, cb: Callable[[str], None]
|
|
726
727
|
) -> EventSubscription:
|
|
727
728
|
"""Add on child created."""
|
|
728
729
|
request_dict = {
|
|
@@ -737,11 +738,18 @@ class DatamodelService(StreamingService):
|
|
|
737
738
|
]
|
|
738
739
|
}
|
|
739
740
|
subscription = EventSubscription(self, path, request_dict)
|
|
740
|
-
|
|
741
|
+
|
|
742
|
+
def cb_grpc(child_type: str, child_name: str):
|
|
743
|
+
ppath = convert_se_path_to_path(path)
|
|
744
|
+
ppath.append((child_type, child_name))
|
|
745
|
+
child_path = convert_path_to_se_path(ppath)
|
|
746
|
+
cb(child_path)
|
|
747
|
+
|
|
748
|
+
self.event_streaming.register_callback(subscription.tag, cb_grpc)
|
|
741
749
|
return subscription
|
|
742
750
|
|
|
743
751
|
def add_on_deleted(
|
|
744
|
-
self, rules: str, path: str,
|
|
752
|
+
self, rules: str, path: str, cb: Callable[[], None]
|
|
745
753
|
) -> EventSubscription:
|
|
746
754
|
"""Add on deleted."""
|
|
747
755
|
request_dict = {
|
|
@@ -753,11 +761,11 @@ class DatamodelService(StreamingService):
|
|
|
753
761
|
]
|
|
754
762
|
}
|
|
755
763
|
subscription = EventSubscription(self, path, request_dict)
|
|
756
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
764
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
757
765
|
return subscription
|
|
758
766
|
|
|
759
767
|
def add_on_changed(
|
|
760
|
-
self, rules: str, path: str,
|
|
768
|
+
self, rules: str, path: str, cb: Callable[[ValueT], None]
|
|
761
769
|
) -> EventSubscription:
|
|
762
770
|
"""Add on changed."""
|
|
763
771
|
request_dict = {
|
|
@@ -769,11 +777,11 @@ class DatamodelService(StreamingService):
|
|
|
769
777
|
]
|
|
770
778
|
}
|
|
771
779
|
subscription = EventSubscription(self, path, request_dict)
|
|
772
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
780
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
773
781
|
return subscription
|
|
774
782
|
|
|
775
783
|
def add_on_affected(
|
|
776
|
-
self, rules: str, path: str,
|
|
784
|
+
self, rules: str, path: str, cb: Callable[[], None]
|
|
777
785
|
) -> EventSubscription:
|
|
778
786
|
"""Add on affected."""
|
|
779
787
|
request_dict = {
|
|
@@ -785,11 +793,11 @@ class DatamodelService(StreamingService):
|
|
|
785
793
|
]
|
|
786
794
|
}
|
|
787
795
|
subscription = EventSubscription(self, path, request_dict)
|
|
788
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
796
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
789
797
|
return subscription
|
|
790
798
|
|
|
791
799
|
def add_on_affected_at_type_path(
|
|
792
|
-
self, rules: str, path: str, child_type: str,
|
|
800
|
+
self, rules: str, path: str, child_type: str, cb: Callable[[], None]
|
|
793
801
|
) -> EventSubscription:
|
|
794
802
|
"""Add on affected at type path."""
|
|
795
803
|
request_dict = {
|
|
@@ -804,11 +812,16 @@ class DatamodelService(StreamingService):
|
|
|
804
812
|
]
|
|
805
813
|
}
|
|
806
814
|
subscription = EventSubscription(self, path, request_dict)
|
|
807
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
815
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
808
816
|
return subscription
|
|
809
817
|
|
|
810
|
-
def
|
|
811
|
-
self,
|
|
818
|
+
def add_on_command_executed_old(
|
|
819
|
+
self,
|
|
820
|
+
rules: str,
|
|
821
|
+
path: str,
|
|
822
|
+
command: str,
|
|
823
|
+
obj,
|
|
824
|
+
cb: Callable[[str, ValueT], None],
|
|
812
825
|
) -> EventSubscription:
|
|
813
826
|
"""Add on command executed."""
|
|
814
827
|
request_dict = {
|
|
@@ -823,11 +836,29 @@ class DatamodelService(StreamingService):
|
|
|
823
836
|
]
|
|
824
837
|
}
|
|
825
838
|
subscription = EventSubscription(self, path, request_dict)
|
|
826
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
839
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
840
|
+
return subscription
|
|
841
|
+
|
|
842
|
+
def add_on_command_executed(
|
|
843
|
+
self, rules: str, path: str, cb: Callable[[str, ValueT], None]
|
|
844
|
+
) -> EventSubscription:
|
|
845
|
+
"""Add on command executed."""
|
|
846
|
+
request_dict = {
|
|
847
|
+
"eventrequest": [
|
|
848
|
+
{
|
|
849
|
+
"rules": rules,
|
|
850
|
+
"commandExecutedEventRequest": {
|
|
851
|
+
"path": path,
|
|
852
|
+
},
|
|
853
|
+
}
|
|
854
|
+
]
|
|
855
|
+
}
|
|
856
|
+
subscription = EventSubscription(self, path, request_dict)
|
|
857
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
827
858
|
return subscription
|
|
828
859
|
|
|
829
860
|
def add_on_attribute_changed(
|
|
830
|
-
self, rules: str, path: str, attribute: str,
|
|
861
|
+
self, rules: str, path: str, attribute: str, cb: Callable[[ValueT], None]
|
|
831
862
|
) -> EventSubscription:
|
|
832
863
|
"""Add on attribute changed."""
|
|
833
864
|
request_dict = {
|
|
@@ -842,11 +873,16 @@ class DatamodelService(StreamingService):
|
|
|
842
873
|
]
|
|
843
874
|
}
|
|
844
875
|
subscription = EventSubscription(self, path, request_dict)
|
|
845
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
876
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
846
877
|
return subscription
|
|
847
878
|
|
|
848
879
|
def add_on_command_attribute_changed(
|
|
849
|
-
self,
|
|
880
|
+
self,
|
|
881
|
+
rules: str,
|
|
882
|
+
path: str,
|
|
883
|
+
command: str,
|
|
884
|
+
attribute: str,
|
|
885
|
+
cb: Callable[[ValueT], None],
|
|
850
886
|
) -> EventSubscription:
|
|
851
887
|
"""Add on command attribute changed."""
|
|
852
888
|
request_dict = {
|
|
@@ -862,7 +898,7 @@ class DatamodelService(StreamingService):
|
|
|
862
898
|
]
|
|
863
899
|
}
|
|
864
900
|
subscription = EventSubscription(self, path, request_dict)
|
|
865
|
-
self.event_streaming.register_callback(subscription.tag,
|
|
901
|
+
self.event_streaming.register_callback(subscription.tag, cb)
|
|
866
902
|
return subscription
|
|
867
903
|
|
|
868
904
|
|
|
@@ -887,6 +923,30 @@ def convert_path_to_se_path(path: Path) -> str:
|
|
|
887
923
|
return se_path
|
|
888
924
|
|
|
889
925
|
|
|
926
|
+
def convert_se_path_to_path(se_path: str) -> Path:
|
|
927
|
+
"""Convert a StateEngine path to a path structure.
|
|
928
|
+
|
|
929
|
+
Parameters
|
|
930
|
+
----------
|
|
931
|
+
se_path : str
|
|
932
|
+
StateEngine path.
|
|
933
|
+
|
|
934
|
+
Returns
|
|
935
|
+
-------
|
|
936
|
+
Path
|
|
937
|
+
path structure
|
|
938
|
+
"""
|
|
939
|
+
path = []
|
|
940
|
+
for comp in se_path.split("/"):
|
|
941
|
+
if comp:
|
|
942
|
+
if ":" in comp:
|
|
943
|
+
name, value = comp.split(":")
|
|
944
|
+
else:
|
|
945
|
+
name, value = comp, ""
|
|
946
|
+
path.append((name, value))
|
|
947
|
+
return path
|
|
948
|
+
|
|
949
|
+
|
|
890
950
|
class PyCallableStateObject:
|
|
891
951
|
"""Any object which can be called to get its state.
|
|
892
952
|
|
|
@@ -1048,7 +1108,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1048
1108
|
return self.get_state()
|
|
1049
1109
|
|
|
1050
1110
|
def add_on_attribute_changed(
|
|
1051
|
-
self, attribute: str, cb: Callable
|
|
1111
|
+
self, attribute: str, cb: Callable[[ValueT], None]
|
|
1052
1112
|
) -> EventSubscription:
|
|
1053
1113
|
"""Register a callback for when an attribute is changed.
|
|
1054
1114
|
|
|
@@ -1056,7 +1116,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1056
1116
|
----------
|
|
1057
1117
|
attribute : str
|
|
1058
1118
|
attribute name
|
|
1059
|
-
cb : Callable
|
|
1119
|
+
cb : Callable[[ValueT], None]
|
|
1060
1120
|
Callback function
|
|
1061
1121
|
|
|
1062
1122
|
Returns
|
|
@@ -1065,11 +1125,11 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1065
1125
|
EventSubscription instance which can be used to unregister the callback
|
|
1066
1126
|
"""
|
|
1067
1127
|
return self.service.add_on_attribute_changed(
|
|
1068
|
-
self.rules, convert_path_to_se_path(self.path), attribute,
|
|
1128
|
+
self.rules, convert_path_to_se_path(self.path), attribute, cb
|
|
1069
1129
|
)
|
|
1070
1130
|
|
|
1071
1131
|
def add_on_command_attribute_changed(
|
|
1072
|
-
self, command: str, attribute: str, cb: Callable
|
|
1132
|
+
self, command: str, attribute: str, cb: Callable[[ValueT], None]
|
|
1073
1133
|
) -> EventSubscription:
|
|
1074
1134
|
"""Register a callback for when an attribute is changed.
|
|
1075
1135
|
|
|
@@ -1079,7 +1139,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1079
1139
|
command name
|
|
1080
1140
|
attribute : str
|
|
1081
1141
|
attribute name
|
|
1082
|
-
cb : Callable
|
|
1142
|
+
cb : Callable[[ValueT], None]
|
|
1083
1143
|
Callback function
|
|
1084
1144
|
|
|
1085
1145
|
Returns
|
|
@@ -1088,7 +1148,7 @@ class PyStateContainer(PyCallableStateObject):
|
|
|
1088
1148
|
EventSubscription instance which can be used to unregister the callback
|
|
1089
1149
|
"""
|
|
1090
1150
|
return self.service.add_on_command_attribute_changed(
|
|
1091
|
-
self.rules, convert_path_to_se_path(self.path), command, attribute,
|
|
1151
|
+
self.rules, convert_path_to_se_path(self.path), command, attribute, cb
|
|
1092
1152
|
)
|
|
1093
1153
|
|
|
1094
1154
|
def __dir__(self):
|
|
@@ -1235,14 +1295,16 @@ class PyMenu(PyStateContainer):
|
|
|
1235
1295
|
self.rules, convert_path_to_se_path(self.path), command
|
|
1236
1296
|
)
|
|
1237
1297
|
|
|
1238
|
-
def add_on_child_created(
|
|
1298
|
+
def add_on_child_created(
|
|
1299
|
+
self, child_type: str, cb: Callable[[PyMenuT], None]
|
|
1300
|
+
) -> EventSubscription:
|
|
1239
1301
|
"""Register a callback for when a child object is created.
|
|
1240
1302
|
|
|
1241
1303
|
Parameters
|
|
1242
1304
|
----------
|
|
1243
1305
|
child_type : str
|
|
1244
1306
|
Type of the child object
|
|
1245
|
-
cb : Callable
|
|
1307
|
+
cb : Callable[[PyMenuT], None]
|
|
1246
1308
|
Callback function
|
|
1247
1309
|
|
|
1248
1310
|
Returns
|
|
@@ -1250,16 +1312,23 @@ class PyMenu(PyStateContainer):
|
|
|
1250
1312
|
EventSubscription
|
|
1251
1313
|
EventSubscription instance which can be used to unregister the callback
|
|
1252
1314
|
"""
|
|
1315
|
+
|
|
1316
|
+
def cb_service(child_path: str):
|
|
1317
|
+
child_path = convert_se_path_to_path(child_path)
|
|
1318
|
+
child_type, child_name = child_path[-1]
|
|
1319
|
+
child = getattr(self, child_type)[child_name]
|
|
1320
|
+
cb(child)
|
|
1321
|
+
|
|
1253
1322
|
return self.service.add_on_child_created(
|
|
1254
|
-
self.rules, convert_path_to_se_path(self.path), child_type,
|
|
1323
|
+
self.rules, convert_path_to_se_path(self.path), child_type, cb_service
|
|
1255
1324
|
)
|
|
1256
1325
|
|
|
1257
|
-
def add_on_deleted(self, cb: Callable) -> EventSubscription:
|
|
1326
|
+
def add_on_deleted(self, cb: Callable[[], None]) -> EventSubscription:
|
|
1258
1327
|
"""Register a callback for when the object is deleted.
|
|
1259
1328
|
|
|
1260
1329
|
Parameters
|
|
1261
1330
|
----------
|
|
1262
|
-
cb : Callable
|
|
1331
|
+
cb : Callable[[], None]
|
|
1263
1332
|
Callback function
|
|
1264
1333
|
|
|
1265
1334
|
Returns
|
|
@@ -1268,15 +1337,15 @@ class PyMenu(PyStateContainer):
|
|
|
1268
1337
|
EventSubscription instance which can be used to unregister the callback
|
|
1269
1338
|
"""
|
|
1270
1339
|
return self.service.add_on_deleted(
|
|
1271
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1340
|
+
self.rules, convert_path_to_se_path(self.path), cb
|
|
1272
1341
|
)
|
|
1273
1342
|
|
|
1274
|
-
def add_on_changed(self, cb: Callable) -> EventSubscription:
|
|
1343
|
+
def add_on_changed(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1275
1344
|
"""Register a callback for when the object is modified.
|
|
1276
1345
|
|
|
1277
1346
|
Parameters
|
|
1278
1347
|
----------
|
|
1279
|
-
cb : Callable
|
|
1348
|
+
cb : Callable[[PyMenuT], None]
|
|
1280
1349
|
Callback function
|
|
1281
1350
|
|
|
1282
1351
|
Returns
|
|
@@ -1284,16 +1353,20 @@ class PyMenu(PyStateContainer):
|
|
|
1284
1353
|
EventSubscription
|
|
1285
1354
|
EventSubscription instance which can be used to unregister the callback
|
|
1286
1355
|
"""
|
|
1356
|
+
|
|
1357
|
+
def cb_service(value: ValueT):
|
|
1358
|
+
cb(self)
|
|
1359
|
+
|
|
1287
1360
|
return self.service.add_on_changed(
|
|
1288
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1361
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1289
1362
|
)
|
|
1290
1363
|
|
|
1291
|
-
def add_on_affected(self, cb: Callable) -> EventSubscription:
|
|
1364
|
+
def add_on_affected(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1292
1365
|
"""Register a callback for when the object is affected.
|
|
1293
1366
|
|
|
1294
1367
|
Parameters
|
|
1295
1368
|
----------
|
|
1296
|
-
cb : Callable
|
|
1369
|
+
cb : Callable[[PyMenuT], None]
|
|
1297
1370
|
Callback function
|
|
1298
1371
|
|
|
1299
1372
|
Returns
|
|
@@ -1301,12 +1374,16 @@ class PyMenu(PyStateContainer):
|
|
|
1301
1374
|
EventSubscription
|
|
1302
1375
|
EventSubscription instance which can be used to unregister the callback
|
|
1303
1376
|
"""
|
|
1377
|
+
|
|
1378
|
+
def cb_service():
|
|
1379
|
+
cb(self)
|
|
1380
|
+
|
|
1304
1381
|
return self.service.add_on_affected(
|
|
1305
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1382
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1306
1383
|
)
|
|
1307
1384
|
|
|
1308
1385
|
def add_on_affected_at_type_path(
|
|
1309
|
-
self, child_type: str, cb: Callable
|
|
1386
|
+
self, child_type: str, cb: Callable[[PyMenuT], None]
|
|
1310
1387
|
) -> EventSubscription:
|
|
1311
1388
|
"""Register a callback for when the object is affected at child type.
|
|
1312
1389
|
|
|
@@ -1314,7 +1391,7 @@ class PyMenu(PyStateContainer):
|
|
|
1314
1391
|
----------
|
|
1315
1392
|
child_type : str
|
|
1316
1393
|
child type
|
|
1317
|
-
cb : Callable
|
|
1394
|
+
cb : Callable[[PyMenuT], None]
|
|
1318
1395
|
Callback function
|
|
1319
1396
|
|
|
1320
1397
|
Returns
|
|
@@ -1322,18 +1399,24 @@ class PyMenu(PyStateContainer):
|
|
|
1322
1399
|
EventSubscription
|
|
1323
1400
|
EventSubscription instance which can be used to unregister the callback
|
|
1324
1401
|
"""
|
|
1402
|
+
|
|
1403
|
+
def cb_service():
|
|
1404
|
+
cb(self)
|
|
1405
|
+
|
|
1325
1406
|
return self.service.add_on_affected_at_type_path(
|
|
1326
|
-
self.rules, convert_path_to_se_path(self.path), child_type,
|
|
1407
|
+
self.rules, convert_path_to_se_path(self.path), child_type, cb_service
|
|
1327
1408
|
)
|
|
1328
1409
|
|
|
1329
|
-
def
|
|
1410
|
+
def add_on_command_executed_old(
|
|
1411
|
+
self, command: str, cb: Callable[[PyMenuT, str, ValueT], None]
|
|
1412
|
+
) -> EventSubscription:
|
|
1330
1413
|
"""Register a callback for when a command is executed.
|
|
1331
1414
|
|
|
1332
1415
|
Parameters
|
|
1333
1416
|
----------
|
|
1334
1417
|
command : str
|
|
1335
|
-
|
|
1336
|
-
cb : Callable
|
|
1418
|
+
Command name
|
|
1419
|
+
cb : Callable[[PyMenuT, str, ValueT], None]
|
|
1337
1420
|
Callback function
|
|
1338
1421
|
|
|
1339
1422
|
Returns
|
|
@@ -1341,8 +1424,35 @@ class PyMenu(PyStateContainer):
|
|
|
1341
1424
|
EventSubscription
|
|
1342
1425
|
EventSubscription instance which can be used to unregister the callback
|
|
1343
1426
|
"""
|
|
1427
|
+
|
|
1428
|
+
def cb_service(command: str, args: ValueT):
|
|
1429
|
+
cb(self, command, args)
|
|
1430
|
+
|
|
1431
|
+
return self.service.add_on_command_executed_old(
|
|
1432
|
+
self.rules, convert_path_to_se_path(self.path), command, self, cb_service
|
|
1433
|
+
)
|
|
1434
|
+
|
|
1435
|
+
def add_on_command_executed(
|
|
1436
|
+
self, cb: Callable[[PyMenuT, str, ValueT], None]
|
|
1437
|
+
) -> EventSubscription:
|
|
1438
|
+
"""Register a callback for when a command is executed.
|
|
1439
|
+
|
|
1440
|
+
Parameters
|
|
1441
|
+
----------
|
|
1442
|
+
cb : Callable[[PyMenuT, str, ValueT], None]
|
|
1443
|
+
Callback function
|
|
1444
|
+
|
|
1445
|
+
Returns
|
|
1446
|
+
-------
|
|
1447
|
+
EventSubscription
|
|
1448
|
+
EventSubscription instance which can be used to unregister the callback
|
|
1449
|
+
"""
|
|
1450
|
+
|
|
1451
|
+
def cb_service(command: str, args: ValueT):
|
|
1452
|
+
cb(self, command, args)
|
|
1453
|
+
|
|
1344
1454
|
return self.service.add_on_command_executed(
|
|
1345
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1455
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1346
1456
|
)
|
|
1347
1457
|
|
|
1348
1458
|
|
|
@@ -1356,12 +1466,12 @@ class PyParameter(PyStateContainer):
|
|
|
1356
1466
|
"""Get default value of the parameter."""
|
|
1357
1467
|
return self.get_attr(Attribute.DEFAULT.value)
|
|
1358
1468
|
|
|
1359
|
-
def add_on_changed(self, cb: Callable) -> EventSubscription:
|
|
1469
|
+
def add_on_changed(self, cb: Callable[[PyMenuT], None]) -> EventSubscription:
|
|
1360
1470
|
"""Register a callback for when the object is modified.
|
|
1361
1471
|
|
|
1362
1472
|
Parameters
|
|
1363
1473
|
----------
|
|
1364
|
-
cb : Callable
|
|
1474
|
+
cb : Callable[[PyMenuT], None]
|
|
1365
1475
|
Callback function
|
|
1366
1476
|
|
|
1367
1477
|
Returns
|
|
@@ -1369,8 +1479,12 @@ class PyParameter(PyStateContainer):
|
|
|
1369
1479
|
EventSubscription
|
|
1370
1480
|
EventSubscription instance which can be used to unregister the callback
|
|
1371
1481
|
"""
|
|
1482
|
+
|
|
1483
|
+
def cb_service(value: ValueT):
|
|
1484
|
+
cb(self)
|
|
1485
|
+
|
|
1372
1486
|
return self.service.add_on_changed(
|
|
1373
|
-
self.rules, convert_path_to_se_path(self.path),
|
|
1487
|
+
self.rules, convert_path_to_se_path(self.path), cb_service
|
|
1374
1488
|
)
|
|
1375
1489
|
|
|
1376
1490
|
|
|
@@ -1577,7 +1691,7 @@ class PyNamedObjectContainer:
|
|
|
1577
1691
|
# On-deleted subscription objects are unsubscribed after the datamodel
|
|
1578
1692
|
# object is deleted.
|
|
1579
1693
|
self[key].add_on_deleted(
|
|
1580
|
-
lambda
|
|
1694
|
+
lambda: self.service.subscriptions.unsubscribe_while_deleting(
|
|
1581
1695
|
self.rules, se_path, "after"
|
|
1582
1696
|
)
|
|
1583
1697
|
)
|
|
@@ -125,10 +125,12 @@ class DatamodelService:
|
|
|
125
125
|
channel: grpc.Channel,
|
|
126
126
|
metadata: list[tuple[str, str]],
|
|
127
127
|
fluent_error_state,
|
|
128
|
+
app_utilities,
|
|
128
129
|
scheme_eval,
|
|
129
130
|
) -> None:
|
|
130
131
|
"""__init__ method of DatamodelService class."""
|
|
131
132
|
self._impl = DatamodelServiceImpl(channel, metadata, fluent_error_state)
|
|
133
|
+
self._app_utilities = app_utilities
|
|
132
134
|
self._scheme_eval = scheme_eval
|
|
133
135
|
|
|
134
136
|
def get_attribute_value(
|
|
@@ -170,7 +172,8 @@ class DatamodelService:
|
|
|
170
172
|
request = DataModelProtoModule.GetStaticInfoRequest()
|
|
171
173
|
request.path = path
|
|
172
174
|
response = self._impl.get_static_info(request)
|
|
173
|
-
|
|
175
|
+
# Note: MessageToDict's parameter names are different in different protobuf versions
|
|
176
|
+
return MessageToDict(response.info, True)
|
|
174
177
|
|
|
175
178
|
|
|
176
179
|
class PyMenu:
|
|
@@ -233,7 +236,7 @@ class PyMenu:
|
|
|
233
236
|
Query result (any Python datatype)
|
|
234
237
|
"""
|
|
235
238
|
with ApiUpgradeAdvisor(
|
|
236
|
-
self._service.
|
|
239
|
+
self._service._app_utilities,
|
|
237
240
|
self._version,
|
|
238
241
|
self._mode,
|
|
239
242
|
):
|
|
@@ -263,6 +263,8 @@ class Reduction:
|
|
|
263
263
|
raise ValueError(f"Invalid location input: '{loc}'")
|
|
264
264
|
|
|
265
265
|
def _get_location_string(self, locations, ctxt) -> List[str]:
|
|
266
|
+
if locations == []:
|
|
267
|
+
return []
|
|
266
268
|
for loc in locations:
|
|
267
269
|
if isinstance(loc, str):
|
|
268
270
|
self._validate_str_location(loc)
|
|
@@ -136,9 +136,12 @@ def _get_request_instance_for_path(request_class, path: str) -> Any:
|
|
|
136
136
|
class SettingsService:
|
|
137
137
|
"""Service for accessing and modifying Fluent settings."""
|
|
138
138
|
|
|
139
|
-
def __init__(
|
|
139
|
+
def __init__(
|
|
140
|
+
self, channel, metadata, app_utilities, scheme_eval, fluent_error_state
|
|
141
|
+
) -> None:
|
|
140
142
|
"""__init__ method of SettingsService class."""
|
|
141
143
|
self._service_impl = _SettingsServiceImpl(channel, metadata, fluent_error_state)
|
|
144
|
+
self._app_utilities = app_utilities
|
|
142
145
|
self._scheme_eval = scheme_eval
|
|
143
146
|
|
|
144
147
|
@_trace
|
|
@@ -369,7 +372,7 @@ class SettingsService:
|
|
|
369
372
|
"""Checks whether a name has a wildcard pattern."""
|
|
370
373
|
return self._scheme_eval.is_defined(
|
|
371
374
|
"has-fnmatch-wild-card?"
|
|
372
|
-
) and self.
|
|
375
|
+
) and self._app_utilities.is_wildcard(name)
|
|
373
376
|
|
|
374
377
|
@_trace
|
|
375
378
|
def is_interactive_mode(self) -> bool:
|