Skip to content

Instantly share code, notes, and snippets.

@chespinoza
Created September 3, 2021 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chespinoza/ca536352fc3f74921e6889ae3b6dbbd3 to your computer and use it in GitHub Desktop.
Save chespinoza/ca536352fc3f74921e6889ae3b6dbbd3 to your computer and use it in GitHub Desktop.
Gator

What is Gator?

Gator is a convenient wrapper around procrastinate which provides a basic web UI through a starlette app which can be used to extend functionality, for instance adding endpoints to trigger tasks asynchronously.

What is a task in Gator's terms?

Gator Tasks are basically a Python script file which lives into the task/ folder, they share the same Gator's namespace, therefore dependencies for new tasks will be installed as Gator dependencies, a nozzle_vendorised folder is included on Gator's namespace so the python modules it contains can be shared between tasks, in the same way it could be added other folders to share common code between tasks.

Once a new task is added, Gator needs to be restarted in order to load it.

What a Gator task can do today?

It can do anything that one would achieve using Python.

How to create a new Gator task?

1- Create a python file into /tasks 2- The entry point for the task can be any async Python function decorated with app.task, i.e.

@app.task(pass_context=True)
async def get_time(ctx: procrastinate.job_context.JobContext) -> None:
    res = httpx.get("https://worldtimeapi.org/api/timezone/Europe/London")
    res.raise_for_status()
    with open("my_time_result.json", "w+") as file:
        file.write(json.dumps(res.json()))

3- make the function accessible by Gator, adding an entry to the file tasks/__init__.py i.e.

    import_paths=[
			"nozzle.gator.tasks.get_time"
    ]

4

What Gator can do today?

What Gator can't do today?

Which features are desirable and aren't implemented yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment