4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
90 lines
3.0 KiB
Python
90 lines
3.0 KiB
Python
"""
|
|
Simulated Customer Pipeline - Pure Business Logic.
|
|
|
|
This is what CUSTOMER CODE looks like - just business logic.
|
|
No CloudWatch, no logging infrastructure, no observability code.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import uuid
|
|
|
|
from opentelemetry import trace
|
|
|
|
_pipeline_context = {
|
|
"pipeline_name": "demo_pipeline_cloudwatch",
|
|
"initialized": False,
|
|
}
|
|
|
|
# Initialize telemetry
|
|
_tracer = trace.get_tracer("cloudwatch-demo")
|
|
|
|
|
|
def extract_and_validate(input_path: str, execution_run_id: str) -> str:
|
|
with _tracer.start_as_current_span("extract_data") as span:
|
|
span.set_attribute("execution.run_id", execution_run_id)
|
|
span.set_attribute("input_path", input_path)
|
|
|
|
if not os.path.exists(input_path):
|
|
span.set_attribute("error", True)
|
|
span.set_attribute("error.message", f"empty file not present: {input_path}")
|
|
raise FileNotFoundError(f"empty file not present: {input_path}")
|
|
|
|
with open(input_path) as f:
|
|
data = f.read()
|
|
|
|
if not data or len(data) == 0:
|
|
span.set_attribute("error", True)
|
|
span.set_attribute("error.message", "empty dataset")
|
|
raise ValueError("empty dataset")
|
|
|
|
span.set_attribute("data_size", len(data))
|
|
return data
|
|
|
|
|
|
def transform_data(data: str, execution_run_id: str) -> list[dict]:
|
|
with _tracer.start_as_current_span("transform_data") as span:
|
|
span.set_attribute("execution.run_id", execution_run_id)
|
|
rows = data.split("\n")
|
|
transformed = [{"line": i, "content": row} for i, row in enumerate(rows)]
|
|
span.set_attribute("record_count", len(transformed))
|
|
return transformed
|
|
|
|
|
|
def write_output(transformed_data: list[dict], output_path: str, execution_run_id: str) -> int:
|
|
with _tracer.start_as_current_span("load_data") as span:
|
|
span.set_attribute("execution.run_id", execution_run_id)
|
|
span.set_attribute("output_path", output_path)
|
|
span.set_attribute("record_count", len(transformed_data))
|
|
return len(transformed_data)
|
|
|
|
|
|
def main() -> dict:
|
|
_pipeline_context["initialized"] = True
|
|
execution_run_id = str(uuid.uuid4())
|
|
|
|
input_file = "/data/input.csv"
|
|
output_file = "/data/output.parquet"
|
|
|
|
with _tracer.start_as_current_span("process_pipeline") as root_span:
|
|
root_span.set_attribute("execution.run_id", execution_run_id)
|
|
root_span.set_attribute("pipeline.name", _pipeline_context["pipeline_name"])
|
|
|
|
raw_data = extract_and_validate(input_file, execution_run_id)
|
|
transformed = transform_data(raw_data, execution_run_id)
|
|
rows = write_output(transformed, output_file, execution_run_id)
|
|
|
|
root_span.set_attribute("rows_processed", rows)
|
|
root_span.set_attribute("status", "success")
|
|
|
|
return {
|
|
"pipeline_name": _pipeline_context["pipeline_name"],
|
|
"status": "success",
|
|
"rows_processed": rows,
|
|
"execution_run_id": execution_run_id,
|
|
}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|