Mara Cron
Mini package for managing cron jobs via mara.
Installation
To use the library directly:
pip install mara-cron
Config of cron jobs
To configure cron jobs in mara you just need to add a new function MARA_CRON_JOBS
in your module or app in the __init__.py file.
Here is a sample which has two jobs:
- the job
cleanup_data_folderclears all data from the local folder/data/. This job is by default disabled. - the job
nightlyruns the root pipeline at 01:00 o'clock each day
Note: The MaraJob job requires that you define the PATH environment variable in your crontab. Cron by default uses just /usr/bin:/bin which is not enough. I recommend using the distribution default e.g. /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
def MARA_CRON_JOBS():
from mara_cron.job import CronJob, MaraJob
return [
CronJob(id='cleanup_data_folder',
description='Clean up the data folder',
default_time_pattern='0 0 * * *',
command='rm -rf /data/*',
enabled=False),
MaraJob(id='nightly',
description="Nightly run of the BI system",
default_time_pattern='0 1 * * *',
command='pipelines run'),
]
Local config
Sample local config to activate crontab management in your mara app:
from mara_app.monkey_patch import patch
import mara_cron.config
# Activates mara_cron jobs. If not set all jobs are
# by default disabled and can only be activated via
# executing:
# mara cron enable --job-id "my_job_id"
patch(mara_cron.config.enabled)(lambda: True)
# Optional parameter to specify a mara instance name
# This is necessary to separate multiple environments running
# on the same user
patch(mara_cron.config.instance_name)(lambda: 'prod')
CLI
This package contains the following cli commands (mara cron <command>):
| Command | Description |
|---|---|
enable --job-id "my_job_id" [--module "module_name"] |
Enables a specific job regardless of the configuration. |
disable --job-id "my_job_id" [--module "module_name"] |
Disables a specific job. |
schedule-job --job-id "my_job_id" |
Schedules a job to run in less than 1 minute. |
list-crontab |
Lists the current cron tab settings |
list-crontab --with-changes |
Lists the current cron tab including the changes not yet written |
write-crontab |
Writes all not published changes to the crontab |
clear-crontab |
Removes all mara jobs from the crontab. Note This applies to all instances !!! |
Metadata
Release files for mara-cron 0.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mara-cron-0.12.0.tar.gz | 11.6 kB | Without provenance | Details for mara-cron-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mara_cron-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for mara_cron-0.12.0-py3-none-any.whl |
Total release size: 23.6 kB
Release files / mara-cron-0.12.0.tar.gz
| Download URL | mara-cron-0.12.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5804901c695047779e4a214e56c6b3372e521606923926f3c121b3a09402a350
|
|
BLAKE2b-256 checksum How to use checksums |
9c9262d414e2809a6b48ff74bbef08c498c98a9e3065fe7a63945227c0ef7231
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / mara_cron-0.12.0-py3-none-any.whl
| Download URL | mara_cron-0.12.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b24a8aaf2f1de80eda6f8c08842c0282fe9fceabd7b2353ef37c8b89945e75a
|
|
BLAKE2b-256 checksum How to use checksums |
3f2a63b4d633d2fb22c5fbd6eccbded06690a2b732d716af87ac70475e8f7c23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for mara-cron 0.12.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.