Python SDK & API Reference
The authoritative Python API reference for programmatic catalog discovery, project tailoring, Draft 2020-12 schema validation, and headless deliverable compilation.
1. Architectural Foundation & Zero-Dependency Design
The tasleemat Python library is built with a strict zero-external-dependency philosophy.
It relies exclusively on Python standard library modules (json, pathlib, dataclasses, hashlib, re, csv),
ensuring instant installation, zero dependency conflicts, and guaranteed execution in ultra-secure, air-gapped container runtimes.
- Thread-Safe In-Memory Caching: Catalog indexing and schema parsing are memoized on first load for microsecond retrieval times.
- Source Immutability Protection: Internal filesystem resolvers block any write or modification operations targeting package data.
- Cross-Platform Compatibility: Native POSIX and Windows filesystem support with UTF-8 encoding normalization.
2. The 8 Verified Core API Functions
tasleemat.list_artifacts(phase=None, tier=None, pack=None)
Discovers deliverable metadata objects across the entire catalog or filtered by lifecycle phase, sizing tier, or methodology pack.
import tasleemat
# List all 114 deliverables
all_artifacts = tasleemat.list_artifacts()
print(f"Total deliverables: {len(all_artifacts)}")
# Discover deliverables for Phase 03 (Initiating) in Tier 2
phase_artifacts = tasleemat.list_artifacts(phase="03", tier=2)
for art in phase_artifacts:
print(f"- [{art.artifact_id}] {art.name_en} / {art.name_ar}")
tasleemat.get_artifact_definition(artifact_id: str) -> dict
Retrieves the canonical metadata dictionary for a specific deliverable code, including English/Arabic names, phase code, and supported tiers.
meta = tasleemat.get_artifact_definition("PMO-03.01")
print(f"Name (EN): {meta['name_en']}")
print(f"Name (AR): {meta['name_ar']}")
print(f"Allocated Tiers: {meta['tiers']}")
tasleemat.get_artifact_assets(artifact_id: str, lang='en') -> ArtifactAssets
Returns a secure wrapper object providing access to the 5 companion files: template, guide, example, schema, and dictionary.
assets = tasleemat.get_artifact_assets("PMO-03.01", lang="ar")
# Direct content accessors
template_text = assets.get_template_content()
guide_text = assets.get_guide_content()
example_text = assets.get_example_content()
schema_dict = assets.get_schema_data()
dict_rows = assets.get_dictionary_rows()
# Or fetch directly by role string:
schema_raw = tasleemat.get_artifact_asset("PMO-03.01", role="schema", lang="en")
tasleemat.get_tailoring_profile(tier: Union[int, str], pack: str='general') -> List[str]
Computes the exact deterministic list of required deliverable codes matching a governance tier and delivery pack.
# Resolve required deliverables for Tier 2 Agile Project
deliverable_ids = tasleemat.get_tailoring_profile(tier=2, pack="agile")
print(f"Allocated {len(deliverable_ids)} deliverables: {deliverable_ids[:5]}...")
tasleemat.validate_artifact_data(artifact_id: str, data: dict, mode='strict') -> ValidationReport
Executes pure-Python Draft 2020-12 schema validation on incoming JSON data payloads. Supports strict and draft modes.
payload = {
"project_id": "PRJ-2026-CLOUD",
"project_name": "Cloud Transformation Platform",
"sponsor": "Executive VP Operations",
"project_manager": "Sarah Al-Ahmad",
"authorization_date": "2026-10-15"
}
report = tasleemat.validate_artifact_data("PMO-03.01", payload, mode="strict")
if report.valid:
print("Payload conforms 100% to Draft 2020-12 schema!")
else:
for err in report.errors:
print(f"Error at {err.path}: {err.message} (Rule: {err.keyword})")
tasleemat.get_lexicon() & tasleemat.render_artifact()
get_lexicon() retrieves bilingual project management terminology mappings.
render_artifact() compiles markdown templates and structured data into standalone, print-ready HTML with Arabic RTL support.
# Terminology lookup
terms = tasleemat.get_lexicon(category="governance")
# Headless HTML render
html_output = tasleemat.render_artifact(
artifact_id="PMO-03.01",
lang="ar",
data=payload,
out_path="./output_charter.html"
)
3. Data Models & Type Classes
ArtifactSummary (Immutable Dataclass)
@dataclass(frozen=True)
class ArtifactSummary:
artifact_id: str # Unique code (e.g. "PMO-03.01")
prefix: str # File prefix (e.g. "03_01")
name_en: str # English name (e.g. "Project Charter")
name_ar: str # Arabic name (e.g. "ميثاق المشروع")
phase_code: str # Lifecycle phase code ("00" to "07")
phase_name_en: str # Phase name in English
phase_name_ar: str # Phase name in Arabic
tiers: List[str] # Supported tiers: ["1", "2", "3"]
fingerprint: str # SHA-256 fingerprint of canonical source
completed_data_validation: dict # Pre-validated baseline report
ValidationReport & ValidationError
@dataclass
class ValidationReport:
valid: bool # True if payload passes all schema rules
errors: List[ValidationError] # List of structured validation errors
schema_id: str # Canonical URI of the companion schema
schema_dialect: str # "https://json-schema.org/draft/2020-12/schema"
fingerprint: str # Cryptographic hash of schema file
@dataclass
class ValidationError:
path: str # JSON Pointer / property path (e.g. "/risks/0/score")
message: str # Detailed failure explanation
keyword: str # Violated schema keyword (e.g. "required", "format")
schema_path: str # Path inside schema where constraint was declared
4. Production Implementation Tutorials
Tutorial 1: Building a Governance REST API with FastAPI
Wrap the tasleemat SDK into high-performance REST microservices for enterprise integration:
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from typing import Optional, List, Dict, Any
import tasleemat
app = FastAPI(title="Tasleemat PMO Governance API", version="2.5.0")
class TailorRequest(BaseModel):
tier: int
pack: str = "general"
class ValidateRequest(BaseModel):
artifact_id: str
data: Dict[str, Any]
mode: str = "strict"
@app.get("/api/v1/artifacts")
def list_artifacts(phase: Optional[str] = None, tier: Optional[int] = None):
results = tasleemat.list_artifacts(phase=phase, tier=tier)
return [
{"id": a.artifact_id, "name_en": a.name_en, "name_ar": a.name_ar, "phase": a.phase_code}
for a in results
]
@app.post("/api/v1/tailor")
def tailor_project(req: TailorRequest):
try:
deliverable_ids = tasleemat.get_tailoring_profile(tier=req.tier, pack=req.pack)
return {"tier": req.tier, "pack": req.pack, "count": len(deliverable_ids), "deliverables": deliverable_ids}
except Exception as e:
raise HTTPException(status_code=400, detail=str(e))
@app.post("/api/v1/validate")
def validate_deliverable(req: ValidateRequest):
report = tasleemat.validate_artifact_data(req.artifact_id, req.data, mode=req.mode)
return {
"valid": report.valid,
"errors": [{"path": e.path, "message": e.message, "rule": e.keyword} for e in report.errors],
"schema_id": report.schema_id
}
Tutorial 2: Interactive PMO Portal with Streamlit
Deploy an interactive internal web portal for project managers to tailor their projects and validate deliverables live:
import streamlit as st
import json
import tasleemat
st.set_page_config(page_title="Tasleemat PMO Portal", layout="wide")
st.title("🛡️ Enterprise PMO Deliverables Portal")
st.sidebar.header("Project Tailoring Parameters")
tier = st.sidebar.selectbox("Governance Sizing Tier", [1, 2, 3], index=1)
pack = st.sidebar.selectbox("Delivery Archetype Pack", ["general", "agile", "ai", "predictive", "hybrid"])
deliverables = tasleemat.get_tailoring_profile(tier=tier, pack=pack)
st.sidebar.success(f"Allocated Deliverables: {len(deliverables)}")
col1, col2 = st.columns([1, 1])
with col1:
st.subheader("Required Deliverables Manifest")
selected_id = st.selectbox("Select Deliverable to Inspect", deliverables)
assets = tasleemat.get_artifact_assets(selected_id, lang="en")
st.markdown(f"**Guide:**\n{assets.get_guide_content()[:500]}...")
with col2:
st.subheader(f"Validate Payload against Schema ({selected_id})")
sample_json = json.dumps({"project_id": "PRJ-01", "name": "Cloud App"}, indent=2)
user_input = st.text_area("JSON Payload", sample_json, height=220)
if st.button("Run Schema Validation"):
try:
payload = json.loads(user_input)
report = tasleemat.validate_artifact_data(selected_id, payload, mode="strict")
if report.valid:
st.success("✅ Payload passed all Draft 2020-12 schema assertions!")
else:
for err in report.errors:
st.error(f"❌ At {err.path}: {err.message}")
except json.JSONDecodeError as e:
st.warning(f"Invalid JSON format: {e}")
Tutorial 3: Attested Earned Value Management (EVM) Calculation Engine
Execute deterministic, mathematically audited computations for project metrics in PMO-06.05 with zero-division handling:
def calculate_evm_metrics(pv: float, ev: float, ac: float, bac: float) -> dict:
# Computes PMI PMBOK standard Earned Value Management metrics with safe division
# Variances
cv = ev - ac # Cost Variance
sv = ev - pv # Schedule Variance
# Indices
cpi = (ev / ac) if ac > 0 else 1.0 # Cost Performance Index
spi = (ev / pv) if pv > 0 else 1.0 # Schedule Performance Index
# Forecasting
eac = (bac / cpi) if cpi > 0 else bac # Estimate At Completion
etc = eac - ac # Estimate To Complete
vac = bac - eac # Variance At Completion
# To-Complete Performance Index (TCPI)
remaining_work = bac - ev
remaining_budget = bac - ac
tcpi = (remaining_work / remaining_budget) if remaining_budget > 0 else 1.0
return {
"cost_variance": round(cv, 2),
"schedule_variance": round(sv, 2),
"cpi": round(cpi, 3),
"spi": round(spi, 3),
"eac": round(eac, 2),
"etc": round(etc, 2),
"vac": round(vac, 2),
"tcpi": round(tcpi, 3),
"status": "HEALTHY" if cpi >= 1.0 and spi >= 1.0 else "WARNING"
}
# Example calculation:
metrics = calculate_evm_metrics(pv=100000, ev=95000, ac=105000, bac=250000)
print(f"Project CPI: {metrics['cpi']}, SPI: {metrics['spi']}, EAC: ${metrics['eac']:,}")