Scheduling your Automation

Create fully automated processes by scheduling your Python script to run on GitHub


After you've used Mito to write Python code, you may want to schedule this code to execute on a repeated basis. Mito makes it incredibly easy to schedule a Python automation, automatically handling:

  1. Automatic version control/documentation: Mito will place your automation and initial data files under version control, making sure that you never loose your work. Moreover, auto-generated documentation means your team can easily understand your automations.

  2. Avoid breaking dependency updates: Mito will automatically detect what dependencies you're using, and freeze them for your automation. This makes sure future package changes don't break your code without your knowledge!

  3. Avoid complex scheduling interfaces: Visually tell Mito the cadence to run your automation and let Mito handle generating cron job syntax, timezones, ensuring runners are available, and making sure all you need to do is download the result.

Where does my automation run?

Currently, Mito supports Github Actions as it's primary automation location. Mito will automatically open automation PRs against your selected repository.

How to schedule an automation:

Step 1: Create an Automations repository and configure it in Mito

  1. Create a new Github repo. You can find instructions here.

  2. Set the new Github Repo as the automation repository for Mito, using environmental variables.

import os
os.environ['MITO_CONFIG_GITHUB_AUTOMATION_REPO'] = 'mito-ds/mito-automations-test'

Step 2: Create a personal access token, and add it to your environment

  1. Create a Github Token, following the instructions here. It will look something like "ghp_thisisarandomstringoflettersandnumbers"

  2. Set the Github Token as an environmental variable wherever you are running Mito.

import os
os.environ["GITHUB_TOKEN"] = "ghp_thisisarandomstringoflettersandnumbers"

Step 3: Use the Schedule Automation interface in the Code tab

  1. Select Code > Schedule Automation

  2. Give the automation a descriptive Automation Name and Automation Description. The Automation Name will become the GitHub PR title and the Automation Description will be the PR description.

  3. Configure the Automation Schedule.

  4. Click Schedule on Github. Mito will create a new PR with the required input files, Python code, and GitHub action workflow. In a few moments the PR will be ready for review.

Step 4: Review and merge this PR

  1. Review the code of this PR, making any necessary changes or updates

  2. Merge this PR into the main branch to schedule the automation.

Step 5: Get the results of future automation runs

  1. Go to the Github repo configured in Step 1.

  2. Go to the Actions tab and select the action for this automation.

  3. Click on the most recent run for this automation.

  4. Scroll down, and download the results artifact. This will contain the results of the automation. If there is no results artifact, this is likely because you did not export any files in your generated code.

Last updated