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_library_v2-1.1.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: cloudshift_library_v2-1.1.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.15.0a5

File hashes

Hashes for cloudshift_library_v2-1.1.1.tar.gz
Algorithm Hash digest
SHA256 a562991dcc364d31e80c1dae2ce665fe8d1a02352a9e5545265b08b655483187
MD5 8ba91c2bd1f44f77c1a6ac79063514d4
BLAKE2b-256 b1f01e967cb8fe2027007e8f755b68db19138e1d2110461ee22987630225c242

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cloudshift_library_v2-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a3ed15c1e9f4487c3f15433c9ebd3acfeba7c991bb34e3271f17de59ea6f3f2
MD5 619a5f460c99527b9591726f355ab6b3
BLAKE2b-256 b816070307c2bbea3d824d8fce7ad5cc6ffdccb6709d1c5851bb21bd6814f79b

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