Schedule Python functions on Google Cloud Platform with minimal boilerplate
Project description
Schedulify
Schedulify is a tool for scheduling Python functions on Google Cloud Platform with minimal boilerplate.
NOTE: Schedulify is currently under development, so the full vision has not been realized yet. If you use this tool, please expect significant changes.
Motivation
Google Cloud Platform offers Cloud Scheduler for running tasks according to a schedule. The process to set up a scheduled task involves many steps:
-
Uploading the application. Depending on the runtime chosen, this may involve containerizing the application and exposing the functions through a web server.
-
Creating and configuring a service account to establish trust between the runtime and Cloud Scheduler.
-
Creating a task in Cloud Scheduler.
The motivation behind this tool is to simplify this process.
Requirements
To use this tool, you must have:
- A Google Cloud project with billing enabled
- The following APIs enabled:
- Cloud Build
- Cloud Run
- Cloud Scheduler
- The Google Cloud SDK installed on your computer
- A Python 3.7-compatible app with one or more functions that you want to run periodically
- A
requirements.txt
file that specifies non-standard dependencies, if any
Status
Currently, the tool performs the following tasks, which are meant to be opaque to the user:
- Generates a Flask server that allows the invocation of the functions over HTTP;
- Generates configs to containerize the app using the Python 3.7 slim Docker image;
- Submits the app to Cloud Build; and
- Starts a Cloud Build service.
Note that the tool does not yet perform any operations in Cloud Scheduler. Support for this along with many other improvements are forthcoming. Refer to the Future Work section below for a full list of improvements.
If the above tasks provide utility for your workload and you are comfortable with the instability that comes with a nascent tool, then you may proceed to the next section which describes how to get started.
Getting Started
First, install Schedulify:
pip install schedulify
Then, navigate to your Python project that contains the functions you want to
run. Add a file named shedulify.json
, formatted as follows:
{
"project-id": "my-project-id",
"region": "us-west1",
"functions": [
{
"module": "my_module",
"function": "my_function",
}
]
}
All function references are relative to where schedulify.json
is location. If
your project contains a requirements.txt
file, it must be present in the same
directory as schedulify.json
.
NOTE: The scheduling portion of this tool is not implemented yet, so the configuration file does not accept configuration for how often the function should be executed.
Authenticate through the Google Cloud SDK:
gcloud auth login
Then, from the directory that schedulify.json
resides in, run:
schedulify
You will see the gcloud
invocations printed to standard out. You should see
the tool building the image and deploying it to Cloud Run.
Future Tasks
- Do not rely on
gcloud
for configuring Google Cloud Platform resources. - (Maybe) Use Cloud Functions. Cloud Functions is probably good enough for most use-cases and allows us to substantially reduce the complexity of containerizing an arbitrary Python app.
- Add support for configuring Cloud Scheduler.
Development Guide
Performing a Release
Refer to Python's Packaging documentation for full details on performing a release. Assuming all tools are set up, run the following to push a new package to PyPI:
python setup.py bdist_wheel
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file schedulify-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: schedulify-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0befb767c702e0f9198bd14703acbf6226748e540298988dc184478b79bfc4c7 |
|
MD5 | 37a3d1aa80214d6d4df8f2a9b6c9c347 |
|
BLAKE2b-256 | df6ed44589cb9a3c99e66e0b17ba2e796e69c63772bf8ce3018015f24839f2fa |