To begin, create a new virtual environment, for example using the virtualenvwrapper package. After that, install dependencies:
$ pip install -r requirements.txt
.
βββ README.md # This file
βββ formatters.py # Data formatting
βββ hooks.py # Webhooks instructions
βββ jobs # Jobs definition
β βββ __init__.py # Jobs triggers
β βββ base.py # Base structures
β βββ <job_name>.py # Job code
βββ main.py # Scheduler entrypoint
βββ retry.py # Job retry function
βββ scheduler.py # Scheduler intialization
βββ settings.py
βββ tests
βββ conftest.py # Fixtures
βββ test_*.py
To create a new job, create a new module in jobs/
directory. After implementing the job, it's definition must be added to jobs/__init__.py
:
all_jobs = [
JobDefinition(
id="xkom", function=xkom, trigger=CronTrigger(hour="10,22", second="10")
),
]
For triggers documentation, refer to APScheduler's documentation (apscheduler.triggers.*
modules).
For settings, environment variables are used, along with python-dotenv package, which loads .env
file.
For tests, pytest
package is used in following manner:
$ python -m pytest
Code should be formatted using black
and isort
. Be sure to run the following before commiting:
black . && isort -y