Skip to main content

A Polars plugin for easily scheduling recurring events with constraints.

Project description

Polars Scheduler

A Polars plugin for easily scheduling recurring events with constraints.

Installation

pip install polars-scheduler[polars]

On older CPUs run:

pip install polars-scheduler[polars-lts-cpu]

Usage

The plugin adds a scheduler namespace to Polars DataFrames with methods for registering events and constraints:

import polars as pl
import polars_scheduler

# Create a new empty schedule
schedule = pl.DataFrame().scheduler.new()

# Add simple meal and medication schedule
schedule = schedule.scheduler.add(
    event="breakfast",
    category="meal",
    unit="serving",
    frequency="1x daily",
)

...

The idea is that you have a DataFrame with a schedule of the day so far perhaps (in this case I don't as it's still a proof-of-concept) and then you have the recurring events expressed as a schedule with constraints.

This schedule of constraints would get built up (as in this example, see examples/nutrition.py) and then you would validate or schedule ahead.

┌──────────────┬────────────┬─────────┬────────┬─────────┬───────────┬──────────────┬──────────────┐
 Event         Category    Unit     Amount  Divisor  Frequency  Constraints   Note         
 ---           ---         ---      ---     ---      ---        ---           ---          
 str           str         str      f64     i64      str        list[str]     str          
╞══════════════╪════════════╪═════════╪════════╪═════════╪═══════════╪══════════════╪══════════════╡
 breakfast     meal        serving  null    null     1x daily   []            null         
 lunch         meal        serving  null    null     1x daily   []            null         
 dinner        meal        serving  null    null     1x daily   []            null         
 vitamin       supplement  pill     null    null     1x daily   ["with       ┆ null         │
                                                                breakfast"]  ┆              │
 antibiotic    medication  pill     null    null     2x daily   ["≥1h after  ┆ null         │
                                                                meal"]       ┆              │
 probiotic     supplement  capsule  null    null     1x daily   ["≥2h after  ┆ null         │
                                                                antibiotic"] ┆              │
 protein       supplement  gram     30.0    null     1x daily   ["≤30m after ┆ mix with     │
 shake                                                          gym OR with   300ml water  
                                                                breakfast"]  ┆              │
 ginger        supplement  shot     null    null     1x daily   ["before     ┆ null         │
                                                                breakfast"]  ┆              │
 gym           exercise    session  null    null     3x weekly  []            null         
└──────────────┴────────────┴─────────┴────────┴─────────┴───────────┴──────────────┴──────────────┘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_scheduler-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polars_scheduler-0.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file polars_scheduler-0.1.0.tar.gz.

File metadata

  • Download URL: polars_scheduler-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.10.6 Linux/5.15.0-125-generic

File hashes

Hashes for polars_scheduler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 250e4f29c60563bcbdfc4f89519b7cfd3a7e84f19969f5c95b30cc32d2da7f39
MD5 391a9e67cac747702295daa29090980c
BLAKE2b-256 bd48bd213550f1e058b42f0fde867374f32f6b1e851c46241fe290307cd9c2bb

See more details on using hashes here.

File details

Details for the file polars_scheduler-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: polars_scheduler-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.10.6 Linux/5.15.0-125-generic

File hashes

Hashes for polars_scheduler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a3976ddeb251bcd673c6cf6bd5c07ecffa1bb6e9769fa6da6521b092bdc9ccdb
MD5 f1cc16716d734e7b026f481ee8fb0dd6
BLAKE2b-256 e61edc4fc24d325550158d9874465d224883373d0f507ceb6778840fe6dcc7da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page