Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pipelex/pipelex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

[pipelex.pipeline_execution_config]
# Set to false to disable conversion of incoming data URLs to pipelex-storage:// URIs
is_normalize_data_urls_to_storage = true
is_normalize_data_urls_to_storage = false
# Set to false to disable generation of execution graphs
is_generate_graph = true

Expand Down Expand Up @@ -65,7 +65,7 @@ pan_to_top = true # Pan to show top of graph on load

[pipelex.storage_config]
# Storage method: "local", "in_memory" (default), "s3", or "gcp"
method = "in_memory"
method = "s3"
# Whether to fetch remote HTTP URLs and store them locally
is_fetch_remote_content_enabled = true

Expand All @@ -81,8 +81,8 @@ uri_format = "{primary_id}/{secondary_id}/{hash}.{extension}"
[pipelex.storage_config.s3]
# AWS S3 storage settings (requires boto3: `pip install pipelex[s3]`)
uri_format = "{primary_id}/{secondary_id}/{hash}.{extension}"
bucket_name = ""
region = ""
bucket_name = "pipelex-assets"
region = "eu-west-3"
signed_urls_lifespan_seconds = 3600 # Set to "disabled" for public URLs

[pipelex.storage_config.gcp]
Expand Down
51 changes: 10 additions & 41 deletions api/routes/pipelex/build/inputs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import traceback
from typing import Any

from fastapi import APIRouter, HTTPException
from fastapi.responses import JSONResponse
from pipelex import log
from pipelex.hub import get_library_manager, get_required_pipe, set_current_library
from pipelex.pipeline.validate_bundle import validate_bundle
from pydantic import BaseModel, Field
Expand All @@ -15,58 +16,26 @@ class BuildInputsRequest(BaseModel):
pipe_code: str = Field(..., description="Pipe code to generate inputs JSON for")


class BuildInputsResponse(BaseModel):
inputs_json: dict[str, Any] = Field(..., description="Generated inputs JSON object")
pipe_code: str = Field(..., description="Pipe code that was used")
success: bool = Field(default=True, description="Whether the operation was successful")
message: str = Field(default="Inputs JSON generated successfully", description="Status message")


@router.post("/build/inputs", response_model=BuildInputsResponse)
async def generate_inputs_json(request_data: BuildInputsRequest):
"""Generate example input JSON for a pipe.

This endpoint generates a JSON object with example values for all pipe inputs
based on their concept types.

It will:
1. Parse and validate the PLX content
2. Load pipes from the bundle
3. Generate inputs JSON for the specified pipe
"""
@router.post("/build/inputs")
async def build_inputs(request_data: BuildInputsRequest) -> Any:
"""Generate example input JSON for a pipe."""
library_manager = get_library_manager()

try:
# Validate and load the PLX content
validate_bundle_result = await validate_bundle(plx_content=request_data.plx_content)
blueprint = validate_bundle_result.blueprints[0]

library_id, _ = library_manager.open_library()
set_current_library(library_id)
# Load pipes temporarily
library_manager.load_from_blueprints(library_id=library_id, blueprints=[blueprint])

# Get the pipe
the_pipe = get_required_pipe(pipe_code=request_data.pipe_code)

# Generate the input JSON
inputs_json_str = the_pipe.inputs.render_inputs(indent=2)
inputs_json = json.loads(inputs_json_str)

response_data = BuildInputsResponse(
inputs_json=inputs_json,
pipe_code=request_data.pipe_code,
success=True,
message="Inputs JSON generated successfully",
)

return JSONResponse(content=response_data.model_dump(serialize_as_any=True))
return json.loads(inputs_json_str)

except Exception as exc:
raise HTTPException(
status_code=500,
detail={
"error_type": type(exc).__name__,
"message": str(exc),
},
) from exc
log.error(f"Error generating inputs JSON for pipe '{request_data.pipe_code}':")
traceback.print_exc()

raise HTTPException(status_code=500, detail=str(exc)) from exc
55 changes: 13 additions & 42 deletions api/routes/pipelex/build/output.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import json
import traceback
from typing import Any

from fastapi import APIRouter, HTTPException
from fastapi.responses import JSONResponse
from pipelex import log
from pipelex.core.concepts.concept_representation_generator import ConceptRepresentationFormat
from pipelex.core.pipes.output.output_renderer import render_output
from pipelex.hub import get_library_manager, get_required_pipe, set_current_library
from pipelex.pipeline.validate_bundle import validate_bundle
from pydantic import BaseModel, Field
Expand All @@ -13,60 +16,28 @@
class BuildOutputRequest(BaseModel):
plx_content: str = Field(..., description="PLX content to load pipes from")
pipe_code: str = Field(..., description="Pipe code to generate output JSON for")
format: ConceptRepresentationFormat = Field(default=ConceptRepresentationFormat.SCHEMA, description="Format to generate output in")


class BuildOutputResponse(BaseModel):
output_json: dict[str, Any] = Field(..., description="Generated output JSON object")
pipe_code: str = Field(..., description="Pipe code that was used")
success: bool = Field(default=True, description="Whether the operation was successful")
message: str = Field(default="Output JSON generated successfully", description="Status message")


@router.post("/build/output", response_model=BuildOutputResponse)
async def build_output(request_data: BuildOutputRequest):
"""Generate example output JSON for a pipe.

This endpoint generates a JSON object showing the expected output structure
based on the pipe's output concept type.

It will:
1. Parse and validate the PLX content
2. Load pipes from the bundle
3. Generate output JSON for the specified pipe
"""
@router.post("/build/output")
async def build_output(request_data: BuildOutputRequest) -> Any:
library_manager = get_library_manager()

try:
# Validate and load the PLX content
validate_bundle_result = await validate_bundle(plx_content=request_data.plx_content)
blueprint = validate_bundle_result.blueprints[0]

library_id, _ = library_manager.open_library()
set_current_library(library_id)
# Load pipes temporarily
library_manager.load_from_blueprints(library_id=library_id, blueprints=[blueprint])

# Get the pipe
the_pipe = get_required_pipe(pipe_code=request_data.pipe_code)
output_json_str = render_output(the_pipe, output_format=request_data.format)

# Generate the output JSON (content only, no concept wrapper)
output_dict = the_pipe.output.render_stuff_spec(ConceptRepresentationFormat.JSON)
output_json = output_dict.get("content", output_dict)

response_data = BuildOutputResponse(
output_json=output_json,
pipe_code=request_data.pipe_code,
success=True,
message="Output JSON generated successfully",
)

return JSONResponse(content=response_data.model_dump(serialize_as_any=True))
return json.loads(output_json_str)

except Exception as exc:
raise HTTPException(
status_code=500,
detail={
"error_type": type(exc).__name__,
"message": str(exc),
},
) from exc
log.error(f"Error generating output JSON for pipe '{request_data.pipe_code}':")
traceback.print_exc()

raise HTTPException(status_code=500, detail=str(exc)) from exc
1 change: 0 additions & 1 deletion api/routes/pipelex/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ async def execute(
)

return PipelineResponseFactory.make_from_pipe_output(
status="success",
pipeline_run_id=pipe_output.pipeline_run_id,
pipeline_state=PipelineState.COMPLETED,
created_at=created_at,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
]

[tool.uv.sources]
pipelex = { path = "../pipelex", editable = true}
pipelex = { git = "https://github.com/Pipelex/pipelex.git", rev = "moad" }


[build-system]
Expand Down
73 changes: 2 additions & 71 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.