ayx_plugin_sdk.providers.file_provider package¶
Submodules¶
ayx_plugin_sdk.providers.file_provider.environment module¶
File provider runtime environment information.
-
class
ayx_plugin_sdk.providers.file_provider.environment.
Environment
(update_config_path: Optional[pathlib.Path] = None)[source]¶ Bases:
ayx_plugin_sdk.core.environment_base.EnvironmentBase
Environment information for the file provider.
-
property
alteryx_install_dir
¶ File provider does not use Designer, so this should raise NotImplementedError.
-
property
alteryx_locale
¶ File provider does not use Designer, so automatically return English.
-
property
designer_version
¶ Return 0.0.0.0 because designer is not being used.
- Returns
0.0.0.0
- Return type
-
property
tool_id
¶ Get the current tools workflow ID.
-
property
update_mode
¶ Return NO_UPDATE_MODE because update only mode is not implemented in the file provider.
- Returns
Returns NO_UPDATE_MODE
- Return type
-
property
update_only
¶ Check if the file provider is running in update only mode.
- Returns
False in the file provider because update only mode is not implemented.
- Return type
-
update_tool_config
(new_config: dict) → None[source]¶ Update the tool’s configuration.
- Parameters
new_config – The new configuration to set for the tool.
- Returns
- Return type
-
property
workflow_dir
¶ Get the directory for the currently running workflow.
-
property
ayx_plugin_sdk.providers.file_provider.file_adapter module¶
Converts file provider classes to and from XML and CSV files.
-
class
ayx_plugin_sdk.providers.file_provider.file_adapter.
FileAdapter
(tool_config: pathlib.Path, workflow_config: pathlib.Path)[source]¶ Bases:
object
File adapter class definition.
This class converts input files into file provider objects and then also converts file provider objects back into output files.
-
build_input_anchors
() → List[ayx_plugin_sdk.providers.file_provider.file_provider_input_anchor.FileProviderInputAnchor][source]¶ Build the input anchors based on anchor configuration settings.
- Returns
The a list of file provider input anchor information.
- Return type
List[FileProviderInputAnchor]
-
build_output_anchors
() → List[ayx_plugin_sdk.providers.file_provider.file_provider_output_anchor.FileProviderOutputAnchor][source]¶ Build the output anchors based on tool config settings.
- Returns
The a list of file provider output anchor information.
- Return type
List[FileProviderOutputAnchor]
-
convert_to_dict
(xml_file: pathlib.Path) → Dict[str, Any][source]¶ Convert a XML file to a Python dictionary.
- Parameters
xml_file – The XML file that should be converted to a Python dictionary.
- Returns
The anchor configuration information.
- Return type
Dict[str, Any]
-
csv_to_dataframe
(input_file: pathlib.Path) → pandas.core.frame.DataFrame[source]¶ Convert a CSV file to a pandas dataframe.
- Parameters
input_file – The input CSV file that should be converted to a Pandas dataframe.
- Returns
The pandas dataframe that contains the input records.
- Return type
pandas.Dataframe
-
dataframe_to_csv
(output_file: pathlib.Path, dataframe: pandas.core.frame.DataFrame) → None[source]¶ Convert a pandas dataframe to an output CSV file.
- Parameters
output_file – The path for the output file where the dataframe values should be held.
dataframe – The Pandas dataframe that should be converted to a CSV file.
-
metadata_to_xml
(output_file: pathlib.Path, metadata: ayx_plugin_sdk.core.metadata.Metadata) → None[source]¶ Convert record metadata to an XML file.
- Parameters
output_file – The path for the output file where the metadata information should be held.
metadata – The Metadata that should be converted to a XML file.
-
xml_to_metadata
(xml_file: pathlib.Path) → ayx_plugin_sdk.core.metadata.Metadata[source]¶ Convert an xml file to record metadata.
- Parameters
xml_file – The XML file that should be converted to Metadata.
- Returns
The metadata information from the incoming XML file.
- Return type
-
ayx_plugin_sdk.providers.file_provider.file_provider module¶
File provider for testing a tool outside of Designer.
-
class
ayx_plugin_sdk.providers.file_provider.file_provider.
FileProvider
(tool_config: pathlib.Path, workflow_config: pathlib.Path, inputs: List[AnchorDefinition], outputs: List[AnchorDefinition], update_tool_config: Optional[pathlib.Path])[source]¶ Bases:
ayx_plugin_sdk.core.provider_base.ProviderBase
File provider implementation.
The file provider will instantiate input and output connections for the tool from input files and pass information along to the tool plugin.
-
property
environment
¶ Get the Environment object from this provider.
- Returns
An instance of a concrete Environment object.
- Return type
-
get_input_anchor
(name: str) → FileProviderInputAnchor[source]¶ Get an input anchor by name.
- Parameters
name – The name of the anchor to get.
- Returns
An instance of a concrete InputAnchorBase object with the name requested.
- Return type
-
get_output_anchor
(name: str) → FileProviderOutputAnchor[source]¶ Get an output anchor by name.
- Parameters
name – The name of the anchor to get.
- Returns
An instance of a concrete OutputAnchorBase object with the name requested.
- Return type
-
property
io
¶ Get the IO object from this provider.
- Returns
An instance of a concrete IO object.
- Return type
-
property
logger
¶ Get the logger for the provider.
- Returns
Python logging object.
- Return type
Logger
-
property
tool_config
¶ Get config xml from this provider.
-
property
ayx_plugin_sdk.providers.file_provider.file_provider_input_anchor module¶
The file provider input anchor class definition.
-
class
ayx_plugin_sdk.providers.file_provider.file_provider_input_anchor.
FileProviderInputAnchor
(name: str, allow_multiple: bool = False, optional: bool = False, connections: Optional[List[InputConnectionBase]] = None)[source]¶ Bases:
ayx_plugin_sdk.core.input_anchor_base.InputAnchorBase
An input anchor that contains input connection information.
-
property
allow_multiple
¶ Get the status of if multiple connections are allowed.
- Returns
Boolean indicating if multiple connections are allowed.
- Return type
-
property
connections
¶ Get the anchor connections.
- Returns
List of all the connections associated with this anchor.
- Return type
List[InputConnectionBase]
-
property
name
¶ Get the name of the input anchor.
- Returns
The name of the input anchor.
- Return type
-
property
ayx_plugin_sdk.providers.file_provider.file_provider_input_connection module¶
File Provider Input Connection class.
-
class
ayx_plugin_sdk.providers.file_provider.file_provider_input_connection.
FileProviderInputConnection
(name: str, metadata: ayx_plugin_sdk.core.metadata.Metadata, packet: Optional[ayx_plugin_sdk.core.record_packet.RecordPacket] = None, anchor: Optional[FileProviderInputAnchor] = None)[source]¶ Bases:
ayx_plugin_sdk.core.input_connection_base.InputConnectionBase
An input connection contains incoming record and metadata information.
-
property
anchor
¶ Get the input anchor this connection is associated with.
- Returns
The anchor this input connection is associated with.
- Return type
-
property
max_packet_size
¶ Get the maximum number of records per packet.
- Returns
The maximum number of records in a packet.
- Return type
int, optional
-
property
metadata
¶ Get the connection metadata.
- Returns
The metadata associated with this input connection.
This will return None when accessed before the input connection has been opened, since the metadata isn’t known until that point.
- Return type
Metadata, optional
-
property
progress
¶ Get the progress percentage of records received on this input connection.
- Returns
The progress percentage of the connection.
- Return type
-
read
() → ayx_plugin_sdk.core.record_packet.RecordPacket[source]¶ Read a record packet from the incoming connection.
- Returns
A record packet containing the data received by this connection.
- Return type
-
property
ayx_plugin_sdk.providers.file_provider.file_provider_output_anchor module¶
File provider output anchor class.
-
class
ayx_plugin_sdk.providers.file_provider.file_provider_output_anchor.
FileProviderOutputAnchor
(name: str, allow_multiple: bool = False, optional: bool = False)[source]¶ Bases:
ayx_plugin_sdk.core.output_anchor_base.OutputAnchorBase
The output anchor contains outgoing record and metadata information.
-
property
allow_multiple
¶ Get the status of if multiple connections are allowed.
- Returns
Boolean indicating if multiple connections are allowed.
- Return type
-
property
is_open
¶ Get if the anchor is open.
-
property
metadata
¶ Get the metadata for the anchor.
-
property
name
¶ Get the name of the output anchor.
- Returns
The name of the output anchor.
- Return type
-
property
num_connections
¶ Get the number of connections attached to the anchor.
- Returns
The number of downstream connections on this anchor.
- Return type
-
open
(metadata: Metadata) → None[source]¶ Open the output anchor.
Write the outgoing record metadata and open this connection for outgoing packets.
- Parameters
metadata – The metadata to set for this anchor.
-
property
optional
¶ Get the status of if the input anchor is optional.
- Returns
Boolean indicating if input anchor is optional.
- Return type
-
property
ayx_plugin_sdk.providers.file_provider.file_record_packet module¶
Interface for working with multiple records.
-
class
ayx_plugin_sdk.providers.file_provider.file_record_packet.
FileRecordPacket
(metadata: ayx_plugin_sdk.core.metadata.Metadata, df: pd.DataFrame)[source]¶ Bases:
ayx_plugin_sdk.core.record_packet.RecordPacket
File Record packet.
ayx_plugin_sdk.providers.file_provider.iox module¶
File Provider.
-
class
ayx_plugin_sdk.providers.file_provider.iox.
IO
[source]¶ Bases:
ayx_plugin_sdk.core.io_base.IoBase
Simple tool interface that will be used with Designer.
-
create_temp_file
(extension: str = 'tmp', options: int = 0) → pathlib.Path[source]¶ Create a temporary file path.
-
ayx_plugin_sdk.providers.file_provider.tool_input module¶
Alteryx designer environment information.
-
class
ayx_plugin_sdk.providers.file_provider.tool_input.
AnchorDefinition
[source]¶ Bases:
pydantic.main.BaseModel
AnchorDefinition validates the anchor information for the tool input.
- Parameters
anchor_name – The name of the anchor that the records and metadata are assoiciated with.
records – The anchor record data.
metadata – The anchor metadata information.
-
anchor_name
: str = None¶
-
metadata
: Path = None¶
-
records
: Path = None¶
-
class
ayx_plugin_sdk.providers.file_provider.tool_input.
ToolDefinition
[source]¶ Bases:
pydantic.main.BaseModel
ToolDefinition validates the tool information for the tool input.
- Parameters
plugin – The class name of the plugin being run.
path – The path to the plugin being run.
-
path
: Path = None¶
-
plugin
: str = None¶
-
class
ayx_plugin_sdk.providers.file_provider.tool_input.
ToolInput
[source]¶ Bases:
pydantic.main.BaseModel
ToolInput validates the input JSON for the user input to the file provider.
- Parameters
tool – A ToolDefinition object with two inputs, path and plugin, that contain the path to the plugin and the plugin name respectively.
tool_config – The path to the tool configuration file.
workflow_config – The path to the workflow configuration file.
inputs –
- A list of AnchorDefinition objects with three inputs, anchor_name, records, and metadata,
that specify the anchor the input information corresponds to, the record information for that anchor, and the metadata information for that anchor respectively.
- outputs
A list of AnchorDefinition objects with three inputs, anchor_name, records, and metadata, that specify the anchor the output information corresponds to, the file where the record information for that anchor will be stored, and the file where the metadata information for that anchor will be stored respectively.
update_tool_config – An optional path that indicates whether to update the tool’s config. If it is set, the config will be updated at the specified path.
-
classmethod
anchor_is_none
(v)[source]¶ Set the inputs and outputs equal to an empty list if they aren’t specified.
-
inputs
: Optional[List[AnchorDefinition]] = None¶
-
outputs
: Optional[List[AnchorDefinition]] = None¶
-
tool
: ToolDefinition = None¶
-
tool_config
: Path = None¶
-
update_tool_config
: Optional[Path] = None¶
-
workflow_config
: Path = None¶
Module contents¶
Alteryx Python SDK - File Adapter for standalone testing.
-
class
ayx_plugin_sdk.providers.file_provider.
AnchorDefinition
[source]¶ Bases:
pydantic.main.BaseModel
AnchorDefinition validates the anchor information for the tool input.
- Parameters
anchor_name – The name of the anchor that the records and metadata are assoiciated with.
records – The anchor record data.
metadata – The anchor metadata information.
-
anchor_name
: str = None¶
-
metadata
: Path = None¶
-
records
: Path = None¶
-
class
ayx_plugin_sdk.providers.file_provider.
FileAdapter
(tool_config: pathlib.Path, workflow_config: pathlib.Path)[source]¶ Bases:
object
File adapter class definition.
This class converts input files into file provider objects and then also converts file provider objects back into output files.
-
build_input_anchors
() → List[ayx_plugin_sdk.providers.file_provider.file_provider_input_anchor.FileProviderInputAnchor][source]¶ Build the input anchors based on anchor configuration settings.
- Returns
The a list of file provider input anchor information.
- Return type
List[FileProviderInputAnchor]
-
build_output_anchors
() → List[ayx_plugin_sdk.providers.file_provider.file_provider_output_anchor.FileProviderOutputAnchor][source]¶ Build the output anchors based on tool config settings.
- Returns
The a list of file provider output anchor information.
- Return type
List[FileProviderOutputAnchor]
-
convert_to_dict
(xml_file: pathlib.Path) → Dict[str, Any][source]¶ Convert a XML file to a Python dictionary.
- Parameters
xml_file – The XML file that should be converted to a Python dictionary.
- Returns
The anchor configuration information.
- Return type
Dict[str, Any]
-
csv_to_dataframe
(input_file: pathlib.Path) → pandas.core.frame.DataFrame[source]¶ Convert a CSV file to a pandas dataframe.
- Parameters
input_file – The input CSV file that should be converted to a Pandas dataframe.
- Returns
The pandas dataframe that contains the input records.
- Return type
pandas.Dataframe
-
dataframe_to_csv
(output_file: pathlib.Path, dataframe: pandas.core.frame.DataFrame) → None[source]¶ Convert a pandas dataframe to an output CSV file.
- Parameters
output_file – The path for the output file where the dataframe values should be held.
dataframe – The Pandas dataframe that should be converted to a CSV file.
-
metadata_to_xml
(output_file: pathlib.Path, metadata: ayx_plugin_sdk.core.metadata.Metadata) → None[source]¶ Convert record metadata to an XML file.
- Parameters
output_file – The path for the output file where the metadata information should be held.
metadata – The Metadata that should be converted to a XML file.
-
xml_to_metadata
(xml_file: pathlib.Path) → ayx_plugin_sdk.core.metadata.Metadata[source]¶ Convert an xml file to record metadata.
- Parameters
xml_file – The XML file that should be converted to Metadata.
- Returns
The metadata information from the incoming XML file.
- Return type
-
-
class
ayx_plugin_sdk.providers.file_provider.
FileProvider
(tool_config: pathlib.Path, workflow_config: pathlib.Path, inputs: List[AnchorDefinition], outputs: List[AnchorDefinition], update_tool_config: Optional[pathlib.Path])[source]¶ Bases:
ayx_plugin_sdk.core.provider_base.ProviderBase
File provider implementation.
The file provider will instantiate input and output connections for the tool from input files and pass information along to the tool plugin.
-
property
environment
¶ Get the Environment object from this provider.
- Returns
An instance of a concrete Environment object.
- Return type
-
get_input_anchor
(name: str) → FileProviderInputAnchor[source]¶ Get an input anchor by name.
- Parameters
name – The name of the anchor to get.
- Returns
An instance of a concrete InputAnchorBase object with the name requested.
- Return type
-
get_output_anchor
(name: str) → FileProviderOutputAnchor[source]¶ Get an output anchor by name.
- Parameters
name – The name of the anchor to get.
- Returns
An instance of a concrete OutputAnchorBase object with the name requested.
- Return type
-
property
io
¶ Get the IO object from this provider.
- Returns
An instance of a concrete IO object.
- Return type
-
property
logger
¶ Get the logger for the provider.
- Returns
Python logging object.
- Return type
Logger
-
property
tool_config
¶ Get config xml from this provider.
-
property
-
class
ayx_plugin_sdk.providers.file_provider.
FileProviderInputAnchor
(name: str, allow_multiple: bool = False, optional: bool = False, connections: Optional[List[InputConnectionBase]] = None)[source]¶ Bases:
ayx_plugin_sdk.core.input_anchor_base.InputAnchorBase
An input anchor that contains input connection information.
-
property
allow_multiple
¶ Get the status of if multiple connections are allowed.
- Returns
Boolean indicating if multiple connections are allowed.
- Return type
-
property
connections
¶ Get the anchor connections.
- Returns
List of all the connections associated with this anchor.
- Return type
List[InputConnectionBase]
-
property
name
¶ Get the name of the input anchor.
- Returns
The name of the input anchor.
- Return type
-
property
-
class
ayx_plugin_sdk.providers.file_provider.
FileProviderInputConnection
(name: str, metadata: ayx_plugin_sdk.core.metadata.Metadata, packet: Optional[ayx_plugin_sdk.core.record_packet.RecordPacket] = None, anchor: Optional[FileProviderInputAnchor] = None)[source]¶ Bases:
ayx_plugin_sdk.core.input_connection_base.InputConnectionBase
An input connection contains incoming record and metadata information.
-
property
anchor
¶ Get the input anchor this connection is associated with.
- Returns
The anchor this input connection is associated with.
- Return type
-
property
max_packet_size
¶ Get the maximum number of records per packet.
- Returns
The maximum number of records in a packet.
- Return type
int, optional
-
property
metadata
¶ Get the connection metadata.
- Returns
The metadata associated with this input connection.
This will return None when accessed before the input connection has been opened, since the metadata isn’t known until that point.
- Return type
Metadata, optional
-
property
progress
¶ Get the progress percentage of records received on this input connection.
- Returns
The progress percentage of the connection.
- Return type
-
read
() → ayx_plugin_sdk.core.record_packet.RecordPacket[source]¶ Read a record packet from the incoming connection.
- Returns
A record packet containing the data received by this connection.
- Return type
-
property
-
class
ayx_plugin_sdk.providers.file_provider.
FileProviderOutputAnchor
(name: str, allow_multiple: bool = False, optional: bool = False)[source]¶ Bases:
ayx_plugin_sdk.core.output_anchor_base.OutputAnchorBase
The output anchor contains outgoing record and metadata information.
-
property
allow_multiple
¶ Get the status of if multiple connections are allowed.
- Returns
Boolean indicating if multiple connections are allowed.
- Return type
-
property
is_open
¶ Get if the anchor is open.
-
property
metadata
¶ Get the metadata for the anchor.
-
property
name
¶ Get the name of the output anchor.
- Returns
The name of the output anchor.
- Return type
-
property
num_connections
¶ Get the number of connections attached to the anchor.
- Returns
The number of downstream connections on this anchor.
- Return type
-
open
(metadata: Metadata) → None[source]¶ Open the output anchor.
Write the outgoing record metadata and open this connection for outgoing packets.
- Parameters
metadata – The metadata to set for this anchor.
-
property
optional
¶ Get the status of if the input anchor is optional.
- Returns
Boolean indicating if input anchor is optional.
- Return type
-
property
-
class
ayx_plugin_sdk.providers.file_provider.
ToolDefinition
[source]¶ Bases:
pydantic.main.BaseModel
ToolDefinition validates the tool information for the tool input.
- Parameters
plugin – The class name of the plugin being run.
path – The path to the plugin being run.
-
path
: Path = None¶
-
plugin
: str = None¶
-
class
ayx_plugin_sdk.providers.file_provider.
ToolInput
[source]¶ Bases:
pydantic.main.BaseModel
ToolInput validates the input JSON for the user input to the file provider.
- Parameters
tool – A ToolDefinition object with two inputs, path and plugin, that contain the path to the plugin and the plugin name respectively.
tool_config – The path to the tool configuration file.
workflow_config – The path to the workflow configuration file.
inputs –
- A list of AnchorDefinition objects with three inputs, anchor_name, records, and metadata,
that specify the anchor the input information corresponds to, the record information for that anchor, and the metadata information for that anchor respectively.
- outputs
A list of AnchorDefinition objects with three inputs, anchor_name, records, and metadata, that specify the anchor the output information corresponds to, the file where the record information for that anchor will be stored, and the file where the metadata information for that anchor will be stored respectively.
update_tool_config – An optional path that indicates whether to update the tool’s config. If it is set, the config will be updated at the specified path.
-
classmethod
anchor_is_none
(v)[source]¶ Set the inputs and outputs equal to an empty list if they aren’t specified.
-
inputs
: Optional[List[AnchorDefinition]] = None¶
-
outputs
: Optional[List[AnchorDefinition]] = None¶
-
tool
: ToolDefinition = None¶
-
tool_config
: Path = None¶
-
update_tool_config
: Optional[Path] = None¶
-
workflow_config
: Path = None¶