Automate Python scripts in Retool Workflows | Retool Blog | Cache (2024)

Today, we’re introducing support for Python in Retool Workflows. Now, you can run Python code blocks as steps in your automations to more elegantly ingest, analyze, and visualize data—with preinstalled dev tools like autocomplete, linting, and 20+ libraries (like numpy and pandas).

Get started for free today. Every Retool plan includes 1GB/month of Workflows data for free.

We heard from customers that building business software is a collaborative effort, and support for the languages that their teams already use helps them build apps faster.

We want Retool to be the fastest way for your team to build, maintain, and extend business software. So we’re doing just that, starting with Python support in Workflows.

How it works

A lot of software today is written in Python. (GitHub’s State of the Octoverse ranks it the second most popular programming language used in 2022, behind JavaScript.) And for good reason—Python comes with a rich library ecosystem, which you can now leverage when building automation projects in Workflows.

Now, when running code blocks, you can select either JavaScript or Python as your language. Just drag a block out onto the canvas, select “Code”, and then select the Python tab to start writing.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (1)

When writing Python in Workflows, you automatically get auto-completion, context, and linting. Don’t worry about importing your favorite libraries, either. We’ve preinstalled 20 libraries and packages—like numpy, pandas, scipy, and plotting libraries like seaborn—so that you don't lose access to the powerful packages you’re used to writing within your IDE or notebook.

A more powerful toolkit for ETL and reporting

As someone who does a fair bit of analytics work, there are times I find myself wanting to reach for something other than JavaScript or SQL when building in Workflows. Applying normalization to a multi-dimensional dataset feels needlessly complex in JavaScript when, in Python, I could simply call np.linalg.norm.

Now, I can swap between JavaScript and Python any time I want to use code blocks in Workflows, meaning I can reach for the right tool for the job at each step in any automation process. Here’s a reporting example:

Say we want to create a weekly report for our Customer Success team, tracking their healthiest and least healthy accounts. First, let’s start with writing the base query to our dataset: in this case, our table is called fct_sfdc_account_health.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (2)

Getting the base-level data using SQL is always a great first step, and with Retool, you can use your existing SQL resources to quickly query your database. But if your reports need to be customized to each user, generating user-specific SQL queries can get annoying fast. Instead, after doing a generic SQL query, we can handle the transformation and filtering in pandas.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (3)

We’ll use pandas to quickly sort, transform, and clean the data. Our Success team is only assigned to certain segments like Enterprise (ENT), so we filter for those here. Additionally, we can truncate any customer names that get too long.

We won’t show all of the transformations here, but you can imagine the utility of writing native SQL then native Python in back-to-back blocks. If your logic is highly conditional, the graph-based expressiveness of Workflows supercharges your developer workflow.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (4)

Finally, we can use an email resource like SMTP to easily send an email to relevant accounts and schedule the workflow to run every Monday morning. We can even leverage the trick above to add an attached PDF containing a visualization we generated earlier:

Automate Python scripts in Retool Workflows | Retool Blog | Cache (5)

Spin up APIs and visualize your data––all in the same platform

Like software development, data is a team sport. Data analysts and operations teams collaborate with engineering on everything from product metrics to reporting dashboards, and maintain operations software to run the business as a joint effort.

Workflows turn every script or data processing workflow into a portable, reusable API to easily leverage complex logic in your Retool UIs—facilitating quicker handoffs between teams without having to worry about provisioning any additional infrastructure.

For example, let’s create a webhook-based workflow. By flipping the Start Trigger block to webhook mode, we’ll automatically get a URL endpoint that we can send POST requests to. And, we can specify the shape of a JSON input to reference later—for example, the attributes on various axes, or filters to apply.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (6)

Just like the reporting use case, imagine that we’ve read in data from a SQL database. We can then use pandas to filter the dataset based on the parameters provided in the startTrigger.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (7)

Now that we have our desired dataset, we can use a Python-based plotting library like seaborn to create a nice plot.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (8)

