TargetSmart Automation Workflows
In addition to the TargetSmart Developer API,
TargetSmart also provides a solution for executing custom data processing
workflows that TargetSmart implements for specific client needs. The
TargetSmartAutomation class can be used to execute these workflows for
common purposes such as customized list matching workflows. Workflow execution
can take minutes to hours depending on the workflow type, size of data, and
TargetSmart Automation workflows use SFTP. You will need to obtain SFTP credentials from TargetSmart to utilize the
TargetSmartAutomation, you can either store your SFTP username and password
as the environmental variables
TS_SFTP_PASSWORD, or pass them in as
from parsons import TargetSmartAutomation # First approach: Store SFTP username and password as environmental variables ts_auto = TargetSmartAutomation() # Second approach: Pass SFTP username and password as arguments. These are # provided by TargetSmart for your account. Warning: Do not store password # literals in your source code. ts_auto = TargetSmartAutomation( sftp_username='my_sftp_username', sftp_password='my_sftp_password' )
You can then call these methods:
# Execute a custom workflow that TargetSmart has provisioned for you. This # blocks until completion and may take minutes/hours depending on the data size # and workflow type input_table = Table.from_csv('my_file_to_match.csv') output_table = ts_auto.match( input_table, 'workflow_name_provided_by_targetsmart', 'my_job_name', emails=['email@example.com'], ) # Most Automation workflows perform list matching, but not all. The ``execute`` # method is an alias for the ``match`` method to avoid confusion in these cases. # This is the equivalent to the above output_table = ts_auto.execute( input_table, 'workflow_name_provided_by_targetsmart', 'my_job_name', emails=['firstname.lastname@example.org'], ) # Optionally check the status of a workflow execution ts_auto.match_status(job_name='my_job_name') # Optionally remove all files for the match job. TargetSmart's lifecycle rules # will remove eventually if not. ts_auto.remove_files(job_name='my_job_name')
- class parsons.TargetSmartAutomation(sftp_username=None, sftp_password=None)
- match(table, job_type, job_name=None, emails=None, call_back=None, remove_files=True)
Submit a file for custom data processing using the TargetSmart Automation workflow solution.
Each Automation workflow expects an input file that meets the layout requirements provided by TargetSmart. The number of columns and column order is significant. So, if it expected 10 columns and you only provide 9, it will fail. However, if you provide 10 columns that are out of order, the job may succeed, but with non-optimal results. You can obtain the layout requirements and other information about a workflow by visiting the Automation console in My TargetSmart. Contact TargetSmart Client Services for support.
- table: Parsons Table Object
A table object with the required columns. Each workflow type requires the input file to meet the requirements provided by TargetSmart. You can locate the input and output layouts for your available workflows using the My TargetSmart Automation console.
- job_type: str
The workflow name to execute. This is case sensitive.. You can locate the workflow names and other information by visiting the Automation console in My TargetSmart.
- job_name: str
Optional job execution name.
- emails: list
A list of emails that will received status notifications. This is useful in debugging failed jobs.
- call_back: str
A callback url to which the status will be posted. See TargetSmart documentation for more details.
- remove_files: boolean
Remove the configuration, file to be matched and matched file from the TargetSmart SFTP upon completion or failure of match.
- execute(*args, **kwargs)
Most Automation workflows perform list matching. However, it is possible that a custom workflow might be provisioned for a client for other types of file processing. The
executemethod is provided as an alias for the
matchmethod which may be a confusing name in these cases.