Skip to main content
Run a Python script. The script is executed in-process by the Python 3 interpreter.
Use this component for small Python tasks that don’t consume a high level of resources. The executes these scripts, so large scripts can cause the to run out of memory, affecting all other pipelines that the is executing. For resource-hungry scripts, consider using:
  • Script Pushdown, which uses a dedicated and is a better option for resource-hungry scripts.
  • Python Pushdown, which lets you execute a Python script using the Snowpark service in your Snowflake account. This is a good option for resource-intensive scripts, provided your Snowflake account is scaled accordingly. This component is only available to Snowflake projects.
You can’t use the Python Script component on Full SaaS infrastructure or the for Snowflake.
Any output written via print statements will appear as the task completion message, and so output should be brief. While it is valid to handle exceptions within the script using try/except, any uncaught exceptions will cause the component to be marked as failed and its failure link to be followed. You may import any modules from the Python Standard Library. Optionally, you may also import your own Python libraries. To do this, you need to specify the location of your libraries in the environment variable EXTENSION_LIBRARY_LOCATION. For more information on this, read Optional parameters. To use these additional Python libraries, you will need to include appropriate imports in your Python script, following standard Python practice. If the component requires access to a cloud provider, by default the component will inherit the ‘s execution role (service account role). However, if there are cloud credentials associated to your environment, these will overwrite the role. This component supports the use of pipeline and project variables. For more information, read Project and pipeline variables.
Python scripts in should be written to be version-agnostic where possible. The Python runtime bundled with the is updated periodically, and there is no guarantee a specific version will remain in place indefinitely. Read Installing Python libraries for further information.

Properties

string
required
A human-readable name for the component.
code editor
required
The Python script to execute.
drop-down
required
Set this to Python 3.
integer
required
The number of seconds to wait for script termination. After the set number of seconds has elapsed, the script is forcibly terminated. The default is 300 seconds (5 minutes).

Script best practices

In a Python script, it’s possible to stream all of the output of a massive curl request to the log output. However, we don’t recommend this practice. Streaming all of the data to the log means that the data leaves your own infrastructure and is stored in log files in , breaking data sovereignty. Best practice, therefore, is to use the script to retrieve the data and then load it into an S3 bucket or some other storage of your choice, bypassing the Matillion logs. If your Python script results in a log file of more than 300 KB being written, the script will execute successfully but the component will truncate the log file and log the message *** WARNING: log output too large. Only returning the last 300 KB **** : <contents>

Default libraries

The following libraries are available by default in the Python Script component: