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

str

property tool_id

Get the current tool’s 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

UpdateMode

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

bool

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

None

property workflow_dir

Get the directory for the currently-running workflow.

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 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 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 a 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

Metadata

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

EnvironmentBase

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

InputAnchorBase

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

OutputAnchorBase

property io

Get the IO object from this provider.

Returns

An instance of a concrete IO object.

Return type

IoBase

property logger

Get the logger for the provider.

Returns

Python logging object.

Return type

Logger

property tool_config

Get config XML from this provider.

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 that indicates if multiple connections are allowed.

Returns

Boolean indicating if multiple connections are allowed.

Return type

bool

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

str

property optional

Get the status that indicates if the input anchor is optional.

Returns

Boolean indicating if input anchor is optional.

Return type

bool

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

InputAnchorBase

property metadata

Get the connection metadata.

Returns

The metadata associated with this input connection.

This returns None when accessed before the input connection has been opened, since the metadata isn’t known until that point.

Return type

Metadata, optional

property name

Get the connection name.

Returns

Name of the input connection.

Return type

str

property progress

Get the progress percentage of records received on this input connection.

Returns

The progress percentage of the connection.

Return type

float

read()ayx_plugin_sdk.core.record_packet.RecordPacket[source]

Read a record packet from the incoming connection.

Returns

A record packet that contains the data received by this connection.

Return type

RecordPacketBase

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 that indicates if multiple connections are allowed.

Returns

Boolean indicating if multiple connections are allowed.

Return type

bool

close()None[source]

Close the outgoing connection.

flush()None[source]

File provider does not need to flush records, so pass.

property is_open

Get status that indicates 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

str

property num_connections

Get the number of connections attached to the anchor.

Returns

The number of downstream connections on this anchor.

Return type

int

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 that indicates if the input anchor is optional.

Returns

Boolean indicating if input anchor is optional.

Return type

bool

update_progress(percentage: float)None[source]

File provider does not need to update progress, so pass.

write(record_packet: RecordPacketBase)None[source]

Write a RecordPacket to the outgoing connection.

Parameters

record_packet – The record packet to write to the output anchor.

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.

error(error_msg: str)None[source]

Display an error in the Results window.

info(info_msg: str)None[source]

Display information in the Results window.

translate_msg(msg: str, *args: Any)str[source]

Translate a message.

update_progress(percent: float)None[source]

Update tool progress.

warn(warn_msg: str)None[source]

Display a warning in the Results window.

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 2 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 3 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 3 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.

Parameters

v – The inputs or the outputs optional list of dictionaries.

Returns

An empty list or the inputs or outputs.

Return type

List[Dict[str, str]]

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 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 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 a 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

Metadata

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

EnvironmentBase

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

InputAnchorBase

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

OutputAnchorBase

property io

Get the IO object from this provider.

Returns

An instance of a concrete IO object.

Return type

IoBase

property logger

Get the logger for the provider.

Returns

Python logging object.

Return type

Logger

property tool_config

Get config XML from this provider.

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 that indicates if multiple connections are allowed.

Returns

Boolean indicating if multiple connections are allowed.

Return type

bool

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

str

property optional

Get the status that indicates if the input anchor is optional.

Returns

Boolean indicating if input anchor is optional.

Return type

bool

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

InputAnchorBase

property metadata

Get the connection metadata.

Returns

The metadata associated with this input connection.

This returns None when accessed before the input connection has been opened, since the metadata isn’t known until that point.

Return type

Metadata, optional

property name

Get the connection name.

Returns

Name of the input connection.

Return type

str

property progress

Get the progress percentage of records received on this input connection.

Returns

The progress percentage of the connection.

Return type

float

read()ayx_plugin_sdk.core.record_packet.RecordPacket[source]

Read a record packet from the incoming connection.

Returns

A record packet that contains the data received by this connection.

Return type

RecordPacketBase

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 that indicates if multiple connections are allowed.

Returns

Boolean indicating if multiple connections are allowed.

Return type

bool

close()None[source]

Close the outgoing connection.

flush()None[source]

File provider does not need to flush records, so pass.

property is_open

Get status that indicates 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

str

property num_connections

Get the number of connections attached to the anchor.

Returns

The number of downstream connections on this anchor.

Return type

int

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 that indicates if the input anchor is optional.

Returns

Boolean indicating if input anchor is optional.

Return type

bool

update_progress(percentage: float)None[source]

File provider does not need to update progress, so pass.

write(record_packet: RecordPacketBase)None[source]

Write a RecordPacket to the outgoing connection.

Parameters

record_packet – The record packet to write to the output anchor.

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 2 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 3 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 3 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.

Parameters

v – The inputs or the outputs optional list of dictionaries.

Returns

An empty list or the inputs or outputs.

Return type

List[Dict[str, str]]

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