We’ll create a file buffer in the Python block, then save our visualization into that file buffer. We can now return that image (in svg/pdf/png/jpg format) as the output of the block. We’re almost done!

Automate Python scripts in Retool Workflows | Retool Blog | Cache (9)

We can use the new webhook Response block to simply return the base64 version of the image generated above.

Now, we’re pretty much done. Jumping over to the Retool app editor, we can create a form with all of the relevant inputs needed for the chart.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (10)

On submit, we can call the endpoint that is exposed in our Start Trigger.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (11)

And finally, we can add in an Image component with the URL directly pointed at our REST Query above.

Automate Python scripts in Retool Workflows | Retool Blog | Cache (12)

Check out the JSON for this example workflow, and import it into your own Retool instance to see how it works!

Get started

Python code blocks are now available to all cloud customers and will be available on-prem soon. Have feedback, or just want to share what you’re building? Join us in the community forums, or reach out to workflows@retool.com. We’re eager to see what you work on next!

Reader

Automate Python scripts in Retool Workflows | Retool Blog | Cache (2024)

FAQs

Can Retool run a Python script? ›

You can send the data of the form app into a retool workflow, which allows you to run python scripts and interact with the data that is sent into the workflow.

How do you automate a workflow in Python? ›

Here are some general steps to follow when automating tasks for Python Projects:
  1. Identify the Task. Identify the task that you want to automate. ...
  2. Break Down the Task. Break down the task into smaller subtasks that can be automated using Python. ...
  3. Research. ...
  4. Write the Code. ...
  5. Test the Code. ...
  6. Run the Code. ...
  7. Monitor and Update.
Jun 4, 2024

What are retool workflows? ›

Retool Workflows enables you to build complex automations that interact with your data sources. Connect pre-built query blocks together that can interact with resources, transform data, and run additional logic. Trigger workflows automatically with custom schedules or using webhook events.

Can you run Python scripts automatically? ›

Yes, you can schedule Python jobs in Windows using the built-in Task Scheduler.

What is the alternative to Retool Python? ›

Best Retool Alternatives to Use in 2024
  • Ply – Best for Software Augmentation. ...
  • DronaHQ – Best Low Code Platform. ...
  • Superblocks – Best to Build Internal Tools. ...
  • OutSystems – Best Visual Development Environment. ...
  • Appsmith – Best Open Source Alternative. ...
  • Appian – Best for Low-Code Automation. ...
  • UI Bakery – Best for UI.
Apr 30, 2024

Can I automate everything with Python? ›

Python's simple syntax and rich collection of modules and libraries make it ideal for scripting repetitive tasks. Whether automating email responses, scheduling tasks, using data structures, or updating spreadsheets, Python makes it all possible with minimal code.

Is Python good for automation? ›

Python, an open-source and easy-to-use programming language, contributes significantly to automating tasks and implementing scripts necessary for business process automation. Speedy automation leads to faster time to market. So, kill the project development waiting period using python for automation.

How do you write an automated script in Python? ›

You can easily create an automation script.
  1. Step 1: Identify the Task. Before writing the code, you should have it clear what you want your code to do. ...
  2. Step 2: Divide the Task into Smaller Steps. ...
  3. Step 3: Research Python Libraries. ...
  4. Step 4: Write the Code. ...
  5. Step 5: Test the Code. ...
  6. Step 6: Update the Code.
Jul 25, 2024

What are the drawbacks of Retool? ›

Limitations on custom components and bigger the app get it slows while developing. Review collected by and hosted on G2.com. What do you like best about Retool? The easy way to create the UI and integrate your APIs, or directly connect to any database or AWS.

What problem does Retool solve? ›

Retool addresses various challenges developers face in application development, such as prolonged development time, tech debt, integration, security, complex coding, high costs, and scalability.

What is Retool good for? ›

Retool can be used to quickly build out custom tools to replace and augment existing processes with fewer engineering resources than would otherwise be required.

What programming language does Retool use? ›

