Skip to main content

A core logic engine for employee scheduling and shift management.

Project description

Shiftwise 🕒

Shiftwise is a robust, lightweight Python library designed to handle the core logic of employee scheduling, shift management, and leave coordination. It provides a clean, model-driven approach to validatng business rules, preventing scheduling conflicts, and managing complex shift swaps.

Developed as the engine behind the Cloud Shift platform, shiftwise is now available as a standalone package for any workforce management application.

🚀 Features

  • Model-Driven Architecture: Clean dataclass models for User, Shift, Leave, and SwapRequest.
  • Intelligent Validation:
    • Automated capacity checks for shifts.
    • Skill-based assignment verification.
    • Overlap and conflict detection for shifts and leaves.
  • Manager Classes:
    • ShiftManager: Manage employee assignments and removals.
    • LeaveManager: Workflow for requesting, approving, and rejecting leave.
    • SwapManager: Peer-to-peer shift swap logic with safety checks.
  • Custom Exceptions: Descriptive errors like ShiftFullError, ShiftConflictError, and LeaveConflictError.

📦 Installation

pip install shiftwise

🛠️ Quick Start

1. Define your Models

from datetime import datetime
from shiftwise import Shift, User, Role

# Create a shift
night_shift = Shift(
    shift_id="S123",
    title="Night Watch",
    start_time=datetime(2023, 10, 20, 22, 0),
    end_time=datetime(2023, 10, 21, 6, 0),
    max_capacity=5,
    required_skills=["FirstAid"]
)

# Create an employee
employee = User(
    user_id="E001",
    email="alice@example.com",
    first_name="Alice",
    last_name="Smith",
    role=Role.EMPLOYEE,
    skills=["FirstAid"]
)

2. Manage Assignments

from shiftwise import ShiftManager

manager = ShiftManager()

# Assign employee to shift (validates capacity, skills, and conflicts)
try:
    manager.assign_employee(
        shift=night_shift,
        employee_id=employee.user_id,
        employee_skills=employee.skills,
        current_employee_shifts=[],
        current_employee_leaves=[]
    )
    print(f"Successfully assigned {employee.first_name} to {night_shift.title}")
except Exception as e:
    print(f"Assignment failed: {e}")

3. Handle Leave Requests

from shiftwise import LeaveManager, Leave, LeaveType
from datetime import date

leave_mgr = LeaveManager()
requested_leave = Leave(
    leave_id="L1",
    employee_id="E001",
    leave_type=LeaveType.ANNUAL,
    start_date=date(2023, 12, 24),
    end_date=date(2023, 12, 26)
)

# Request leave (fails if overlaps with existing requests)
new_request = leave_mgr.request_leave("E001", [], requested_leave)

⚖️ License

Distributed under the MIT License. See LICENSE for more information.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

cloudshift_v2-1.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

cloudshift_v2-1.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file cloudshift_v2-1.1.1.tar.gz.

File metadata

  • Download URL: cloudshift_v2-1.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cloudshift_v2-1.1.1.tar.gz
Algorithm Hash digest
SHA256 7fc10b76f023051e039770c8976f38d8e859fa9f0d2f0ae72eb203949d360a55
MD5 136cd64f4b97ad81a2ca22cc2a31a649
BLAKE2b-256 a704b6232a9d591cee2bec3063f4cd5f276ce27aebb13c43b121b7210d1de2f8

See more details on using hashes here.

File details

Details for the file cloudshift_v2-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: cloudshift_v2-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cloudshift_v2-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 705eade4f3ccbd53942e839a58be5149529e643efe878a25e09740fa39ba31cf
MD5 3495bd4aaf8168e32208b5eed30ba92d
BLAKE2b-256 e22ab746605eda76d8f619c851a8565e5e46018c59b12b24cc9457eb17990c8f

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