% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/track_progress.R
\name{track_progress}
\alias{track_progress}
\title{Track Progress of Parallel Processing Tasks}
\usage{
track_progress(
  df,
  index,
  total_tasks,
  n_post,
  batch_size,
  provider,
  worker_env = NULL,
  verbose = TRUE
)
}
\arguments{
\item{df}{Data frame. A subset of data to process in this task.}

\item{index}{Integer. The current task number (for progress tracking).}

\item{total_tasks}{Integer. Total number of tasks in the parallel job.}

\item{n_post}{Integer. Number of posts to process in each API call.}

\item{provider}{Character. AI provider to use, either "OpenAI" or "Groq".}

\item{worker_env}{Environment or NULL. When running in a parallel worker, the worker's
package environment so config (e.g. \code{coding_instruction}, \code{id_column})
is available. If NULL (default), the package's \code{.package_env} is used.}

\item{verbose}{Logical. If TRUE (default), progress messages are shown. If FALSE, suppressed.}
}
\value{
Data frame with successfully processed results from \code{main_func()},
or NULL if an error occurs during processing.
}
\description{
This function wraps the main processing function with progress tracking,
error handling, and rate limiting. It's designed to be called from parallel
workers to process data batches while providing feedback on progress.
}
\details{
The function provides several important features:
\itemize{
\item Progress messages showing current task vs total tasks
\item Rate limiting with 5-second delays to avoid overwhelming APIs
\item Comprehensive error handling with informative error messages
\item Automatic validation of provider parameter
\item Graceful degradation returning NULL on errors
}

This function is primarily used internally by the parallel processing
framework and calls \code{main_func()} with the \code{n_post} parameter passed by the caller.
}
\seealso{
\code{\link[=main_func]{main_func()}}, \code{\link[=parallel_execute]{parallel_execute()}}
}
\keyword{internal}