Retool use JS as the main language, so if you want to find sth about data Structure, you may need to search data structure of javascript.

What software executes Python scripts? ›

PyCharm, a proprietary and Open Source IDE for Python development. PythonAnywhere, an online IDE and Web hosting service. Python Tools for Visual Studio, Free and open-source plug-in for Visual Studio. Spyder, IDE for scientific programming.

How do I run a Python script in robot? ›

To import the Python script inside Robot, we use the keyword Library in the Robot file under ***settings*** . To call the function, we use <file_name> <dot> <function name> . To add keywords inside the function, we use the keyword decorator.

Can I run a Python script? ›

To run a Python script in Terminal from the command line, navigate to the script's directory and use the python script_name.py command. Redirecting output involves using the > symbol followed by a file name to capture the script's output in a file.

Top Articles
Hotel DESTINO PACHA IBIZA RESORT in Ibiza-Stadt günstig buchen bei TUI.com
Half Baked Harvest Pumpkin Pie
Tyler Sis 360 Louisiana Mo
Nehemiah 4:1–23
Northern Whooping Crane Festival highlights conservation and collaboration in Fort Smith, N.W.T. | CBC News
Melfme
Walgreens Alma School And Dynamite
Erskine Plus Portal
6001 Canadian Ct Orlando Fl
Love In The Air Ep 9 Eng Sub Dailymotion
Bnsf.com/Workforce Hub
Trivago Sf
Ge-Tracker Bond
Persona 5 Royal Fusion Calculator (Fusion list with guide)
Sullivan County Image Mate
Marion City Wide Garage Sale 2023
Tips and Walkthrough: Candy Crush Level 9795
Shreveport City Warrants Lookup
About My Father Showtimes Near Copper Creek 9
The Many Faces of the Craigslist Killer
Craigslist Maryland Trucks - By Owner
Strange World Showtimes Near Savoy 16
Urbfsdreamgirl
Accuradio Unblocked
What Sells at Flea Markets: 20 Profitable Items
Tom Thumb Direct2Hr
Acuity Eye Group - La Quinta Photos
Aladtec Login Denver Health
Craigslist Central Il
Supermarkt Amsterdam - Openingstijden, Folder met alle Aanbiedingen
Sinfuldeeds Vietnamese Rmt
Royals op zondag - "Een advertentie voor Center Parcs" of wat moeten we denken van de laatste video van prinses Kate?
Craigslist Greencastle
Devotion Showtimes Near Mjr Universal Grand Cinema 16
AsROck Q1900B ITX und Ramverträglichkeit
Laurin Funeral Home | Buried In Work
The Bold And The Beautiful Recaps Soap Central
Restored Republic December 9 2022
Google Chrome-webbrowser
Hindilinks4U Bollywood Action Movies
Jail View Sumter
What Does Code 898 Mean On Irs Transcript
Rs3 Bis Perks
Dcilottery Login
Craigslist Com Panama City Fl
Craigslist Central Il
VDJdb in 2019: database extension, new analysis infrastructure and a T-cell receptor motif compendium
Lawrence E. Moon Funeral Home | Flint, Michigan
Das schönste Comeback des Jahres: Warum die Vengaboys nie wieder gehen dürfen
Wzzm Weather Forecast
Southwind Village, Southend Village, Southwood Village, Supervision Of Alcohol Sales In Church And Village Halls
Chitterlings (Chitlins)
Latest Posts
Article information

Author: Annamae Dooley

Last Updated:

Views: 5710

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Annamae Dooley

Birthday: 2001-07-26

Address: 9687 Tambra Meadow, Bradleyhaven, TN 53219

Phone: +9316045904039

Job: Future Coordinator

Hobby: Archery, Couponing, Poi, Kite flying, Knitting, Rappelling, Baseball

Introduction: My name is Annamae Dooley, I am a witty, quaint, lovely, clever, rich, sparkling, powerful person who loves writing and wants to share my knowledge and understanding with you.