Actor: Documentation update

Signed-off-by: Václav Vančura <commit@vancura.dev>
This commit is contained in:
Václav Vančura 2025-02-05 10:50:49 +01:00 committed by Adam Kliment
parent 31056d10e4
commit 1ba5aeefdc
2 changed files with 7 additions and 8 deletions

View File

@ -49,7 +49,7 @@ This Actor wraps the [Docling project](https://ds4sd.github.io/docling/) to prov
### Using Apify API ### Using Apify API
```bash ```bash
curl --request POST \ $ curl --request POST \
--url "https://api.apify.com/v2/acts/username~actorname/run" \ --url "https://api.apify.com/v2/acts/username~actorname/run" \
--header 'Content-Type: application/json' \ --header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \ --header 'Authorization: Bearer YOUR_API_TOKEN' \
@ -98,7 +98,7 @@ If the Actor logs warnings or debug info, these messages can be pushed to `DOCLI
You can retrieve the results programmatically by calling: You can retrieve the results programmatically by calling:
```bash ```bash
apify key-value-store get OUTPUT_RESULT $ apify key-value-stores get-value OUTPUT_RESULT
``` ```
### Example Outputs ### Example Outputs
@ -188,7 +188,7 @@ If you wish to develop or modify this Actor locally:
4. Run the Actor locally using: 4. Run the Actor locally using:
```bash ```bash
apify run $ apify run
``` ```
### Actor Structure ### Actor Structure

View File

@ -2,14 +2,14 @@
# --- Setup Error Handling --- # --- Setup Error Handling ---
# Initialize log file first # Initialize log file first.
LOG_FILE="/tmp/docling.log" LOG_FILE="/tmp/docling.log"
touch "$LOG_FILE" || { touch "$LOG_FILE" || {
echo "Fatal: Cannot create log file at $LOG_FILE" echo "Fatal: Cannot create log file at $LOG_FILE"
exit 1 exit 1
} }
# Ensure all output is logged # Ensure all output is logged.
exec 1> >(tee -a "$LOG_FILE") exec 1> >(tee -a "$LOG_FILE")
exec 2> >(tee -a "$LOG_FILE" >&2) exec 2> >(tee -a "$LOG_FILE" >&2)
@ -67,7 +67,7 @@ if [ "$(echo "${INPUT}" | jq -r '.ocr')" = "true" ]; then
DOC_CONVERT_CMD="${DOC_CONVERT_CMD} --ocr" DOC_CONVERT_CMD="${DOC_CONVERT_CMD} --ocr"
fi fi
# Print the exact command that will be executed # Print the exact command that will be executed.
echo "Debug: Command string: $DOC_CONVERT_CMD" echo "Debug: Command string: $DOC_CONVERT_CMD"
echo "Debug: Full command: /usr/bin/time -v bash -c \"$DOC_CONVERT_CMD\"" echo "Debug: Full command: /usr/bin/time -v bash -c \"$DOC_CONVERT_CMD\""
@ -83,12 +83,11 @@ touch "$TIMESTAMP_FILE" || {
exit 1 exit 1
} }
# Execute the command with timeout and memory monitoring
echo "Starting document processing with memory monitoring..." echo "Starting document processing with memory monitoring..."
/usr/bin/time -v bash -c "$DOC_CONVERT_CMD" 2>&1 | tee -a "$LOG_FILE" /usr/bin/time -v bash -c "$DOC_CONVERT_CMD" 2>&1 | tee -a "$LOG_FILE"
DOCLING_EXIT_CODE=${PIPESTATUS[0]} DOCLING_EXIT_CODE=${PIPESTATUS[0]}
# Check if the command failed and handle the error # Check if the command failed and handle the error.
if [ $DOCLING_EXIT_CODE -ne 0 ]; then if [ $DOCLING_EXIT_CODE -ne 0 ]; then
echo "Error: Docling command failed with exit code $DOCLING_EXIT_CODE" echo "Error: Docling command failed with exit code $DOCLING_EXIT_CODE"
echo "Memory usage information:" echo "Memory usage information:"