Skip to content

Bazefield Insert Allocation Jobs

The JobBazeInsertAlloc class is a job instance that inserts allocation history into Bazefield historian. This class is defined in the job_instance_baze_insert_alloc.py file and inherits from the JobInstance base class.

Python Class

Required Parameters

All the parameters listed below must be provided in the parameters column of the job_instance table in JSON format.

  • object_filter: A dictionary with filters to apply when selecting objects to insert allocations for. It has one required key, "selected", and one optional key, "ignored". Each key can contain any of the following optional keys: "instances", "types", "models", "parent". The values are lists of strings. For example:

    {
      "selected": {
        "types": ["Inverter"],
        "instances": ["RBG-RBG1-TS2-INV01"]
      },
      "ignored": {
        "instances": ["RBG-RBG1-TS2-INV02"]
      }
    }
    

    This example selects all objects of type "Inverter" and the specific instance "RBG-RBG1-TS2-INV01", except the instance "RBG-RBG1-TS2-INV02".

    The "parent" key can be used to resolve child objects from the performance database. Child objects can be solar inverters or wind turbines. For example:

    {
      "selected": {
        "parent": ["RBG-RBG1"]
      }
    }
    

    This example selects all child objects (inverters or turbines) of the parent object "RBG-RBG1".

  • start: The start datetime of the allocation period in the format YYYY-MM-DD HH:MM:SS.

  • end: The end datetime of the allocation period in the format YYYY-MM-DD HH:MM:SS.

  • allocation_category: The allocation category to insert (e.g., "Night").

  • allocation_type: The allocation type to insert (e.g., "Internal - Solar - Event Types").

  • child_category (optional): A child allocation category. If provided, a secondary allocation will also be inserted alongside the main one. The child allocation type is determined automatically based on the allocation_type:

    • If allocation_type contains "Wind", the child allocation type will be "Internal - Wind - Event Causes".
    • Otherwise, it will be "Internal - Solar - Event Causes".
  • comment (optional): A string comment for the allocation. Defaults to "Synced from BoP allocation (Performance API)".

The job will also directly look up the following parameter from the settings table in the database (under the baze_tag_persistance section):

  • job_step_interval: The interval in seconds to wait after each job step finishes before starting the next one. If not set, defaults to 0 seconds. This is important to avoid overloading Bazefield historian with too many requests in a short period of time.

Job Steps

One job step is created per resolved object instance. Each step stores the object name and the allocation parameters (category, type, child category, and comment). The steps are ordered alphabetically by object instance name.

When a step is executed, it calls the Bazefield historian API to insert the allocation history for that object over the full period defined by start and end. If child_category is set, the insertion also includes the child allocation category in the same API call.

Automatic Processing

Job Creation

Jobs can be created on demand by any system or user that has access to the job_instances table in the performance database. The job type name that must be used is "Bazefield Insert Allocation".

Job Execution

Jobs are picked up and executed by the job processor. The job will be marked as "Finished" when all steps complete successfully, or "Failed" if any step raises an error. Failed steps store the error message in the database for inspection.