kernelfoundry.eval_pipeline.database¶
Database initialization, utility functions and table definitions.
Functions
|
Adds the item to the database, ignoring any errors to not stop the program flow. |
|
Create and add a new Job to the database. |
|
Add a single log entry for a job. |
|
Add multiple log entries in a single transaction for better performance. |
|
Initialize database connections (PostgreSQL or SQLite based on DB_IP env var). |
|
Update the progress of a job in the database. |
|
Update the status config, and timestamps of a job in the database. |
- kernelfoundry.eval_pipeline.database.init(cfg)[source]¶
Initialize database connections (PostgreSQL or SQLite based on DB_IP env var).
- kernelfoundry.eval_pipeline.database.add_ignore_errors(item)[source]¶
Adds the item to the database, ignoring any errors to not stop the program flow.
- kernelfoundry.eval_pipeline.database.add_job(task_origin: str, status: str = 'INIT') int | None[source]¶
Create and add a new Job to the database.
- kernelfoundry.eval_pipeline.database.update_job_status(job_id: int, status: str | None = None, started_at: datetime | None = None, finished_at: datetime | None = None, task_id: str | None = None, config: dict | None = None, progress: float | None = None) bool[source]¶
Update the status config, and timestamps of a job in the database.
- Parameters:
job_id (int) – The ID of the job to update
status (str) – New status (INIT, RUN, COMPLETE, FAIL)
started_at (datetime, optional) – Timestamp when job started
finished_at (datetime, optional) – Timestamp when job finished
task_id (str, optional) – The task ID to associate with this job
config (dict, optional) – Updated configuration to store in the database
progress (float, optional) – Updated progress value between 0.0 and 1.0
- Returns:
True if update was successful, False otherwise
- Return type:
- kernelfoundry.eval_pipeline.database.update_job_progress(job_id: int, progress: float) bool[source]¶
Update the progress of a job in the database.
- kernelfoundry.eval_pipeline.database.add_job_log(job_id: int, level: str, message: str, timestamp: datetime | None = None, hostname: str | None = None, kernel_uuid: str | None = None, agent_session_id: str | None = None) int | None[source]¶
Add a single log entry for a job.
- Parameters:
job_id (int) – The ID of the job this log belongs to
level (str) – Log level (INFO, DEBUG, WARNING, ERROR)
message (str) – The log message
timestamp (datetime, optional) – Custom timestamp (defaults to server time)
hostname (str | None, optional) – Hostname of the process that emitted the log entry
kernel_uuid (str | None, optional) – UUID of the kernel associated with the log entry
agent_session_id (str | None, optional) – Agent session identifier associated with the log entry
- Returns:
The log entry ID if successful, None otherwise
- Return type:
int | None
- kernelfoundry.eval_pipeline.database.add_job_log_batch(logs: list[dict]) bool[source]¶
Add multiple log entries in a single transaction for better performance.
- Parameters:
logs (list[dict]) – List of log dictionaries, each containing: - job_id (int): The ID of the job - hostname (str | None, optional): Hostname of the process that emitted the log entry - kernel_uuid (str | None, optional): UUID of the kernel associated with the log entry - agent_session_id (str | None, optional): Agent session identifier associated with the log entry - level (str): Log level (INFO, DEBUG, WARNING, ERROR) - message (str): The log message - timestamp (datetime, optional): Custom timestamp
- Returns:
True if all logs were added successfully, False otherwise
- Return type:
Example:
logs = [ {"job_id": 1, "level": "INFO", "message": "Starting task"}, {"job_id": 1, "level": "DEBUG", "message": "Processing step 1"}, {"job_id": 1, "level": "ERROR", "message": "Failed at step 2"}, ] add_job_log_batch(logs)
- class kernelfoundry.eval_pipeline.database.Kernel(**kwargs)[source]¶
-
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class kernelfoundry.eval_pipeline.database.Task(**kwargs)[source]¶
-
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class kernelfoundry.eval_pipeline.database.Rag(**kwargs)[source]¶
-
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class kernelfoundry.eval_pipeline.database.Job(**kwargs)[source]¶
-
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class kernelfoundry.eval_pipeline.database.JobLog(**kwargs)[source]¶
-
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
Modules