another-ayx-python-sdk 2.4.24__py3-none-any.whl → 2.5.0__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.
- another_ayx_python_sdk/__main__.py +2 -2
- another_ayx_python_sdk/examples/AyxSdkInput/main.py +1 -1
- another_ayx_python_sdk/examples/requirements.txt +1 -1
- another_ayx_python_sdk/version.py +3 -3
- another_ayx_python_sdk-2.5.0.dist-info/METADATA +151 -0
- {another_ayx_python_sdk-2.4.24.dist-info → another_ayx_python_sdk-2.5.0.dist-info}/RECORD +10 -215
- {another_ayx_python_sdk-2.4.24.dist-info → another_ayx_python_sdk-2.5.0.dist-info}/WHEEL +1 -1
- {another_ayx_python_sdk-2.4.24.dist-info → another_ayx_python_sdk-2.5.0.dist-info}/top_level.txt +0 -2
- another_ayx_python_sdk-2.4.24.dist-info/METADATA +0 -63
- build/lib/another_ayx_python_sdk/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/__main__.py +0 -470
- build/lib/another_ayx_python_sdk/assets/workspace_files/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/assets/workspace_files/setup.py +0 -38
- build/lib/another_ayx_python_sdk/cli/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/cli/utilities.py +0 -103
- build/lib/another_ayx_python_sdk/cli/workspace.py +0 -266
- build/lib/another_ayx_python_sdk/cli/yxi_builder.py +0 -125
- build/lib/another_ayx_python_sdk/cli/yxi_installer.py +0 -45
- build/lib/another_ayx_python_sdk/core/__init__.py +0 -51
- build/lib/another_ayx_python_sdk/core/constants.py +0 -25
- build/lib/another_ayx_python_sdk/core/dcm_base.py +0 -115
- build/lib/another_ayx_python_sdk/core/doc_utilities.py +0 -40
- build/lib/another_ayx_python_sdk/core/environment_base.py +0 -213
- build/lib/another_ayx_python_sdk/core/exceptions.py +0 -59
- build/lib/another_ayx_python_sdk/core/field.py +0 -183
- build/lib/another_ayx_python_sdk/core/input_anchor_base.py +0 -86
- build/lib/another_ayx_python_sdk/core/input_connection_base.py +0 -206
- build/lib/another_ayx_python_sdk/core/io_base.py +0 -139
- build/lib/another_ayx_python_sdk/core/metadata.py +0 -173
- build/lib/another_ayx_python_sdk/core/observable_mixin.py +0 -90
- build/lib/another_ayx_python_sdk/core/output_anchor_base.py +0 -151
- build/lib/another_ayx_python_sdk/core/plugin.py +0 -108
- build/lib/another_ayx_python_sdk/core/plugin_v2.py +0 -97
- build/lib/another_ayx_python_sdk/core/provider_base.py +0 -125
- build/lib/another_ayx_python_sdk/core/proxy_requests.py +0 -51
- build/lib/another_ayx_python_sdk/core/record_packet.py +0 -88
- build/lib/another_ayx_python_sdk/core/record_packet_base.py +0 -123
- build/lib/another_ayx_python_sdk/core/register_plugin.py +0 -127
- build/lib/another_ayx_python_sdk/core/testing.py +0 -191
- build/lib/another_ayx_python_sdk/core/utils.py +0 -146
- build/lib/another_ayx_python_sdk/examples/AyxSdkInput/main.py +0 -89
- build/lib/another_ayx_python_sdk/examples/AyxSdkMultiConnectionsMultiOutputAnchor/main.py +0 -102
- build/lib/another_ayx_python_sdk/examples/AyxSdkMultipleInputAnchors/main.py +0 -84
- build/lib/another_ayx_python_sdk/examples/AyxSdkMultipleOutputAnchors/main.py +0 -96
- build/lib/another_ayx_python_sdk/examples/AyxSdkOptionalInputAnchor/main.py +0 -94
- build/lib/another_ayx_python_sdk/examples/AyxSdkOutput/main.py +0 -78
- build/lib/another_ayx_python_sdk/examples/AyxSdkPassThrough/main.py +0 -82
- build/lib/another_ayx_python_sdk/providers/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/providers/amp_provider/__init__.py +0 -41
- build/lib/another_ayx_python_sdk/providers/amp_provider/__main__.py +0 -85
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_dcm.py +0 -58
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_driver.py +0 -358
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_environment.py +0 -73
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_environment_v2.py +0 -278
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_input_anchor.py +0 -73
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_input_connection.py +0 -132
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_io.py +0 -64
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_io_components.py +0 -407
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_output_anchor.py +0 -107
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_provider.py +0 -68
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_provider_v2.py +0 -128
- build/lib/another_ayx_python_sdk/providers/amp_provider/amp_record_packet.py +0 -21
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/__init__.py +0 -32
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/input_anchor_builder.py +0 -123
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/input_connection_builder.py +0 -95
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/metadata_builder.py +0 -118
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/output_anchor_builder.py +0 -110
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/packers.py +0 -458
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/record_builder.py +0 -204
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/record_packet_builder.py +0 -133
- build/lib/another_ayx_python_sdk/providers/amp_provider/builders/tool_config_builder.py +0 -59
- build/lib/another_ayx_python_sdk/providers/amp_provider/cng_certs.py +0 -197
- build/lib/another_ayx_python_sdk/providers/amp_provider/data_transport/__init__.py +0 -18
- build/lib/another_ayx_python_sdk/providers/amp_provider/data_transport/amp_transport.py +0 -127
- build/lib/another_ayx_python_sdk/providers/amp_provider/data_transport/transport_base.py +0 -35
- build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_helpers/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_helpers/control_msgs.py +0 -189
- build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_helpers/dcme_msgs.py +0 -119
- build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_helpers/record_transfer_msgs.py +0 -32
- build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_util.py +0 -161
- build/lib/another_ayx_python_sdk/providers/amp_provider/logger_config.py +0 -63
- build/lib/another_ayx_python_sdk/providers/amp_provider/plugin_class_loader.py +0 -77
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/__init__.py +0 -67
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/dcm_repository.py +0 -252
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/environment_repository.py +0 -212
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/grpc_repository.py +0 -119
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/input_anchor_repository.py +0 -110
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/input_connection_repository.py +0 -276
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/input_metadata_repository.py +0 -144
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/input_record_packet_repository.py +0 -252
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/io_repository.py +0 -188
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/output_anchor_repository.py +0 -117
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/output_metadata_repository.py +0 -129
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/output_record_packet_repository.py +0 -170
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/plugin_class_repository.py +0 -55
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/singleton.py +0 -32
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/test_harness_state_repository.py +0 -172
- build/lib/another_ayx_python_sdk/providers/amp_provider/repositories/tool_config_repository.py +0 -89
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/__init__.py +0 -0
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/close_outgoing_anchor_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/close_outgoing_anchor_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/dcm_e_pb2.py +0 -38
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/dcm_e_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_anchor_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_anchor_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_connection_complete_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_connection_complete_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_connection_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_connection_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_data_push_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_data_push_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_record_packet_push_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/incoming_record_packet_push_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/metadata_pb2.py +0 -31
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/metadata_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_anchor_pb2.py +0 -28
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_anchor_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_data_push_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_data_push_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_metadata_push_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_metadata_push_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_record_packet_push_pb2.py +0 -26
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/outgoing_record_packet_push_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/output_message_data_pb2.py +0 -29
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/output_message_data_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/password_data_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/password_data_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/plugin_initialization_data_pb2.py +0 -33
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/plugin_initialization_data_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/record_batch_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/record_batch_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/record_packet_pb2.py +0 -29
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/record_packet_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_engine_service_pb2.py +0 -34
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_engine_service_pb2_grpc.py +0 -305
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_pb2.py +0 -30
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_pb2_grpc.py +0 -235
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_startup_info_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_startup_info_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_v2_pb2.py +0 -54
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/sdk_tool_service_v2_pb2_grpc.py +0 -99
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/translate_message_data_pb2.py +0 -27
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/translate_message_data_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/transport_pb2.py +0 -31
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/transport_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/update_progress_pb2.py +0 -25
- build/lib/another_ayx_python_sdk/providers/amp_provider/resources/generated/update_progress_pb2_grpc.py +0 -4
- build/lib/another_ayx_python_sdk/providers/amp_provider/sdk_tool_runner.py +0 -115
- build/lib/another_ayx_python_sdk/providers/amp_provider/sdk_tool_service.py +0 -207
- build/lib/another_ayx_python_sdk/providers/amp_provider/sdk_tool_service_v2.py +0 -306
- build/lib/another_ayx_python_sdk/providers/amp_provider/utilities/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/providers/amp_provider/utilities/constants.py +0 -22
- build/lib/another_ayx_python_sdk/providers/amp_provider/utilities/conversions.py +0 -55
- build/lib/another_ayx_python_sdk/providers/amp_provider/utilities/utilities.py +0 -63
- build/lib/another_ayx_python_sdk/providers/e1_provider/__init__.py +0 -36
- build/lib/another_ayx_python_sdk/providers/e1_provider/anchor_builder.py +0 -95
- build/lib/another_ayx_python_sdk/providers/e1_provider/cache_e1_sdk_import.py +0 -31
- build/lib/another_ayx_python_sdk/providers/e1_provider/connection_callback_strategy.py +0 -155
- build/lib/another_ayx_python_sdk/providers/e1_provider/connection_interface.py +0 -125
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_dcm.py +0 -53
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_environment.py +0 -127
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_input_anchor.py +0 -51
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_input_anchor_proxy.py +0 -33
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_input_connection.py +0 -87
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_io.py +0 -71
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_output_anchor.py +0 -157
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_output_anchor_proxy.py +0 -97
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_plugin_driver.py +0 -63
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_plugin_proxy.py +0 -363
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_provider.py +0 -71
- build/lib/another_ayx_python_sdk/providers/e1_provider/e1_record_packet.py +0 -21
- build/lib/another_ayx_python_sdk/providers/e1_provider/events.py +0 -36
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/__init__.py +0 -37
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/alteryx_engine.py +0 -105
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/constants.py +0 -50
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/field.py +0 -122
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/output_anchor.py +0 -55
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/output_anchor_manager.py +0 -31
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/record_copier.py +0 -65
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/record_creator.py +0 -41
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/record_info.py +0 -134
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/record_ref.py +0 -42
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/tool.py +0 -29
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/AlteryxPythonSDK/tool_execution_info.py +0 -43
- build/lib/another_ayx_python_sdk/providers/e1_provider/mock_e1_sdk/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/providers/e1_provider/proxies/__init__.py +0 -18
- build/lib/another_ayx_python_sdk/providers/e1_provider/proxies/field_proxy.py +0 -109
- build/lib/another_ayx_python_sdk/providers/e1_provider/proxies/record_copier_proxy.py +0 -49
- build/lib/another_ayx_python_sdk/providers/e1_provider/records/__init__.py +0 -23
- build/lib/another_ayx_python_sdk/providers/e1_provider/records/base_record_container.py +0 -47
- build/lib/another_ayx_python_sdk/providers/e1_provider/records/parsed_record_container.py +0 -67
- build/lib/another_ayx_python_sdk/providers/e1_provider/records/raw_record_container.py +0 -111
- build/lib/another_ayx_python_sdk/providers/e1_provider/tool_config_loader.py +0 -132
- build/lib/another_ayx_python_sdk/providers/e1_provider/utilities/__init__.py +0 -35
- build/lib/another_ayx_python_sdk/providers/e1_provider/utilities/utilities.py +0 -54
- build/lib/another_ayx_python_sdk/providers/e1_provider/workflow_config.py +0 -31
- build/lib/another_ayx_python_sdk/providers/file_provider/__init__.py +0 -32
- build/lib/another_ayx_python_sdk/providers/file_provider/environment.py +0 -131
- build/lib/another_ayx_python_sdk/providers/file_provider/file_adapter.py +0 -286
- build/lib/another_ayx_python_sdk/providers/file_provider/file_provider.py +0 -185
- build/lib/another_ayx_python_sdk/providers/file_provider/file_provider_dcm.py +0 -53
- build/lib/another_ayx_python_sdk/providers/file_provider/file_provider_input_anchor.py +0 -70
- build/lib/another_ayx_python_sdk/providers/file_provider/file_provider_input_connection.py +0 -112
- build/lib/another_ayx_python_sdk/providers/file_provider/file_provider_output_anchor.py +0 -114
- build/lib/another_ayx_python_sdk/providers/file_provider/file_record_packet.py +0 -21
- build/lib/another_ayx_python_sdk/providers/file_provider/iox.py +0 -56
- build/lib/another_ayx_python_sdk/providers/file_provider/tool_input.py +0 -104
- build/lib/another_ayx_python_sdk/test_harness/__init__.py +0 -14
- build/lib/another_ayx_python_sdk/test_harness/__main__.py +0 -120
- build/lib/another_ayx_python_sdk/test_harness/plugin_runner.py +0 -416
- build/lib/another_ayx_python_sdk/test_harness/process_lifecycle_manager.py +0 -80
- build/lib/another_ayx_python_sdk/test_harness/sdk_engine_service.py +0 -106
- build/lib/another_ayx_python_sdk/version.py +0 -8
- {another_ayx_python_sdk-2.4.24.dist-info → another_ayx_python_sdk-2.5.0.dist-info}/entry_points.txt +0 -0
- {another_ayx_python_sdk-2.4.24.dist-info → another_ayx_python_sdk-2.5.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,189 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""Helper functions to create record transfer message types."""
|
15
|
-
import logging
|
16
|
-
from functools import wraps
|
17
|
-
from typing import Callable, Dict, TYPE_CHECKING
|
18
|
-
from uuid import uuid4
|
19
|
-
|
20
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.outgoing_metadata_push_pb2 import (
|
21
|
-
OutgoingMetadataPush,
|
22
|
-
)
|
23
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.output_message_data_pb2 import (
|
24
|
-
OutputMessageData,
|
25
|
-
OutputMessageTypes,
|
26
|
-
)
|
27
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.password_data_pb2 import (
|
28
|
-
PasswordData,
|
29
|
-
)
|
30
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.sdk_tool_service_v2_pb2 import (
|
31
|
-
ControlOut,
|
32
|
-
)
|
33
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.translate_message_data_pb2 import (
|
34
|
-
TranslateMessageData,
|
35
|
-
)
|
36
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.update_progress_pb2 import (
|
37
|
-
UpdateProgress,
|
38
|
-
)
|
39
|
-
|
40
|
-
if TYPE_CHECKING:
|
41
|
-
from pyarrow import Schema # noqa F401
|
42
|
-
|
43
|
-
|
44
|
-
OUTPUT_MSG = "output_message"
|
45
|
-
TRANSLATED_MSG = "translated_message"
|
46
|
-
TRANSLATE_MSG = "translate_message"
|
47
|
-
DECRYPT_PW = "decrypt_password"
|
48
|
-
DCME_REQ = "dcm_e_request"
|
49
|
-
METADATA_MSG = "outgoing_metadata"
|
50
|
-
UPDATE_MSG = "update_progress"
|
51
|
-
|
52
|
-
ACCEPTED_PAYLOADS = set(
|
53
|
-
[OUTPUT_MSG, TRANSLATE_MSG, DECRYPT_PW, DCME_REQ, METADATA_MSG, UPDATE_MSG]
|
54
|
-
)
|
55
|
-
|
56
|
-
logger = logging.getLogger()
|
57
|
-
|
58
|
-
|
59
|
-
def ctrl_out_wrapper(which_payload: str, set_id: bool = False) -> Callable:
|
60
|
-
"""Wrap a payload, returned by the decorated function, in a ControlOut message."""
|
61
|
-
|
62
|
-
def _inner(func: Callable) -> Callable:
|
63
|
-
@wraps(func)
|
64
|
-
def set_payload(*args: tuple, **kwargs: dict) -> ControlOut:
|
65
|
-
if which_payload not in ACCEPTED_PAYLOADS:
|
66
|
-
logger.error("Can not assign CtrlOut payload %s", which_payload)
|
67
|
-
raise AttributeError
|
68
|
-
msg = ControlOut()
|
69
|
-
if set_id:
|
70
|
-
msg.msg_id = str(uuid4())
|
71
|
-
ptr_msg_payload = getattr(msg, which_payload)
|
72
|
-
ptr_msg_payload.CopyFrom(func(*args, **kwargs))
|
73
|
-
return msg
|
74
|
-
|
75
|
-
return set_payload
|
76
|
-
|
77
|
-
return _inner
|
78
|
-
|
79
|
-
|
80
|
-
def _output_msg_data(control_values: Dict) -> ControlOut:
|
81
|
-
return ControlOut(output_message=OutputMessageData(**control_values))
|
82
|
-
|
83
|
-
|
84
|
-
def _translate_msg(control_values: Dict) -> ControlOut:
|
85
|
-
ctrl_out_msg = ControlOut(translate_message=TranslateMessageData(**control_values))
|
86
|
-
ctrl_out_msg.msg_id = str(uuid4())
|
87
|
-
return ctrl_out_msg
|
88
|
-
|
89
|
-
|
90
|
-
def _decrypt_password(control_values: Dict) -> ControlOut:
|
91
|
-
msg = ControlOut(decrypt_password=PasswordData(**control_values))
|
92
|
-
msg.msg_id = str(uuid4())
|
93
|
-
return msg
|
94
|
-
|
95
|
-
|
96
|
-
def _confirm_complete() -> ControlOut:
|
97
|
-
msg = ControlOut()
|
98
|
-
msg.confirm_complete.SetInParent()
|
99
|
-
return msg
|
100
|
-
|
101
|
-
|
102
|
-
ctrl_out_payload_fn = {
|
103
|
-
OUTPUT_MSG: _output_msg_data,
|
104
|
-
TRANSLATE_MSG: _translate_msg,
|
105
|
-
DECRYPT_PW: _decrypt_password,
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
def new_control_out_msg(control_values: dict, oneof_key: str) -> ControlOut:
|
110
|
-
"""Create a ControlOut msg from passed values and payload key."""
|
111
|
-
if oneof_key == "confirm_complete":
|
112
|
-
return _confirm_complete()
|
113
|
-
new_msg_w_payload = ctrl_out_payload_fn[oneof_key]
|
114
|
-
return new_msg_w_payload(control_values)
|
115
|
-
|
116
|
-
|
117
|
-
@ctrl_out_wrapper(OUTPUT_MSG)
|
118
|
-
def new_ctrl_out_error_msg(err_msg: str, priority: int) -> ControlOut:
|
119
|
-
"""Create a message with the Error type flag."""
|
120
|
-
msg_data = {
|
121
|
-
"message_type": OutputMessageTypes.OMT_Error,
|
122
|
-
"message": err_msg,
|
123
|
-
"priority": priority,
|
124
|
-
}
|
125
|
-
return OutputMessageData(**msg_data)
|
126
|
-
|
127
|
-
|
128
|
-
@ctrl_out_wrapper(OUTPUT_MSG)
|
129
|
-
def new_ctrl_out_info_msg(info_msg: str, priority: int) -> ControlOut:
|
130
|
-
"""Create a message with the Info type flag."""
|
131
|
-
msg_data = {
|
132
|
-
"message_type": OutputMessageTypes.OMT_Info,
|
133
|
-
"message": info_msg,
|
134
|
-
"priority": priority,
|
135
|
-
}
|
136
|
-
return OutputMessageData(**msg_data)
|
137
|
-
|
138
|
-
|
139
|
-
@ctrl_out_wrapper(OUTPUT_MSG)
|
140
|
-
def new_ctrl_out_warn_msg(warn_msg: str, priority: int) -> ControlOut:
|
141
|
-
"""Create a message with the Warn type flag."""
|
142
|
-
msg_data = {
|
143
|
-
"message_type": OutputMessageTypes.OMT_Warning,
|
144
|
-
"message": warn_msg,
|
145
|
-
"priority": priority,
|
146
|
-
}
|
147
|
-
return OutputMessageData(**msg_data)
|
148
|
-
|
149
|
-
|
150
|
-
@ctrl_out_wrapper(OUTPUT_MSG)
|
151
|
-
def new_ctrl_out_save_config(tool_config: str) -> ControlOut:
|
152
|
-
"""Create a message with the Warn type flag."""
|
153
|
-
msg_data = {
|
154
|
-
"message_type": OutputMessageTypes.OMT_UpdateOutputConfigXml,
|
155
|
-
"message": tool_config,
|
156
|
-
}
|
157
|
-
return OutputMessageData(**msg_data)
|
158
|
-
|
159
|
-
|
160
|
-
@ctrl_out_wrapper(TRANSLATE_MSG, set_id=True)
|
161
|
-
def new_ctrl_out_translate_msg(msg: str, *args) -> ControlOut: # type: ignore
|
162
|
-
"""Create a ControlOut.translate_message."""
|
163
|
-
msg_data = {
|
164
|
-
"unlocalized_string": msg,
|
165
|
-
"interpolation_data": [str(arg) for arg in args] if len(args) > 0 else [],
|
166
|
-
}
|
167
|
-
return TranslateMessageData(**msg_data)
|
168
|
-
|
169
|
-
|
170
|
-
@ctrl_out_wrapper(DECRYPT_PW, set_id=True)
|
171
|
-
def new_ctrl_out_decrypt_msg(pw: str) -> ControlOut:
|
172
|
-
"""Create ControlOut.decrypt_password."""
|
173
|
-
return PasswordData(password=pw)
|
174
|
-
|
175
|
-
|
176
|
-
@ctrl_out_wrapper(METADATA_MSG)
|
177
|
-
def new_ctrl_out_metadata_msg(anchor_name: str, metadata: "Schema") -> ControlOut:
|
178
|
-
"""Create ControlOut.outgoing_metadata_push."""
|
179
|
-
as_bytes = metadata.serialize().to_pybytes()
|
180
|
-
return OutgoingMetadataPush(output_anchor_name=anchor_name, schema=as_bytes)
|
181
|
-
|
182
|
-
|
183
|
-
@ctrl_out_wrapper(UPDATE_MSG)
|
184
|
-
def new_ctrl_out_update_progress_msg(progress: float) -> ControlOut:
|
185
|
-
"""Create ControlOut.outgoing_metadata_push."""
|
186
|
-
msg_data = {
|
187
|
-
"value": progress,
|
188
|
-
}
|
189
|
-
return UpdateProgress(**msg_data)
|
@@ -1,119 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""AMP Provider: Proxy class for DCM API."""
|
15
|
-
import datetime as dt
|
16
|
-
from typing import Dict, Optional
|
17
|
-
|
18
|
-
from another_ayx_python_sdk.core.exceptions import DcmEError, DcmEException
|
19
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.dcm_e_pb2 import (
|
20
|
-
DcmERequest,
|
21
|
-
DcmEResponse,
|
22
|
-
)
|
23
|
-
|
24
|
-
from google.protobuf import json_format
|
25
|
-
from google.protobuf.struct_pb2 import Struct
|
26
|
-
|
27
|
-
from .control_msgs import DCME_REQ, ctrl_out_wrapper
|
28
|
-
|
29
|
-
|
30
|
-
@ctrl_out_wrapper(DCME_REQ, set_id=True)
|
31
|
-
def get_connection_msg(connection_id: str) -> DcmERequest: # noqa: D102
|
32
|
-
"""Create a connection request message."""
|
33
|
-
req = DcmERequest()
|
34
|
-
req.v2.get_connection.connection_id = connection_id
|
35
|
-
return req
|
36
|
-
|
37
|
-
|
38
|
-
@ctrl_out_wrapper(DCME_REQ, set_id=True)
|
39
|
-
def get_write_lock_msg(
|
40
|
-
connection_id: str,
|
41
|
-
role: str,
|
42
|
-
secret_type: str,
|
43
|
-
expires_in: Optional[dt.datetime] = None,
|
44
|
-
) -> DcmERequest: # noqa: D102
|
45
|
-
"""Create a LockSecret message."""
|
46
|
-
req = DcmERequest()
|
47
|
-
req.v2.lock_secret.connection_id = connection_id
|
48
|
-
req.v2.lock_secret.credential_role = role
|
49
|
-
req.v2.lock_secret.secret_type = secret_type
|
50
|
-
if expires_in:
|
51
|
-
req.v2.lock_secret.expires_in = expires_in.isoformat()
|
52
|
-
return req
|
53
|
-
|
54
|
-
|
55
|
-
@ctrl_out_wrapper(DCME_REQ, set_id=True)
|
56
|
-
def free_write_lock_msg(
|
57
|
-
connection_id: str, role: str, secret_type: str, lock_id: str
|
58
|
-
) -> DcmERequest: # noqa: D102
|
59
|
-
"""Create a UnlockSecret message."""
|
60
|
-
req = DcmERequest()
|
61
|
-
req.v2.unlock_secret.connection_id = connection_id
|
62
|
-
req.v2.unlock_secret.credential_role = role
|
63
|
-
req.v2.unlock_secret.secret_type = secret_type
|
64
|
-
req.v2.unlock_secret.lock_id = lock_id
|
65
|
-
return req
|
66
|
-
|
67
|
-
|
68
|
-
@ctrl_out_wrapper(DCME_REQ, set_id=True)
|
69
|
-
def update_connection_secret_msg(
|
70
|
-
connection_id: str,
|
71
|
-
lock_id: str,
|
72
|
-
role: str,
|
73
|
-
secret_type: str,
|
74
|
-
value: str,
|
75
|
-
expires_on: Optional[dt.datetime],
|
76
|
-
parameters: Optional[Dict[str, str]],
|
77
|
-
) -> DcmERequest: # noqa: D102
|
78
|
-
"""Create UpdateSecret message."""
|
79
|
-
req = DcmERequest()
|
80
|
-
req.v2.update_secret.connection_id = connection_id
|
81
|
-
req.v2.update_secret.lock_id = lock_id
|
82
|
-
req.v2.update_secret.credential_role = role
|
83
|
-
req.v2.update_secret.secret_type = secret_type
|
84
|
-
req.v2.update_secret.value = value
|
85
|
-
if parameters:
|
86
|
-
st = Struct()
|
87
|
-
st.update(parameters)
|
88
|
-
req.v2.update_secret.parameters.CopyFrom(st)
|
89
|
-
if expires_on:
|
90
|
-
req.v2.update_secret.expires_on = expires_on.isoformat()
|
91
|
-
return req
|
92
|
-
|
93
|
-
|
94
|
-
def handle_response(res: DcmEResponse) -> Dict:
|
95
|
-
"""Handle DcmE response."""
|
96
|
-
response_dict = json_format.MessageToDict(res.response)
|
97
|
-
if not res.success:
|
98
|
-
if "message" in response_dict.keys() and "errorCode" in response_dict.keys():
|
99
|
-
if "detail" in response_dict.keys():
|
100
|
-
response_dict["dcme_exception"] = DcmEException(
|
101
|
-
"Dcm.E Error!",
|
102
|
-
DcmEError(
|
103
|
-
response_dict["message"],
|
104
|
-
int(response_dict["errorCode"]),
|
105
|
-
response_dict["detail"],
|
106
|
-
),
|
107
|
-
)
|
108
|
-
else:
|
109
|
-
response_dict["dcme_exception"] = DcmEException(
|
110
|
-
"Dcm.E Error!",
|
111
|
-
DcmEError(
|
112
|
-
response_dict["message"], int(response_dict["errorCode"])
|
113
|
-
),
|
114
|
-
)
|
115
|
-
else:
|
116
|
-
response_dict["dcme_exception"] = DcmEException(
|
117
|
-
"Dcm.E Error!", DcmEError(res.response, 10003)
|
118
|
-
)
|
119
|
-
return response_dict
|
build/lib/another_ayx_python_sdk/providers/amp_provider/grpc_helpers/record_transfer_msgs.py
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""Helper functions to create record transfer message types."""
|
15
|
-
|
16
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.sdk_tool_service_v2_pb2 import (
|
17
|
-
OutgoingRecords,
|
18
|
-
RecordTransferOut,
|
19
|
-
WantRecords,
|
20
|
-
)
|
21
|
-
|
22
|
-
|
23
|
-
def new_record_transfer_out_msg(
|
24
|
-
record_values: dict, oneof_key: str
|
25
|
-
) -> RecordTransferOut:
|
26
|
-
"""Create a RecordTransferOut msg from passed values and payload key."""
|
27
|
-
msg = RecordTransferOut()
|
28
|
-
if oneof_key == "outgoing_records":
|
29
|
-
msg = RecordTransferOut(outgoing_records=OutgoingRecords(**record_values))
|
30
|
-
else:
|
31
|
-
msg = RecordTransferOut(want_records=WantRecords(record_values["anchor_name"]))
|
32
|
-
return msg
|
@@ -1,161 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""Utility methods and classes for use with gRPC."""
|
15
|
-
import logging
|
16
|
-
import sys
|
17
|
-
from concurrent import futures
|
18
|
-
from typing import Any
|
19
|
-
|
20
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.sdk_engine_service_pb2_grpc import (
|
21
|
-
SdkEngineStub,
|
22
|
-
)
|
23
|
-
from another_ayx_python_sdk.providers.amp_provider.resources.generated.sdk_tool_service_v2_pb2_grpc import (
|
24
|
-
SdkToolV2Stub,
|
25
|
-
add_SdkToolV2Servicer_to_server,
|
26
|
-
)
|
27
|
-
from another_ayx_python_sdk.providers.amp_provider.sdk_tool_service_v2 import SdkToolServiceV2
|
28
|
-
|
29
|
-
import grpc
|
30
|
-
|
31
|
-
if sys.platform == "win32":
|
32
|
-
from another_ayx_python_sdk.providers.amp_provider.cng_certs import read_windows_store_chain
|
33
|
-
|
34
|
-
logger = logging.getLogger(__name__)
|
35
|
-
|
36
|
-
|
37
|
-
def build_sdk_tool_server(sdk_tool_address: str): # type: ignore
|
38
|
-
"""
|
39
|
-
Build the SDK Tool Server.
|
40
|
-
|
41
|
-
Parameters
|
42
|
-
----------
|
43
|
-
sdk_tool_address: str
|
44
|
-
A socket address that corresponds to the sdk tool.
|
45
|
-
|
46
|
-
Returns
|
47
|
-
-------
|
48
|
-
server
|
49
|
-
An instance of the SDK Tool Service gRPC server.
|
50
|
-
|
51
|
-
sdk_tool_address
|
52
|
-
A copy of the sdk_tool_address parameter, modified to point at server's open port.
|
53
|
-
"""
|
54
|
-
server = grpc.aio.server(
|
55
|
-
futures.ThreadPoolExecutor(max_workers=10),
|
56
|
-
options=[
|
57
|
-
("grpc.max_send_message_length", -1),
|
58
|
-
("grpc.max_receive_message_length", -1),
|
59
|
-
],
|
60
|
-
)
|
61
|
-
add_SdkToolV2Servicer_to_server(SdkToolServiceV2(), server)
|
62
|
-
# we are doing because fips() builtin exists only in Python FIPS special build
|
63
|
-
try:
|
64
|
-
fipsok: bool = fips() # type: ignore # noqa
|
65
|
-
except Exception:
|
66
|
-
fipsok = False
|
67
|
-
if fipsok and sys.platform == "win32":
|
68
|
-
chain_pair = read_windows_store_chain("grpcio_alteryx_ssl") # type: ignore
|
69
|
-
server_credentials = grpc.ssl_server_credentials([chain_pair])
|
70
|
-
port = server.add_secure_port(sdk_tool_address, server_credentials)
|
71
|
-
logger.debug("FIPS mode enabled")
|
72
|
-
else:
|
73
|
-
port = server.add_insecure_port(sdk_tool_address)
|
74
|
-
logger.debug(f"gRPC port: {port}")
|
75
|
-
return server, port
|
76
|
-
|
77
|
-
|
78
|
-
def build_sdk_engine_client(sdk_engine_address: "SocketAddress") -> SdkToolV2Stub:
|
79
|
-
"""
|
80
|
-
Build the SDK Engine Client.
|
81
|
-
|
82
|
-
Parameters
|
83
|
-
----------
|
84
|
-
sdk_engine_address: SocketAddress
|
85
|
-
A socket address that corresponds to the sdk engine.
|
86
|
-
|
87
|
-
Returns
|
88
|
-
-------
|
89
|
-
client
|
90
|
-
An instance of the SDK Engine client
|
91
|
-
"""
|
92
|
-
channel = grpc.insecure_channel(
|
93
|
-
sdk_engine_address.address,
|
94
|
-
options=[
|
95
|
-
("grpc.max_send_message_length", -1),
|
96
|
-
("grpc.max_receive_message_length", -1),
|
97
|
-
],
|
98
|
-
)
|
99
|
-
client = SdkEngineStub(channel)
|
100
|
-
return client
|
101
|
-
|
102
|
-
|
103
|
-
class SocketAddress:
|
104
|
-
"""Class for tracking host and port information."""
|
105
|
-
|
106
|
-
@classmethod
|
107
|
-
def from_address_str(cls, address_str: str) -> "SocketAddress":
|
108
|
-
"""
|
109
|
-
Construct a socket address from an address string.
|
110
|
-
|
111
|
-
Parameters
|
112
|
-
----------
|
113
|
-
address_str: str
|
114
|
-
A string consisting of host and port, separated by a colon, such as "localhost:8000".
|
115
|
-
|
116
|
-
Returns
|
117
|
-
-------
|
118
|
-
SocketAddress
|
119
|
-
A new instance of the SocketAddress class.
|
120
|
-
"""
|
121
|
-
host, port = address_str.split(":")
|
122
|
-
return cls(host, int(port))
|
123
|
-
|
124
|
-
def __init__(self, host: str, port: int) -> None:
|
125
|
-
"""
|
126
|
-
Construct a socket address.
|
127
|
-
|
128
|
-
Parameters
|
129
|
-
----------
|
130
|
-
host: str
|
131
|
-
The address hostname.
|
132
|
-
|
133
|
-
port: int
|
134
|
-
The address port.
|
135
|
-
|
136
|
-
Returns
|
137
|
-
-------
|
138
|
-
SocketAddress
|
139
|
-
A new instance of the SocketAddress class.
|
140
|
-
"""
|
141
|
-
self.host = host
|
142
|
-
self.port = port
|
143
|
-
|
144
|
-
@property
|
145
|
-
def address(self) -> str:
|
146
|
-
"""
|
147
|
-
Get the address string that contains both host and port.
|
148
|
-
|
149
|
-
Returns
|
150
|
-
-------
|
151
|
-
address: str
|
152
|
-
The address string in the form "host:port"
|
153
|
-
"""
|
154
|
-
return f"{self.host}:{self.port}"
|
155
|
-
|
156
|
-
def __eq__(self, other: Any) -> bool:
|
157
|
-
"""Compare if 2 socket addresses are equal."""
|
158
|
-
if not isinstance(other, self.__class__):
|
159
|
-
return NotImplemented
|
160
|
-
|
161
|
-
return self.address == other.address
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""Logger configuration utilities."""
|
15
|
-
import logging
|
16
|
-
import os
|
17
|
-
from pathlib import Path
|
18
|
-
|
19
|
-
|
20
|
-
def configure_logger() -> None:
|
21
|
-
"""Configure the logger for the Python SDK."""
|
22
|
-
logging.raiseExceptions = False
|
23
|
-
env_dir = os.environ.get("LOCALAPPDATA") or os.environ.get("HOME")
|
24
|
-
if env_dir is None:
|
25
|
-
raise ValueError(
|
26
|
-
"LOCALAPPDATA or HOME environment variables should be set for logging."
|
27
|
-
)
|
28
|
-
log_dir = Path(env_dir) / "Alteryx" / "Log"
|
29
|
-
log_dir.mkdir(parents=True, exist_ok=True)
|
30
|
-
|
31
|
-
log_file = log_dir / "PythonSDK.log"
|
32
|
-
|
33
|
-
logger = logging.getLogger()
|
34
|
-
lg_level = logging.DEBUG if os.environ.get("AYX_SDK_VERBOSE") else logging.INFO
|
35
|
-
logger.setLevel(lg_level)
|
36
|
-
|
37
|
-
formatter = logging.Formatter(
|
38
|
-
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
39
|
-
)
|
40
|
-
|
41
|
-
file_handler = logging.FileHandler(str(log_file), encoding="utf-8")
|
42
|
-
file_handler.setFormatter(formatter)
|
43
|
-
logger.addHandler(file_handler)
|
44
|
-
|
45
|
-
# TODO: Figure how to make python not choke on full stdout buffer
|
46
|
-
# stream_handler = logging.StreamHandler(sys.stdout)
|
47
|
-
# stream_handler.setFormatter(formatter)
|
48
|
-
# logger.addHandler(stream_handler)
|
49
|
-
|
50
|
-
|
51
|
-
def get_plugin_logger(plugin_handle: str, root_log_dir: Path) -> logging.Logger:
|
52
|
-
"""Configure a file logger for a plugin."""
|
53
|
-
root_log_dir.mkdir(parents=True, exist_ok=True)
|
54
|
-
log_file = root_log_dir / f"{plugin_handle}.log"
|
55
|
-
logger = logging.getLogger(plugin_handle)
|
56
|
-
handler = logging.FileHandler(log_file)
|
57
|
-
|
58
|
-
formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
|
59
|
-
handler.setFormatter(formatter)
|
60
|
-
logger.addHandler(handler)
|
61
|
-
_level = logging.DEBUG if os.environ.get("AYX_SDK_VERBOSE", False) else logging.INFO
|
62
|
-
logger.setLevel(_level)
|
63
|
-
return logger
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
"""Plugin class loader logic."""
|
15
|
-
import importlib
|
16
|
-
from typing import Type, cast
|
17
|
-
|
18
|
-
from another_ayx_python_sdk.core.plugin import Plugin
|
19
|
-
from another_ayx_python_sdk.core.plugin_v2 import PluginV2
|
20
|
-
|
21
|
-
|
22
|
-
class PluginNotFoundError(Exception):
|
23
|
-
"""Plugin not found exception."""
|
24
|
-
|
25
|
-
pass
|
26
|
-
|
27
|
-
|
28
|
-
class PluginClassError(Exception):
|
29
|
-
"""Plugin class error."""
|
30
|
-
|
31
|
-
pass
|
32
|
-
|
33
|
-
|
34
|
-
def load_plugin_class(plugins_package: str, tool_name: str) -> Type[Plugin]:
|
35
|
-
"""
|
36
|
-
Dynamically load the plugin class.
|
37
|
-
|
38
|
-
Parameters
|
39
|
-
----------
|
40
|
-
plugins_package: str
|
41
|
-
Path to the plugins to load from.
|
42
|
-
|
43
|
-
tool_name: str
|
44
|
-
Name of the tool to load.
|
45
|
-
|
46
|
-
Returns
|
47
|
-
-------
|
48
|
-
plugin_class: Type[Plugin]
|
49
|
-
|
50
|
-
Raises
|
51
|
-
------
|
52
|
-
ModuleNotFoundError
|
53
|
-
If module couldn't be found
|
54
|
-
|
55
|
-
PluginNotFoundError
|
56
|
-
If the module doesn't contain the specified tool
|
57
|
-
|
58
|
-
PluginClassError
|
59
|
-
If the specified tool isn't a Plugin.
|
60
|
-
"""
|
61
|
-
try:
|
62
|
-
plugins_module = importlib.import_module(plugins_package)
|
63
|
-
except ModuleNotFoundError:
|
64
|
-
raise ModuleNotFoundError(
|
65
|
-
f"ERROR: Couldn't find module {plugins_package} for loading plugins."
|
66
|
-
)
|
67
|
-
try:
|
68
|
-
plugin_class = getattr(plugins_module, tool_name)
|
69
|
-
except AttributeError:
|
70
|
-
raise PluginNotFoundError(
|
71
|
-
f"ERROR: Plugin module {plugins_package} doesn't contain a tool named {tool_name}."
|
72
|
-
)
|
73
|
-
if not (issubclass(plugin_class, Plugin) or issubclass(plugin_class, PluginV2)):
|
74
|
-
raise PluginClassError(
|
75
|
-
f"ERROR: {tool_name} class from {plugins_package} module is not a Plugin."
|
76
|
-
)
|
77
|
-
return cast(Type[Plugin], plugin_class)
|