This document describes the REST API endpoints for interacting with the Augmentoolkit server, allowing you to manage and run data generation pipelines, monitor their status, and manage associated files (inputs, outputs, logs, configs).
The API is built using FastAPI and utilizes Huey for background task queueing and Redis for state management (task status, PID mapping, output directory mapping).
Base URL: (Assuming the server runs locally on port 8000) http://127.0.0.1:8000
- Pipelines: Defined sequences of data processing steps, typically corresponding to Python functions within the codebase (e.g., in a
pipelinesdirectory). - Tasks: An instance of a pipeline run, managed by the Huey background task queue. Each task has a unique
task_id. - Nodes: Refers to the importable path of the Python function that executes a pipeline (e.g.,
pipelines.my_pipeline.run). - Configs: YAML configuration files (stored in
./external_configs/) that provide parameters for pipeline runs. Can be overridden by parameters in the API request. - Super Config (
super_config.yaml): Defines path aliases used for resolving node and config paths. - Directories:
./inputs/: Stores input data files used by pipelines../outputs/: Stores output files generated by pipelines. Output directories are often named using thetask_id../external_configs/: Stores reusable pipeline configuration files../logs/: Stores log files (<task_id>.log) for each pipeline task run.
- GET /
- Summary: Health Check
- Description: Basic health check endpoint. Returns a simple message indicating the API is running.
- Response:
{"message": "Augmentoolkit API is running."}
-
POST /pipelines/run
- Summary: Queue a dataset generation pipeline for execution.
- Status Code: 202 Accepted
- Description: Resolves node and config paths using aliases from
super_config.yamland enqueues a pipeline task using Huey (tasks.run_pipeline_task). The task executes the pipeline defined bynode_pathpotentially using configuration fromconfig_pathandparametersviarun_augmentoolkit.py. - Request Body:
{ "node_path": "string (required, can use aliases)", "config_path": "string (optional, relative to ./external_configs/ or absolute, can use aliases)", "parameters": { /* JSON object of key-value pairs (optional) */ } } - Response:
{ "pipeline_id": "string (Huey Task ID)", "message": "Pipeline run queued successfully." }
-
GET /pipelines/available
- Summary: Get available pipeline aliases from super_config.yaml.
- Description: Reads the
super_config.yamlfile and returns a sorted list of path aliases (keys) whose corresponding values do not end with.yaml. These aliases typically represent the runnable entry points for pipelines that can be passed to thenode_pathfield in the/pipelines/runendpoint. - Path Parameters: None
- Query Parameters: None
- Response: A JSON list of strings.
[ "alias1", "alias2", "another-pipeline-alias", ... ]
- Error Responses:
- 500 Internal Server Error: If
super_config.yamlcannot be found or parsed, or an unexpected error occurs. (Note: If the file is found but empty orpath_aliasesis missing/invalid, it currently returns an empty list[]gracefully).
- 500 Internal Server Error: If
-
GET /tasks/{task_id}/status
- Summary: Get the status of a pipeline run.
- Description: Retrieves the current status (PENDING, RUNNING, COMPLETED, FAILED, REVOKED) and result (if finished) of a specific pipeline task using its
task_id. Checks Huey's state and potentially Redis for progress information. - Path Parameters:
task_id: The Huey task ID obtained from/pipelines/run.
- Response:
{ "task_id": "string", "status": "string (PENDING | RUNNING | COMPLETED | FAILED | REVOKED)", "message": "string (optional)", "progress": "float (optional, 0.0-1.0)", "details": { /* Optional details, e.g., error info or result */ } } - Error Responses:
- 404 Not Found: If
task_iddoes not exist. - 500 Internal Server Error: If status retrieval fails.
- 404 Not Found: If
-
GET /tasks/{task_id}/parameters
- Summary: Get the parameters a task was executed with.
- Description: Retrieves the parameters (combined from config file and request overrides) that were used to start a specific task run. Parameters are stored in Redis when the task begins execution and persist based on a configured timeout (typically several days).
- Path Parameters:
task_id: The Huey task ID obtained from/pipelines/run.
- Response:
{ "task_id": "string", "parameters": { /* JSON object of key-value pairs used for the task */ } } - Error Responses:
- 404 Not Found: If the
task_iddoes not exist or if the parameters were not stored/have expired. - 500 Internal Server Error: If retrieving or parsing the parameters from Redis fails (e.g., data corruption).
- 404 Not Found: If the
-
POST /tasks/{task_id}/interrupt
- Summary: Interrupt a running pipeline task subprocess or revoke a pending task.
- Description: Attempts to interrupt a running task or revoke a pending one.
- If the task is RUNNING: Looks up the subprocess PID associated with the
task_idin Redis (set bytasks.py) and sends aSIGINTsignal to it usingos.kill. - If the task is PENDING: Revokes the task using
huey.revoke. - Reports an error if the task is already finished or revoked.
- If the task is RUNNING: Looks up the subprocess PID associated with the
- Path Parameters:
task_id: The Huey task ID.
- Response:
{"message": "Sent SIGINT signal..."}(for running tasks){"message": "Task ... was pending and has been successfully revoked."}(for pending tasks)
- Error Responses:
- 404 Not Found: If
task_iddoes not exist or the subprocess PID is gone. - 409 Conflict: If the task is already finished/revoked or fails to revoke.
- 500 Internal Server Error: If signaling fails or other errors occur.
- 404 Not Found: If
-
GET /tasks/queue
- Summary: Get lists of pending and scheduled tasks.
- Description: Retrieves the IDs of tasks currently pending or scheduled in the Huey queue using
huey.pending()andhuey.scheduled(). Note: This does not reliably show tasks that are actively running. - Path Parameters: None
- Query Parameters: None
- Response:
{ "pending_tasks": ["string (task_id)", ...], "scheduled_tasks": ["string (task_id)", ...], "message": "string (e.g., Found X pending and Y scheduled tasks.)" } - Error Responses:
- 500 Internal Server Error: If retrieving queue status fails.
-
GET /tasks/{task_id}/logs
- Summary: Get logs for a specific task.
- Description: Retrieves the content of the log file (
./logs/<task_id>.log) generated by a specific task run. - Path Parameters:
task_id: The Huey task ID.
- Query Parameters:
tail(int, optional): Return only the last N lines of the log.
- Response:
{ "task_id": "string", "message": "string", "logs": "string (log content)" } - Error Responses:
- 404 Not Found: If the log file doesn't exist.
- 500 Internal Server Error: If reading the file fails.
-
DELETE /tasks/{task_id}/logs
- Summary: Delete log file for a specific task.
- Description: Deletes the specific log file (
./logs/<task_id>.log). - Path Parameters:
task_id: The Huey task ID.
- Response:
{"message": "Successfully deleted log file..."} - Error Responses:
- 404 Not Found: If the log file doesn't exist.
- 500 Internal Server Error: If deletion fails.
-
GET /logs
- Summary: List all available log files.
- Description: Returns a list of all
.logfilenames currently in the./logs/directory. - Response:
{"log_files": ["task_id1.log", "task_id2.log", ...]} - Error Responses:
- 500 Internal Server Error: If listing the directory fails.
-
DELETE /logs
- Summary: Clear all task log files.
- Description: Deletes all files ending with
.logwithin the./logs/directory. - Response: Reports the number of deleted files and any errors encountered.
{ "message": "Successfully deleted X log file(s)...", "errors": [ /* list of error strings, if any */ ] } - Error Responses:
- 500 Internal Server Error: If accessing or clearing the directory fails.
-
GET /tasks/{task_id}/outputs/download
- Summary: Download output directory for a task.
- Description: Retrieves the path of the output directory associated with the
task_idfrom Redis (set bytasks.py), zips the entire directory content, and returns it as a downloadable file (task_<task_id>_output.zip). - Path Parameters:
task_id: The Huey task ID.
- Response: A zip file (
application/zip). - Error Responses:
- 404 Not Found: If the task ID mapping or the directory itself doesn't exist.
- 500 Internal Server Error: If zipping or file access fails.
-
GET /tasks/{task_id}/outputs/structure
- Summary: Get structure of a task's output directory.
- Description: Retrieves the path of the output directory associated with the
task_idfrom Redis and returns its file/folder structure as a JSON list. Paths are relative to the specific task's output directory root. - Path Parameters:
task_id: The Huey task ID.
- Response: List of
FileStructureobjects (see below). - Error Responses:
- 404 Not Found: If the task ID mapping or the directory itself doesn't exist.
- 500 Internal Server Error: If reading the directory fails.
-
GET /outputs/structure/{relative_path:path}
- Summary: Get structure of a path within the main outputs directory.
- Description: Retrieves the file/folder structure for a given path relative to the root
./outputs/directory. Uses the sharedhandle_get_structurehelper. - Path Parameters:
relative_path: The path relative to./outputs/(e.g.,my_folder/sub_folderor leave empty/.for the root).
- Response: List of
FileStructureobjects:[ { "path": "string (relative path)", "is_dir": true, "children": [ /* nested FileStructure objects */ ] }, { "path": "string (relative path)", "is_dir": false, "children": null } ] - Error Responses:
- 404 Not Found: If the path doesn't exist.
- 400 Bad Request: If the path is not a directory.
- 500 Internal Server Error: If listing fails.
-
GET /outputs/download/{relative_path:path}
- Summary: Download a specific file or folder from outputs.
- Description: Downloads a specific file or zips and downloads a specific folder relative to the root
./outputs/directory. Uses the sharedhandle_download_itemhelper. - Path Parameters:
relative_path: The path relative to./outputs/.
- Response: A file (
application/octet-streamor detected type) or a zip archive (application/zip). - Error Responses:
- 404 Not Found: If the path doesn't exist.
- 500 Internal Server Error: If reading/zipping fails.
-
DELETE /outputs/{relative_path:path}
- Summary: Delete a file or folder from outputs.
- Description: Deletes a specific file or folder relative to the root
./outputs/directory. Uses the sharedhandle_delete_itemhelper. Warning: This is permanent. - Path Parameters:
relative_path: The path relative to./outputs/.
- Response:
{"message": "Successfully deleted..."} - Error Responses:
- 404 Not Found: If the path doesn't exist.
- 400 Bad Request: If attempting to delete the root
./outputsdirectory. - 500 Internal Server Error: If deletion fails.
-
POST /outputs/move
- Summary: Move/Rename a file or folder within outputs.
- Description: Moves or renames a file or folder within the
./outputs/directory usingshutil.move.- The source path must exist.
- The destination path must not already exist (to prevent overwrites).
- The parent directory of the destination path must exist.
- Cannot be used to move the root
./outputsdirectory itself.
- Request Body:
{ "source_relative_path": "string (required, current relative path)", "destination_relative_path": "string (required, new relative path)" } - Response (Status 200):
{ "message": "Successfully moved {file/directory} from '{source}' to '{destination}'." } - Error Responses:
- 400 Bad Request: If source/destination paths are invalid, if the destination parent doesn't exist, or if attempting to move the root directory.
- 404 Not Found: If the source path does not exist.
- 409 Conflict: If the destination path already exists.
- 500 Internal Server Error: If the move operation fails for other reasons (e.g., permissions).
Input file management endpoints mirror the Output File Management endpoints, but operate on the ./inputs/ directory. Also, it has a route to create a directory, too.
-
GET /inputs/structure/{relative_path:path}
- Summary: Get structure of a path within the inputs directory.
- Description: Retrieves structure relative to
./inputs/. - Response: List of
FileStructureobjects.
-
GET /inputs/download/{relative_path:path}
- Summary: Download a specific file or folder from inputs.
- Description: Downloads file/folder relative to
./inputs/. - Response: File or Zip archive.
-
DELETE /inputs/{relative_path:path}
- Summary: Delete a file or folder from inputs.
- Description: Deletes file/folder relative to
./inputs/. Warning: Permanent. - Response:
{"message": "Successfully deleted..."}
-
POST /inputs/move
- Summary: Move/Rename a file or folder within inputs.
- Description: Moves or renames a file or folder within the
./inputs/directory usingshutil.move. See/outputs/movefor detailed behavior and error conditions. - Request Body:
{ "source_relative_path": "string (required, current relative path)", "destination_relative_path": "string (required, new relative path)" } - Response (Status 200):
{ "message": "Successfully moved {file/directory} from '{source}' to '{destination}'." } - Error Responses: 400, 404, 409, 500 (see
/outputs/move)
-
POST /inputs/directory
- Summary: Create a new directory within the inputs folder.
- Description: Creates a new directory at the specified
relative_pathwithin the./inputs/directory. The path can include parent directories (e.g.,existing_folder/new_subfolder). - Request Body:
{ "relative_path": "string (required, relative path)" } - Response (Status 201):
{ "message": "Successfully created directory '{relative_path}' in inputs." } - Error Responses:
- 400 Bad Request: If
relative_pathis invalid (empty, '.', targets root) or if the parent directory specified in the path does not exist. - 409 Conflict: If a file or directory already exists at the target
relative_path. - 500 Internal Server Error: If directory creation fails for other reasons (e.g., permissions).
- 400 Bad Request: If
-
POST /inputs/upload/{relative_path:path}
- Summary: Upload files to a specific path within inputs, automatically extracting zip files.
- Description: Uploads one or more files to a specified path within
./inputs/. The path is created if it doesn't exist.- If a file ends with
.zip(case-insensitive), it is automatically extracted into the targetrelative_path. - Upon successful extraction, the original
.zipfile is deleted. - If extraction fails, the original
.zipfile is kept, and an error is reported. - Non-zip files are saved directly to the
relative_path. - Allows uploading directly to the root
./inputs/directory (e.g., by specifying.as therelative_path).
- If a file ends with
- Path Parameters:
relative_path: Target path relative to./inputs/. Files (including extracted zip contents) will be placed here.
- Request Body:
multipart/form-datacontaining one or more files. - Response (Status 201 or 207):
{ "message": "Upload process completed...", "uploaded_files": [ {"filename": "string", "size": int, "path": "string (relative path)", "error": "string (optional, only on failed extraction)"} ], "extracted_zips": [ {"filename": "string (original zip)", "extracted_to": "string (relative path)"} ], "errors": [ /* list of general error strings, if any */ ] } - Error Responses:
- 500 Internal Server Error: If directory creation, file writing, or extraction fails unexpectedly.
Configuration file management endpoints operate on the ./external_configs/ directory.
-
GET /configs/aliases
- Summary: Get available config file aliases from super_config.yaml.
- Description: Reads the
super_config.yamlfile and returns a sorted list of path aliases (keys) whose corresponding values do end with.yaml(case-insensitive). These aliases can be used to identify existing configuration files for duplication or other purposes. - Path Parameters: None
- Query Parameters: None
- Response: A JSON list of strings.
[ "config-alias1", "another_config.yaml", "path/to/config_alias_3", ... ]
- Error Responses:
- 500 Internal Server Error: If
super_config.yamlcannot be found or parsed, or an unexpected error occurs. (Note: If the file is found but empty orpath_aliasesis missing/invalid, it returns an empty list[]gracefully).
- 500 Internal Server Error: If
-
GET /configs/structure/{relative_path:path}
- Summary: Get structure of a path within the configs directory.
- Description: Retrieves structure relative to
./external_configs/. - Response: List of
FileStructureobjects.
-
GET /configs/content/{relative_path:path}
- Summary: Get content of a specific config file.
- Description: Retrieves the plain text content of a specific file relative to
./external_configs/. - Path Parameters:
relative_path: The path relative to./external_configs/.
- Response: Plain text file content (
text/plain). - Error Responses:
- 404 Not Found: If the file doesn't exist.
- 400 Bad Request: If the path is not a file.
-
POST /configs/content/{relative_path:path}
- Summary: Create or update a config file.
- Description: Creates a new file or overwrites an existing file at the specified path relative to
./external_configs/. Parent directories are created if they don't exist. - Path Parameters:
relative_path: The path relative to./external_configs/.
- Request Body: Raw text content (
text/plain). - Response:
{"message": "Successfully saved config..."} - Error Responses:
- 400 Bad Request: If attempting to write to the root.
- 500 Internal Server Error: If writing fails.
-
DELETE /configs/{relative_path:path}
- Summary: Delete a specific config file or directory.
- Description: Deletes a specific file or directory (recursively) relative to
./external_configs/. Warning: Permanent. - Path Parameters:
relative_path: The path relative to./external_configs/.
- Response:
{"message": "Successfully deleted config {file|directory}..."} - Error Responses:
- 404 Not Found: If the file or directory doesn't exist.
- 400 Bad Request: If attempting to delete the root
./external_configsdirectory. - 500 Internal Server Error: If deletion fails.
-
POST /configs/move
- Summary: Move/Rename a file or folder within configs.
- Description: Moves or renames a file or folder within the
./external_configs/directory usingshutil.move. See/outputs/movefor detailed behavior and error conditions. - Request Body:
{ "source_relative_path": "string (required, current relative path)", "destination_relative_path": "string (required, new relative path)" } - Response (Status 200):
{ "message": "Successfully moved {file/directory} from '{source}' to '{destination}'." } - Error Responses: 400, 404, 409, 500 (see
/outputs/move)
-
POST /configs/directory
- Summary: Create a new directory within the configs folder.
- Description: Creates a new directory at the specified
relative_pathwithin the./external_configs/directory. Uses the sharedhandle_create_directoryhelper. - Request Body:
{ "relative_path": "string (required, relative path)" } - Response (Status 201):
{ "message": "Successfully created directory '{relative_path}' in external_configs." } - Error Responses:
- 400 Bad Request: If
relative_pathis invalid (empty, '.', targets root) or if the parent directory specified in the path does not exist. - 409 Conflict: If a file or directory already exists at the target
relative_path. - 500 Internal Server Error: If directory creation fails for other reasons (e.g., permissions).
- 400 Bad Request: If
-
POST /configs/duplicate
- Summary: Duplicate a pipeline config into external_configs.
- Description: Duplicates a configuration file identified by a
source_alias(fromsuper_config.yaml) into the./external_configs/directory at the specifieddestination_relative_path. The source alias must resolve to an existing.yamlfile. The destination path must not already exist, and its parent directory must exist. - Request Body:
{ "source_alias": "string (required, alias from super_config.yaml)", "destination_relative_path": "string (required, new relative path in external_configs)" } - Response (Status 201):
{ "message": "Successfully duplicated config from alias '{source_alias}' to '{destination_relative_path}' in external_configs." } - Error Responses:
- 400 Bad Request: If the source alias doesn't point to a
.yamlfile, if destination path is invalid, or if destination parent directory doesn't exist. - 404 Not Found: If the source alias is not found in
super_config.yamlor the resolved source file doesn't exist. - 409 Conflict: If the destination path already exists.
- 500 Internal Server Error: If resolving paths, reading the source, or writing the destination file fails.
- 400 Bad Request: If the source alias doesn't point to a