ayx_python_sdk.providers.file_provider package

Submodules

ayx_python_sdk.providers.file_provider.environment module

File provider runtime environment information.

class ayx_python_sdk.providers.file_provider.environment.Environment(update_config_path: Optional[pathlib.Path] = None)[source]

Bases: ayx_python_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

get_settings_conf(keys: list, version_override: str = '')dict[source]

Parse xml to retrieve settings for a given designer version.

parse_settings_key_value(settings_str: str, line_delimiter: str = '\n', key_delimiter: str = '=')dict[source]

Extract a key value pair from an xml text entry set by Designer.

property proxy_configuration

Retrieve proxy config from UserSettings.xml.

property tool_id

Get the current tool’s workflow ID.

Returns:

Tool’s ID (specified by developer).

Return type:

int

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.

Returns:

The workflow directory as a Path object.

Return type:

Path

ayx_python_sdk.providers.file_provider.file_adapter module

Converts file provider classes to and from XML and CSV files.

class ayx_python_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_python_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_python_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_python_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_python_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_python_sdk.providers.file_provider.file_provider module

File provider for testing a tool outside of Designer.

ayx_python_sdk.providers.file_provider.file_provider_dcm module

File Provider: Proxy class for DCM API.

class ayx_python_sdk.providers.file_provider.file_provider_dcm.FileProviderDCM[source]

Bases: ayx_python_sdk.core.dcm_base.DcmBase

Class that wraps DCM API work.

free_write_lock(connection_id: str, role: str, secret_type: str, lock_id: str)None[source]

Free a lock obtained from a previous call to get_write_lock().

Parameters:
  • connection_id – string with UUID of connection

  • role – A role such as ?oauth?

  • secret_type – A secret type such as ?oauth_token?

  • lock_id – A lock_id acquired from a previous call to get_write_lock()

get_connection(connection_id: str) → Dict[source]

Retrieve connection information including secrets by connection ID.

Parameters:

connection_id – string with UUID of connection

get_write_lock(connection_id: str, role: str, secret_type: str, expires_in: Optional[datetime.datetime]) → Dict[source]

Attempt to acquire an exclusive write lock.

Parameters:
  • connection_id – string with UUID of connection

  • role – A role such as ?oauth?

  • secret_type – A secret type such as ?oauth_token?

  • expires_in – (Optional) A DateTime value in which to ask for the lock to be held for in milliseconds. Defaults to 0.

update_connection_secret(connection_id: str, lock_id: str, role: str, secret_type: str, value: str, expires_on: Optional[datetime.datetime], parameters: Optional[Dict[str, str]]) → Dict[source]

Update a single secret for role and secret_type to value as well as the optional expires_on and parameters.

Parameters:
  • connection_id – A connection ID

  • lock_id – A lock ID acquired from get_write_lock()

  • role – A role such as ?oauth?

  • secret_type – A secret type such as ?oauth_token?

  • value – The new value to store for the secret

  • expires_on – (Optional) DateTime of expiration of this secret

  • parameters – Dict of parameter values for this secret (this is arbitrary user data stored as JSON)

ayx_python_sdk.providers.file_provider.file_provider_input_anchor module

The file provider input anchor class definition.

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

Return type:

bool

property connections

Get the anchor connections.

Returns:

List of all the connections associated with the 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 value that indicates if input anchor is optional.

Return type:

bool

ayx_python_sdk.providers.file_provider.file_provider_input_connection module

File Provider Input Connection class.

class ayx_python_sdk.providers.file_provider.file_provider_input_connection.FileProviderInputConnection(name: str, metadata: ayx_python_sdk.core.metadata.Metadata, packet: Optional[ayx_python_sdk.core.record_packet.RecordPacket] = None, anchor: Optional[FileProviderInputAnchor] = None)[source]

Bases: ayx_python_sdk.core.input_connection_base.InputConnectionBase

An input connection contains incoming record and metadata information.

property anchor

Get the anchor this input 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_python_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_python_sdk.providers.file_provider.file_provider_output_anchor module

File provider output anchor class.

class ayx_python_sdk.providers.file_provider.file_provider_output_anchor.FileProviderOutputAnchor(name: str, allow_multiple: bool = False, optional: bool = False)[source]

Bases: ayx_python_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 value that indicates 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 the 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 output anchor is optional.

Returns:

Boolean value that indicates if output 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_python_sdk.providers.file_provider.file_record_packet module

Interface for working with multiple records.

class ayx_python_sdk.providers.file_provider.file_record_packet.FileRecordPacket(metadata: ayx_python_sdk.core.metadata.Metadata, df: pd.DataFrame)[source]

Bases: ayx_python_sdk.core.record_packet.RecordPacket

File Record packet.

ayx_python_sdk.providers.file_provider.iox module

File Provider.

class ayx_python_sdk.providers.file_provider.iox.IO[source]

Bases: ayx_python_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.

decrypt_password(password: str)str[source]

Decrypt a password; will append ‘_decrypted’ to the supplied password.

Deprecated since version 1.0.3: This will be removed in 2.0.0. Use functions of provider’s dcm property instead

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_python_sdk.providers.file_provider.tool_input module

Alteryx Designer environment information.

class ayx_python_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_python_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_python_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_python_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_python_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_python_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_python_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_python_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_python_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_python_sdk.providers.file_provider.FileProviderInputAnchor(name: str, allow_multiple: bool = False, optional: bool = False, connections: Optional[List[InputConnectionBase]] = None)[source]

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

Return type:

bool

property connections

Get the anchor connections.

Returns:

List of all the connections associated with the 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 value that indicates if input anchor is optional.

Return type:

bool

class ayx_python_sdk.providers.file_provider.FileProviderInputConnection(name: str, metadata: ayx_python_sdk.core.metadata.Metadata, packet: Optional[ayx_python_sdk.core.record_packet.RecordPacket] = None, anchor: Optional[FileProviderInputAnchor] = None)[source]

Bases: ayx_python_sdk.core.input_connection_base.InputConnectionBase

An input connection contains incoming record and metadata information.

property anchor

Get the anchor this input 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_python_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_python_sdk.providers.file_provider.FileProviderOutputAnchor(name: str, allow_multiple: bool = False, optional: bool = False)[source]

Bases: ayx_python_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 value that indicates 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 the 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 output anchor is optional.

Returns:

Boolean value that indicates if output 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_python_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_python_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